scrolling letters as your Merry Christmas

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

scrolling letters as your Merry Christmas

Post by MrDEB » Fri Feb 28, 2014 8:25 am

Been hacking at this trying to get a full multiplexing and scrolling smoothly.
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.

   

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by brad » Sat Mar 01, 2014 9:06 pm

Having used LED matrix displays in probably most of my projects, I have had more than my share of experience with this type of thing and have actually changed the way I do things as the years go by.

Looking at your code you have a big waste of program memory by allocating 9bytes for each letter (whereas you only need up to 5, depending on your letter).

Here is a number table that I am using in my USB power meter project:

Code: Select all

Const NumberTable(30) As Byte = (%00011111,%00010001,%00011111,%00001001,%00011111,%00000001,%00010111,%00010101,%00011101,%00010001,%00010101,%00011111,%00011100,%00000100,%00011111,
%00011101,%00010101,%00010111,%00011111,%00010101,%00010111,%00010000,%00010000,%00011111,%00011111,%00010101,%00011111,%00011101,%00010101,%00011111)
And here is what the number table looks like as an image:
NumberSmaller.PNG
NumberSmaller.PNG (5.33 KiB) Viewed 26374 times

You can see the numbers in there but they are grouped in nice and tight (i.e. there are no spaces) which is perfectly fine because in your code if you wanted the number 0 you would grab the first three bytes of the array (i.e. 0, 1 and 2) if you wanted the number 1 you would grab the next three bytes (3, 4 and 5) and so on.

It does become a little more tricky for letters or characters that are not always the same width, for example the letter A might be four pixels wide, while the letter X might be five pixels wide. In this case you need to know how big the letter is going to be and also where in the array, that letter actually begins.

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Sat Mar 01, 2014 11:49 pm

YES my letters should be smakker as they are presently 8 x 8.
Now by reducing the size of the letters I reduce the number of bytes per letter and cram the letters together but trying to get it to scroll from right to left.
here is what I have been trying that should work but it doesn't.

Code: Select all

WHILE True()
      
    FOR index = 0 TO 7  ' anodes byte
      FOR x = 0 TO 7      ' anodes bit
          portc =T_Data(index).bits (x)  ' index changes the CONST array byte. The bits(x) turns each LED on /off in the byte that index has.
          portb =CAT_Data(x)         ' This scans the cathodes
          
       
          DELAYMS(500)        ' have it slowed down to SEE what is actually going on.
         
      NEXT
    NEXT   
    
       
       
WEND                  // Loop back to the while loop as long as we havent finished.

    
going to reduce letter size and cram together.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by brad » Sun Mar 02, 2014 8:25 am

Have you tried this on hardware yet? Because I can't see how it would work.

I am assuming that your LED anodes are connected to PORTC (i.e. 8 LED's for an 8-bit port), but in your code, you are only ever sending data to PORTC.0 (i.e. only one LED) you aren't actually sending any data to the remaining 7 LED's:

Code: Select all

portc =T_Data(index).bits (x)
You would be wanting your code to send out an entire byte to the port:

Code: Select all

portc =T_Data(index)
Also, if you want the text to scroll, you would want to have a buffer that you first store all of your letters into and then you send that data to the screen, rather than trying to get the data straight from the CONST arrays, to the screen.

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Mon Mar 03, 2014 10:27 pm

My first posted code works pretty good but feel it could be better.
As for hardware, yes it works as posted (will post a short video).
Going to try loading more bytes but not sure what or method so more research.
The code in my first post is what I wrote trying to implement suggestions.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by brad » Tue Mar 04, 2014 9:47 pm

What do you mean by trying to load more bytes?

Feel free to post a video to this forum topic once you have it uploaded :)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Thu Mar 06, 2014 10:54 pm

Going in hopefully the right direction by using the DICE GAME as an example but I am not using shift registers, just a pic.
Have what appears to be lines scrolling only, no letters. I tried slowing the whole ting down but no success yet. I am sure the issue is in loading the SENTENCE DATA into the display buffer then into the anodes. Some direction is needed as I interpreted the DICE GAME source code incorrectly.

Code: Select all

{
*****************************************************************************
*  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  ' data to send to matrix
DIM Data_Display AS BYTE        ' data that matrix displays
DIM Colum_start AS PORTB        ' cathodes
DIM Anode_Data AS PORTC        ' Anodes
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 b
          ' Display_Buffer(x) = Sentence_Data(x)
          ' Data_Display = Display_Buffer(x)          ' LOAD BUFFER WITH "Sentence_Data" CONST array
           Anode_Data = display_buffer(x)                              ' data bus
           Anode_Data.bits(7 - (x- Colum_start)) = 1  ' cycle the anodes 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 is Cathodes on portb
           Colum_start = 0
           END IF
        END IF
    END SUB
    
    FOR y = 0 TO 20
      Draw_Data()
      NEXT
    '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
for x = 0 to 96
      Display_Buffer(x) = Sentence_Data(x)
      next
    Draw_Data()
    
    Scroll_Text()
WEND

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Thu Mar 06, 2014 11:01 pm


MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Sat Mar 08, 2014 4:11 am

Changed the code around but don't think the CONST array data is loading?? Something with the DRAW_DATA

Code: Select all

{
*****************************************************************************
*  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_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 15               ' 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
    
   
    '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
Load_Buffer()
WHILE true
    
    Draw_Data()
     FOR y = 0 TO 20
      Draw_Data()
      NEXT
    Scroll_Text()
WEND





User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by brad » Sun Mar 09, 2014 9:04 pm

In projects like these I like to start basic and just make sure that my LED matrix is working correctly. Having said that, in your code above you have this:

Code: Select all

DIM Colum_start AS PORTB        ' cathodes
DIM Anode_Data AS PORTC        ' Anodes
so in that case I would be starting out by blanking the display (send logic 1's to the cathodes and 0's to the anodes). I would then do a simple loop to scan through each LED in the matrix and make sure they turn on and then off:

Code: Select all

Colum_start = %11111111
Anode_Data = %00000000
for index1 = 0 to 7
    Colum_start.index1 = 0
    for index2 = 0 to 7
        Anode_Data.index2 = 1
        delayms(200)
        Anode_Data.index2 = 0
    next
    Colum_start.index1 = 1
next

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Mon Mar 10, 2014 9:34 am

I have already checked that all the leds work as they should.
This morning (Sunday before going to church) it dawned on me that, using the SPB DICE code but with out using shift rtegisters, I realized that START_COLUM = START_COLUM + 7 is a pointer to the CONST bytes, not the cathodes.
Just got back from dinner to take a new outlook on the code.
Here is where I think the hang up is. I was referencing the wrong things. I need to change from START COLUM from cathodes to the bytes in the CONST array.

Code: Select all

 
SUB Draw_Data()
    
    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
          
      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
    
   
    '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 = 10
Colum_start = 0
Load_Buffer()
WHILE true
    
    Draw_Data()
     FOR y = 0 TO 20
      Draw_Data()
      NEXT
    Scroll_Text()
WEND


MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Tue Mar 11, 2014 6:21 am

After studying how you did your ELECTRONIC DICE it dawned on me on where I went astray.
Got this code written and tested. Scrolls pretty good but need to slow it down a little. I coded the upper case alphabet and all 26 letters work except need to reverse a few but that's another day. Open for improvements

Code: Select all

CONST Cathodes_Data(8) AS BYTE = (%11111110, %11111101, %11111011, %11110111, %11101111, %11011111, %10111111, %01111111)    

'CONST Data_array(2) AS BYTE = (%11111111, %00000000)
DIM x AS BYTE
DIM y AS BYTE
SetAllDigital                       // Make all Pins digital I/O's
TRISC = %00000000                   // Make PORTD all outputs
TRISB = %00000000   

 y = 0
WHILE true
 
FOR x = 0 TO 7
      portc = A_data(x + y)
      portb = Cathodes_Data(x)
      DELAYMS(10)
      portc = %00000000
      
      DELAYMS(1)
     NEXT 
     IF y +x <210 THEN
     y = y + 1
     ELSE
     y = 0
     DELAYMS(25)
     END IF
     
      WEND

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by brad » Wed Mar 12, 2014 10:44 pm

if it is going to fast you just need to put in a delay routine that still allows the screen to update, something like this:

Code: Select all

dim ScrollDelay as byte

ScrollDelay = 20

if ScrollDelay <> 0 then
    dec(ScrollDelay)
else
    ScrollDelay = 20
    <Now you would update the scrolling data info>
endif

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by MrDEB » Thu Mar 13, 2014 12:17 am

I tried several delays in different sections but?
Curious about <0>
Saw this in the dice game but ?
Your idea of all the CONST data in one array really helped. Going to try them connected together next.
In process of soldering a board for this project. Boy them 805 chips are tiny and made a mistake on the switch location and connection points but it is workable. Have already made changes on the PCB layout in DIPTRACE.
If you want I can send you the file as it uses a 20mm square LED matrix.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: scrolling letters as your Merry Christmas

Post by brad » Thu Mar 13, 2014 10:23 pm

MrDEB wrote:I tried several delays in different sections but?
Curious about <0>
Saw this in the dice game but ?
Your idea of all the CONST data in one array really helped. Going to try them connected together next.
In process of soldering a board for this project. Boy them 805 chips are tiny and made a mistake on the switch location and connection points but it is workable. Have already made changes on the PCB layout in DIPTRACE.
If you want I can send you the file as it uses a 20mm square LED matrix.
Do you mean that you are curious about <> 0?

That is just the way I have made delays over the years where it still allows the rest of the code to run. You load up your variable with a number (in this case 20) then it checks to see if this number is 0. If it is not, then it takes one away. It keeps doing this until eventually it is 0. When it is 0 - it will reset the variable back to 20 AND it will run the code to update the screen data.

If you instead put in a delay like this:

Code: Select all

delayMS(20)
Then your microcontroller will halt what is doing (including updating the LED matrix) until 20mS has elapsed, therefor you will get some ugly screen flicker happening :)

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 0 guests