Wow, yeah, that's some pretty ineffecient code - no offense.
* Try and never write the same snippet of code more than once, if more than a very simple command and it's needed more than a single time make it a subroutine. You have a VERY long piece of code copy/pasted twice (as far as I can see).
* Avoid using HIGH/LOW, set the TRIS registers to the correct value and write directly to the PORT register (or LAT register on 18F parts). Doing that single thing saves 540 words in your program.
* Instead of the IF/THEN thing for each bit just do C1 = LINE1[0+SVLA] etc.
Something like:
Went from 3161 to 775 words and that's just a first go.Code:' Variables etc as before but make sure to set TRIS registers properly! DRO=2 'time refresh set 'turn off display L1 = 1 L2 = 1 L3 = 1 L4 = 1 L5 = 1 L6 = 1 L7 = 1 C1 = 0 C2 = 0 C3 = 0 C4 = 0 C5 = 0 cikleri: FOR SVLA=0 TO 6 'scroll through the array GOSUB ScanIt PAUSE 5 NEXT 'ROTATE BACK FOR SVLA=6 TO 0 STEP -1 GOSUB ScanIt PAUSE 5 NEXT GOTO CIKLERI ScanIt: FOR TRIALI = 0 TO 29 'time to show individual char L1 = 0 'ENABLE LINE 1 C1 = LINE1[0+SVLA] C2 = LINE1[1+SVLA] C3 = line1[2+SVLA] C4 = line1[3+SVLA] C5 = line1[4+SVLA] PAUSE DRO L1 = 1 L2 = 0 'ENABLE LINE 2 C1 = LINE2[0+SVLA] C2 = LINE2[1+SVLA] C3 = line2[2+SVLA] C4 = line2[3+SVLA] C5 = line2[4+SVLA] PAUSE DRO L2 = 1 L3 = 0 'ENABLE LINE 3 C1 = LINE3[0+SVLA] C2 = LINE3[1+SVLA] C3 = line3[2+SVLA] C4 = line3[3+SVLA] C5 = line3[4+SVLA] PAUSE DRO L3 = 1 L4 = 0 'ENABLE LINE 4 C1 = LINE4[0+SVLA] C2 = LINE4[1+SVLA] C3 = line4[2+SVLA] C4 = line4[3+SVLA] C5 = line4[4+SVLA] PAUSE DRO L4 = 1 L5 = 0 'ENABLE LINE 5 C1 = LINE5[0+SVLA] C2 = LINE5[1+SVLA] C3 = line5[2+SVLA] C4 = line5[3+SVLA] C5 = line5[4+SVLA] PAUSE DRO L5 = 1 L6 = 0 'ENABLE LINE 6 C1 = LINE6[0+SVLA] C2 = LINE6[1+SVLA] C3 = line6[2+SVLA] C4 = line6[3+SVLA] C5 = line6[4+SVLA] PAUSE DRO L6 = 1 L7 = 0 'ENABLE LINE 7 C1 = LINE7[0+SVLA] C2 = LINE7[1+SVLA] C3 = line7[2+SVLA] C4 = line7[3+SVLA] C5 = line7[4+SVLA] PAUSE DRO L7 = 1 NEXT RETURN
I'm sure the rest can be handled with some array manipulation and indexing to reduce the size even further but I don't have time right now.
/Henrik.




Bookmarks