MrDEB
Well-Known Member
I have a clunky code that works BUT feel that this posted code may work better. My present clunky code has too mant spaces etc. In this posted code it uses a buffer to store the const arrays but it won't compile.
Any explanation as to how this posted code works as I have tried to understand what is going on but can't figure out how the const arrays are xfered from the Display_buffer to Data bus.(see draw data sub) the compile error is in this _ Data_Bus = Display_Out XOR $11111111
DIM Display_Out AS BYTE ' CONST array data
DIM Display_Buffer(8) AS BYTE ' data to send to matrix
DIM Data_Bus AS portb ' data that matrix displays
DIM Colum_start AS WORD ' cathodes
DIM Anode_Data AS PORTC ' Anodes
DIM x AS BYTE
DIM y AS BYTE
DIM Speed AS BYTE
//SUB ROUTINES
SUB Load_Buffer()
FOR x = 0 TO 96 ' 120 / 8 = 15
Display_Buffer(x) = Sentence_Data(x)
NEXT
END SUB
SUB Draw_Data()
FOR x = Colum_start TO (Colum_start+7) ' COLUMS ON PORT b counter
Display_Out = Display_Buffer(x) ' const data
Data_Bus = Display_Out XOR $11111111 ' inverts the CONST array data at the port
Display_Buffer(x) = Sentence_Data(x)
Data_Bus = Sentence_Data XOR %11111111 ' reverse the data bits
Data_Bus = 0 ' data bus
Data_Bus.bits(7 - (x- Colum_start)) = 1 ' cycle the anodes from 0 to 7
Data_Bus = 0
display_out = 1
DELAYMS(10)
display_out= 0
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 is Cathodes on portb
Colum_start = 0
END IF
END IF
END SUB
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
Load_Buffer()
WHILE true
Draw_Data()
FOR y = 0 TO 20
Draw_Data()
NEXT
Scroll_Text()
WEND
Any explanation as to how this posted code works as I have tried to understand what is going on but can't figure out how the const arrays are xfered from the Display_buffer to Data bus.(see draw data sub) the compile error is in this _ Data_Bus = Display_Out XOR $11111111
DIM Display_Out AS BYTE ' CONST array data
DIM Display_Buffer(8) AS BYTE ' data to send to matrix
DIM Data_Bus AS portb ' data that matrix displays
DIM Colum_start AS WORD ' cathodes
DIM Anode_Data AS PORTC ' Anodes
DIM x AS BYTE
DIM y AS BYTE
DIM Speed AS BYTE
//SUB ROUTINES
SUB Load_Buffer()
FOR x = 0 TO 96 ' 120 / 8 = 15
Display_Buffer(x) = Sentence_Data(x)
NEXT
END SUB
SUB Draw_Data()
FOR x = Colum_start TO (Colum_start+7) ' COLUMS ON PORT b counter
Display_Out = Display_Buffer(x) ' const data
Data_Bus = Display_Out XOR $11111111 ' inverts the CONST array data at the port
Display_Buffer(x) = Sentence_Data(x)
Data_Bus = Sentence_Data XOR %11111111 ' reverse the data bits
Data_Bus = 0 ' data bus
Data_Bus.bits(7 - (x- Colum_start)) = 1 ' cycle the anodes from 0 to 7
Data_Bus = 0
display_out = 1
DELAYMS(10)
display_out= 0
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 is Cathodes on portb
Colum_start = 0
END IF
END IF
END SUB
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
Load_Buffer()
WHILE true
Draw_Data()
FOR y = 0 TO 20
Draw_Data()
NEXT
Scroll_Text()
WEND