So here it is, almost finished (not tested in PBP yet, written in notepad).
Digit data are stored as 4 bit width sequences, each char compromising of 4x8 pixels (width & height). They are stored by pairs in eeprom (1st address holds bitmaps for 1 & 2, 2nd address - for 3 & 4 and so on).
This routine should display value of 4 digit CNTR variable on screen. It does that by reading 4 bit graphic data from eeprom, adding 1 space between pixels and assembling into 32 bit array, which later should be cut into 4 bytes and sent to MAX7219. For simplicity, code is shown for sending only 1 line. However, I'm stuck, how to read values from 32 bit array and convert them into bytes.
Code:
LINE VAR BIT[32] 'line of MAX7219 buffer
DBIT var byte 'digit bit eeprom address
DOFF var byte 'digit offset 0 for first, 4 for next
DSHF var byte 'Shift value for next digit data
CNTR var word 'Input variable
Y var byte 'Temporary digit variable
X var byte 'digit scan variable
Z var byte 'digit row variable
BT var bit 'bit variable for font hold
' decoder routine
DECODER:
DSHF=0 'reset char shift variable
for x=0 to 3 'read all 4 digits
Y=CNTR DIG X 'EXTRACT VARIABLE DIGIT
IF Y=1 THEN DBIT=0: DOFF=0 'set the font offset
IF Y=2 THEN DBIT=0: DOFF=4
IF Y=3 THEN DBIT=8: DOFF=0
IF Y=4 THEN DBIT=8: DOFF=4
IF Y=5 THEN DBIT=16: DOFF=0
IF Y=6 THEN DBIT=16: DOFF=4
IF Y=7 THEN DBIT=24: DOFF=0
IF Y=8 THEN DBIT=24: DOFF=4
IF Y=9 THEN DBIT=32: DOFF=0
IF Y=0 THEN DBIT=32: DOFF=4
for Z=0 to 4 'read font data and write into rows
READ DBIT+DOFF+Z,BT 'read bit from eeprom
LINE[Z+DSHF]=BT 'write into array
next
DSHF=DSHF+5 'increment char shift variable
'now here should extract bits from array and convert into bytes
'to send to MAX7219, but how?
next
Bookmarks