I have the alphebet in upper case but working on lower ase as well. Plan to build a module for alphabet but here is my present code. It scrolls from right to left fairly well but the code could be better. Been looking at a C+ version and get lost.
This is Swordfish. Any suggestions on direction I should go. Been looking over your Pixel brothers code as well looking for ideas that might improve this code.
Code: Select all
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 "shift.bas"
INCLUDE "convert.bas"
// Arrays
// Arrays
' LETTER K
CONST Cathodes_Data(9)AS BYTE = (%01111111, ' KEEP THESE AS THEY DON"T CHANGE PER LETTER
%10111111,
%11011111,
%11101111,
%11110111,
%11111011,
%11111101,
%11111110,
%11111111)
' LETTER A
CONST A_Data(9)AS BYTE = (%01111111, // A
%10010000,
%10010000,
%10010000,
%01111111,
%00000000,
%00000000,
%00000000,
%00000000)
' LETTER B
CONST B_Data(9)AS BYTE = (%11111111, // B
%10011001,
%10011001,
%01100110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
' LETTER C
CONST C_Data(9)AS BYTE = (%00111100, // B
%01000010,
%10000001,
%01000010,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST D_Data(9)AS BYTE = (%11111111, // D
%10000001,
%10000001,
%01000010,
%00111100,
%00000000,
%00000000,
%00000000,
%00000000)
CONST E_Data(9)AS BYTE = (%01111110, // E
%10001001,
%10001001,
%10000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST F_Data(9)AS BYTE = (%11111111, // F
%10001000,
%10001000,
%10000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST G_Data(9)AS BYTE = (%00111110, // G
%01000001,
%00010001,
%00001110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST H_Data(9)AS BYTE = (%11111111, // H
%00010000,
%00010000,
%11111111,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST I_Data(9)AS BYTE = (%00000000, // I
%10000001,
%11111111,
%10000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST J_Data(9)AS BYTE = (%00001110, // J
%00000001,
%00000001,
%11111110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST K_Data(9)AS BYTE = (%11111111, 'K
%00011000,
%00100100,
%01000010,
%00000001,
%00000000,
%00000000,
%00000000,
%00000000)
CONST L_Data(9)AS BYTE = (%11111111, // L
%00000001,
%00000001,
%00000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST M_Data(9)AS BYTE = (%01111111, // M
%10000000,
%01000000,
%10000000,
%11111111,
%00000000,
%00000000,
%00000000,
%00000000)
CONST N_Data(9)AS BYTE = (%11111111, // N
%00100000,
%00001000,
%00000100,
%11111111,
%00000000,
%00000000,
%00000000,
%00000000)
CONST O_Data(9)AS BYTE = (%01111110, // 0
%10000001,
%10000001,
%01111110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST P_Data(9)AS BYTE = (%01111111, // P
%10010000,
%10010000,
%01100000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST Q_Data(9)AS BYTE = (%01111100, // Q
%10000001,
%10000001,
%01111110,
%00000010,
%00000001,
%00000000,
%00000000,
%00000000)
CONST R_Data(9)AS BYTE = (%01111111, // R
%10010000,
%10010000,
%01111000,
%00000111,
%00000000,
%00000000,
%00000000,
%00000000)
CONST S_Data(9)AS BYTE = (%01110010, // S
%10001001,
%10010001,
%00001110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST T_Data(9)AS BYTE = (%10000000, // T
%10000000,
%11111111,
%10000000,
%10000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST U_Data(9)AS BYTE = (%11111110, // U
%00000001,
%00000001,
%11111110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST V_Data(9)AS BYTE = (%10000000, // V
%00100000,
%00001000,
%00000010,
%00001000,
%00100000,
%10000000,
%00000000,
%00000000)
CONST W_Data(9)AS BYTE = (%11111111, // W
%00000010,
%00000100,
%00000100,
%00000010,
%11111111,
%00000000,
%00000000,
%00000000)
CONST X_Data(9)AS BYTE = (%10000001, // X
%01000100,
%00010000,
%01000100,
%10000001,
%00000000,
%00000000,
%00000000,
%00000000)
CONST Y_Data(9)AS BYTE = (%11000000, // Y
%00100000,
%00011111,
%00100000,
%11000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST Z_Data(9)AS BYTE = (%01000011, // Z
%01000101,
%01001001,
%01100001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST ab_Data(6)AS BYTE = ($30,
$48,
$84,
$48,
$70,
$80)
' LETTER A
CONST aa_Data(9)AS BYTE = (%01111111, // a
%00010000,
%00010000,
%0010000,
%00111111,
%00000000,
%00000000,
%00000000,
%00000000)
' LETTER B
CONST bb_Data(9)AS BYTE = (%11111111, // b
%10011001,
%10011001,
%01100110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
' LETTER C
CONST cc_Data(9)AS BYTE = (%00111100, // c
%01000010,
%10000001,
%01000010,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST dd_Data(9)AS BYTE = (%11111111, // d
%10000001,
%10000001,
%01000010,
%00111100,
%00000000,
%00000000,
%00000000,
%00000000)
CONST ee_Data(9)AS BYTE = (%01111110, // e
%10001001,
%10001001,
%10000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST ff_Data(9)AS BYTE = (%11111111, // f
%10001000,
%10001000,
%10000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST gg_Data(9)AS BYTE = (%00111110, // g
%01000001,
%00010001,
%00001110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST hh_Data(9)AS BYTE = (%11111111, // h
%00010000,
%00010000,
%11111111,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST ii_Data(9)AS BYTE = (%00000000, // i
%10000001,
%11111111,
%10000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST jj_Data(9)AS BYTE = (%00001110, // j
%00000001,
%00000001,
%11111110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST kk_Data(9)AS BYTE = (%11111111, 'k
%00011000,
%00100100,
%01000010,
%00000001,
%00000000,
%00000000,
%00000000,
%00000000)
CONST ll_Data(9)AS BYTE = (%11111111, // l
%00000001,
%00000001,
%00000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST mm_Data(9)AS BYTE = (%01111111, // m
%10000000,
%01000000,
%10000000,
%11111111,
%00000000,
%00000000,
%00000000,
%00000000)
CONST nn_Data(9)AS BYTE = (%11111111, // n
%00100000,
%00001000,
%00000100,
%11111111,
%00000000,
%00000000,
%00000000,
%00000000)
CONST oo_Data(9)AS BYTE = (%01111110, // o
%10000001,
%10000001,
%01111110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST pp_Data(9)AS BYTE = (%01111111, // Pp
%10010000,
%10010000,
%01100000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST qq_Data(9)AS BYTE = (%01111100, // q
%10000001,
%10000001,
%01111110,
%00000010,
%00000001,
%00000000,
%00000000,
%00000000)
CONST rr_Data(9)AS BYTE = (%01111111, // r
%10010000,
%10010000,
%01111000,
%00000111,
%00000000,
%00000000,
%00000000,
%00000000)
CONST ss_Data(9)AS BYTE = (%01110010, // s
%10001001,
%10010001,
%00001110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST tt_Data(9)AS BYTE = (%10000000, // t
%10000000,
%11111111,
%10000000,
%10000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST uu_Data(9)AS BYTE = (%11111110, // u
%00000001,
%00000001,
%11111110,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST vv_Data(9)AS BYTE = (%10000000, // v
%00100000,
%00001000,
%00000010,
%00001000,
%00100000,
%10000000,
%00000000,
%00000000)
CONST ww_Data(9)AS BYTE = (%11111111, // w
%00000010,
%00000100,
%00000100,
%00000010,
%11111111,
%00000000,
%00000000,
%00000000)
CONST xx_Data(9)AS BYTE = (%10000001, // x
%01000100,
%00010000,
%01000100,
%10000001,
%00000000,
%00000000,
%00000000,
%00000000)
CONST yy_Data(9)AS BYTE = (%11000000, // y
%00100000,
%00011111,
%00100000,
%11000000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST zz_Data(9)AS BYTE = (%01000011, // z
%01000101,
%01001001,
%01100001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
// variable declaration
'DIM x AS BYTE
DIM Anodes_data(9) AS BYTE
DIM index AS BYTE
'DIM Anodes_data(9) AS BYTE
DIM y AS BYTE
DIM x AS BYTE
// Sub Routines
// Start Of Program
'portc = 0
'portb = 1
SetAllDigital // Make all Pins digital I/O's
TRISC = %00000000 // Make PORTD all outputs
TRISB = %00000000 // Make PORTB all outputs
y = 0
// Main Loop
WHILE True()
FOR x = 0 TO 25
SELECT x
CASE 0 Anodes_data = a_Data
CASE 1 Anodes_data = B_Data
CASE 2 Anodes_data = C_Data
CASE 3 Anodes_data = D_Data
CASE 4 Anodes_data = E_Data
CASE 5 Anodes_data = F_Data
CASE 6 Anodes_data = G_Data
CASE 7 Anodes_data = H_Data
CASE 8 Anodes_data = I_Data
CASE 9 Anodes_data = J_Data
CASE 10 Anodes_data = K_Data
CASE 11 Anodes_data = L_Data
CASE 12 Anodes_data = M_Data
CASE 13 Anodes_data = N_Data
CASE 14 Anodes_data = O_Data
CASE 15 Anodes_data = P_Data
CASE 16 Anodes_data = Q_Data
CASE 17 Anodes_data = R_Data
CASE 18 Anodes_data = S_Data
CASE 19 Anodes_data = T_Data
CASE 20 Anodes_data = U_Data
CASE 21 Anodes_data = V_Data
CASE 22 Anodes_data = W_Data
CASE 23 Anodes_data = X_Data
CASE 24 Anodes_data = Y_Data
CASE 25 Anodes_data = Z_Data
END SELECT
'Anodes_data =
'a1_data ' SUB ROUTE TO CHANGE CONST ARRAY DATA FOR NEXT LETTER
//000000000000000000000
portc = Anodes_data(0) '0
portb = Cathodes_Data(0)
DELAYMS(10)
//11111111111111111111111111
portc = Anodes_data(0) '1
portb = Cathodes_Data(0)
DELAYMS(10)
portc = Anodes_data(1)
portb = Cathodes_Data(0)
DELAYMS(100)
//2222222222222222222222222
portc = Anodes_data(0) '2
portb = Cathodes_Data(2)
DELAYMS(10)
portc = Anodes_data(1)
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(2)
portb = Cathodes_Data(0)
DELAYMS(100)
//3333333333333333333333333333333333333
portc = %00000000
portc = Anodes_data(0) '3
portb = Cathodes_Data(3)
DELAYMS(10)
portc = Anodes_data(1)
portb = Cathodes_Data(2)
DELAYMS(10)
portc = Anodes_data(2)
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(3)
portb = Cathodes_Data(0)
DELAYMS(100)
portc = %00000000
//44444444444444444444444444444444444444
portc = Anodes_data(0)
portb = Cathodes_Data(4) '4
DELAYMS(10)
portc = Anodes_data(1)
portb = Cathodes_Data(3)
DELAYMS(10)
portc = Anodes_data(2)
portb = Cathodes_Data(2)
DELAYMS(10)
portc = Anodes_data(3)
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(4)
portb = Cathodes_Data(0)
DELAYMS(100)
portc = %00000000
//555555555555555555555555555555555555555555
portc = Anodes_data(0) '5
portb = Cathodes_Data(5)
DELAYMS(10)
portc = %00000000
portc = Anodes_data(1)
portb = Cathodes_Data(4)
DELAYMS(10)
portc = Anodes_data(2)
portb = Cathodes_Data(3)
DELAYMS(10)
portc = Anodes_data(3)
portb = Cathodes_Data(2)
DELAYMS(10)
portc = Anodes_data(4)
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(5)
portb = Cathodes_Data(0)
DELAYMS(100)
'66666666666666666666666666666666666666666666
portc = %00000000
portc = Anodes_data(0) '6
portb = Cathodes_Data(6)
DELAYMS(10)
portc = Anodes_data(1)
portb = Cathodes_Data(5)
DELAYMS(10)
portc = Anodes_data(2)
portb = Cathodes_Data(4)
DELAYMS(10)
portc = Anodes_data(3)
portb = Cathodes_Data(3)
DELAYMS(10)
portc = Anodes_data(4)
portb = Cathodes_Data(2)
DELAYMS(10)
portc = Anodes_data(5)
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(6)
portb = Cathodes_Data(0)
DELAYMS(100)
//777777777777777777777777777777777777777
portc = Anodes_data(0) '7
portb = Cathodes_Data(7)
DELAYMS(10)
portc = Anodes_data(1)
portb = Cathodes_Data(6)
DELAYMS(10)
portc = Anodes_data(2)
portb = Cathodes_Data(5)
DELAYMS(10)
portc = Anodes_data(3)
portb = Cathodes_Data(4)
DELAYMS(10)
portc = Anodes_data(4)
portb = Cathodes_Data(3)
DELAYMS(10)
portc = Anodes_data(5)
portb = Cathodes_Data(2)
DELAYMS(1)
portc = Anodes_data(6)
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(7)
portb = Cathodes_Data(0)
DELAYMS(100)
portc = %00000000
//88888888888888888888888888888888888888 ROUTINES 8 & 9 are to finish out back end of letters
portc = Anodes_data(1) '8
portb = Cathodes_Data(7)
DELAYMS(10)
portc = Anodes_data(2)
portb = Cathodes_Data(6)
DELAYMS(10)
portc = Anodes_data(3)
portb = Cathodes_Data(5)
DELAYMS(10)
portc = Anodes_data(4)
portb = Cathodes_Data(4)
DELAYMS(10)
portc = Anodes_data(5)
portb = Cathodes_Data(3)
DELAYMS(10)
portc = Anodes_data(6)
portb = Cathodes_Data(2)
DELAYMS(1)
portc = Anodes_data(7)
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(8)
portb = Cathodes_Data(0)
DELAYMS(100)
portc = %00000000
//9999999999999999999999999999999999999
portc = Anodes_data(2) '0
portb = Cathodes_Data(7)
DELAYMS(10)
portc = Anodes_data(3) '0
portb = Cathodes_Data(6)
DELAYMS(10)
portc = Anodes_data(4) '0
portb = Cathodes_Data(5)
DELAYMS(10)
portc = Anodes_data(5) '0
portb = Cathodes_Data(4)
DELAYMS(10)
portc = Anodes_data(6) '0
portb = Cathodes_Data(3)
DELAYMS(10)
portc = Anodes_data(7) '0
portb = Cathodes_Data(2)
DELAYMS(1)
portc = Anodes_data(8) '0
portb = Cathodes_Data(1)
DELAYMS(10)
portc = Anodes_data(8) '0
portb = Cathodes_Data(0)
DELAYMS(100)
portc = %00000000 ' eliminate ghosting
NEXT
WEND // Loop back to the while loop as long as we havent finished.