Geez oh grief.
"Buffer" is exactly what I explained to you a hundred posts ago. It's an array where you store the entire message so that it can be scrolled.
Sure. Why not? We're only four pages into this saga, so it's definitely time to start throwing some more randomly selected terms into the mix.Am thinking that the EEPROM can be used??
... As far as number of pages, yes but not having schooling in coding, the code I have working is an accomplishment in my book and reviewing Post 17, my method to achieve scrolling accomplishes the same basic principal but the long way around...
?..Trying to decipher why the data can't be displayed directly from the CONST array.....
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 3/4/2014 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
DEVICE = 18F2420
CLOCK = 8
// import LCD library...
INCLUDE "convert.bas"
INCLUDE "InternalOscillator.bas"
INCLUDE "Utils.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "SUART.bas"
// Arrays
// Arrays
// Arrays
// Desired sentence (ANODES)
CONST Sentence_Data(96) AS BYTE = (%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111110,%01001010,%01001010,%01000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111110,%01000010,%01000010,%01000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00111100,%01000010,%01000010,%00111100,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111110,%01000010,%01000010,%01000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111110,%01000010,%01000010,%01000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000)
// CATHODES
CONST Row1Data(8) AS BYTE = (%11111110,%11111101,%11111011,%11110111,%11101111,%11011111,%10111111,%01111111)
DIM Display_Buffer(8) AS BYTE
DIM Data_Display AS BYTE
DIM Colum_start AS portc
DIM Cathode_Data AS portb
DIM x AS BYTE
DIM y AS BYTE
DIM Speed AS BYTE
//SUB ROUTINES
SUB Draw_Data()
FOR x = Colum_start TO (Colum_start+7) ' COLUMS ON PORT C
Data_Display= Sentence_Data(x)
Data_Display = Display_Buffer(x) ' LOAD BUFFER WITH "Sentence_Data" CONST array
Cathode_Data = 0
Cathode_Data.bits(7 - (x- Colum_start)) = 1 ' cycle the cathodes from 0 to 7
'SetBaudrate(sbr9600)
'UART.Write("Value = %", BinToStr(Display_Buffer(x) ,40),13,10)
delayms(100)
NEXT
END SUB
SUB Scroll_Text()
IF Speed <> 0 THEN
DEC(Speed)
ELSE
Speed = 6
Colum_start = Colum_start + 1
IF Colum_start + 8 = 96 THEN ' # of elements in CONST array
Colum_start = 0
END IF
END IF
END SUB
'SetTX(PORTC.6)
'SetRX(PORTC.7)
'SetBaudrate(sbr9600)
'SetMode(umTrue)
SetAllDigital // Make all Pins digital I/O's
TRISC = %00000000 // Make PORTD all outputs
TRISB = %00000000 // Make PORTB all outputs
y = 0
Speed = 50
Colum_start = 0
WHILE true
Draw_Data()
Scroll_Text()
WEND
That's debatableMaking a little progress
DIM Data_Display AS BYTE
DIM Colum_start AS portc
SUB Draw_Data()
FOR x = Colum_start TO (Colum_start+7) ' COLUMS ON PORT C
Data_Display= Sentence_Data(x)
Data_Display = Display_Buffer(x) ' LOAD BUFFER WITH "Sentence_Data" CONST array
Cathode_Data = 0
Cathode_Data.bits(7 - (x- Colum_start)) = 1 ' cycle the cathodes from 0 to 7
delayms(100)
NEXT
END SUB
I have always found understanding other's code is difficult, especially when I don't understand the fundamental principles of what it's attempting to do.
At this point, I think you have two options on for this project:
1. Highlight all of your code from beginning to end. Press the [delete] key. Go back to posts #17 & #18, understand what you need to do and start over from scratch.
2. Beg/pay/pester someone to write the code for you.
Taking code not designed to do what you want with hardware you don't have and changing the code you don't understand to do something you don't understand how to do doesn't seem to be working for you. Imagine that.
#include <pic.h> // pic specific identifiers
#define _XTAL_FREQ 20000000 // Xtal speed
__CONFIG(0x37F2); // Config bits
#define ROW_PORT PORTB //
#define ROW_TRIS TRISB
#define COL_PORT PORTC //
#define COL_TRIS TRISC
extern const unsigned char fnt[]; // delclare as external (in another file)
// Required prototypes
void DelayMs(int x), scroll(char dir), invert(void);
void clear(void), display(const char* str);
// Variables
unsigned char pos; // keep tabs on rows
unsigned char leds[8]; // led buffer
unsigned char leds2[8]; // 2nd led buffer
unsigned char pow[] = {1,2,4,8,16,32,64,128}; // power array
void main(void) // program entry
{
char x,y,z,t;
ADCON1 = 0x6;
ROW_TRIS = 0b00000000; // row port as outputs
COL_TRIS = 0b00000000; // col port as outputs
T2CON = 0x16; // setup timer 2
ROW_PORT = 0;
COL_PORT = 0xFF; // setup led array
PR2 = 249; // timer preload value
TMR2IE = 1; // enable timer 2 interrupt
PEIE = 1; // enable peripheral interrupt
GIE = 1; // enableglobal interrupt
pos = 0; // start at beginning
while(1) // endless Loop
{
display("Hello world!!"); // display a message
clear(); // start again
DelayMs(1000);
}
}
void display(const char* str)
{
int addr; // large table (requires an int)
int z; // looping variable
while(*str!=0)
{
addr = ((int)*str++ - 0x20); // locate character in table
addr *= 8; // 8 bytes in each char
for(z=0;z<8;z++)
leds2[z] = fnt[addr+z]; // load em up!!
for(z=0;z<8;z++)
scroll(1); // scroll right.
}
}
void interrupt ISR()
{
if(TMR2IF) // omly do if timeout occured
{
ROW_PORT = 0xff;
COL_PORT = leds[pos]; // Retrive current array
ROW_PORT -= pow[pos]; // Keep powers in table
if(pos++ == 7) pos = 0; // cycle through array buffer
TMR2IF = 0; // clear interrupt
}
}
void clear() // clear buffer
{
char x;
for(x=0;x<8;x++)
leds[x] = 0;
}
void scroll(char dir)
{
char x;
switch (dir)
{
case 0: // scroll left
for(x=0;x<8;x++)
{
if(leds2[x] & 1)
leds[x]+=128;
leds[x] >>= 1;
leds2[x]>>= 1;
}
DelayMs(100);
break;
case 1: // scroll right
for(x=0;x<8;x++)
{
if(leds2[x] & 128)
leds[x]+=1;
leds[x] <<= 1;
leds2[x] <<= 1;
}
DelayMs(100);
break;
case 2: // scroll up
for(x=7;x>0;x--)
leds[x] = leds[x-1];
leds[0] = leds2[7];
for(x=7;x>0;x--)
leds2[x] = leds2[x-1];
leds2[0] = 0;
DelayMs(100);
break;
case 3: // scroll down
for(x=0;x<8;x++)
leds[x] = leds[x+1];
leds2[7] = leds[0];
for(x=0;x<8;x++)
leds2[x] = leds2[x+1];
leds2[7] = 0;
DelayMs(100);
}
}
void DelayMs(int x)
{ // wrapper function for larger delays.
while(x--)
__delay_ms(1);
}
FOR x = Colum_start TO (Colum_start+7) ' COLUMS ON PORT b counter
buffer = Anodes_Data ' const data
Data_Bus = Display_Out XOR $11111111 ' inverts the CONST array data at the portb
Data_Bus = 0 ' data bus
Data_Bus.bits(7 - (x- Colum_start)) = 1 ' cycle the cathodes from 0 to 7
Anode_Data =
DELAYMS(10)
Anode_Data = 0
NEXT
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?