Something like this?
Code:' 001110 001110 001110 001110 FullDisp VAR LONG FullDisp.31 = 0 FullDisp.30 = 0 FullDisp.29 = 1 FullDisp.28 = 1 FullDisp.27 = 1 FullDisp.26 = 0 FullDisp.25 = 0 ... ... ... ... ... ...
Something like this?
Code:' 001110 001110 001110 001110 FullDisp VAR LONG FullDisp.31 = 0 FullDisp.30 = 0 FullDisp.29 = 1 FullDisp.28 = 1 FullDisp.27 = 1 FullDisp.26 = 0 FullDisp.25 = 0 ... ... ... ... ... ...
Yes, but have no idea if can use another variable instead of 31 and other digits.
Like displayvar.X=Y
I suspect this is what you want:
But I also suspect we've covered this before so instead of me trying to repeat what's already been covered in detail I just leave it all to Melanie :-)Code:displayvar.0[X]=Y
http://www.picbasic.co.uk/forum/showthread.php?t=544
So it should look like this, right? (have no access to PBP at this moment).
Code:SCREEN32 VAR BIT[32] 'MAIN VARIABLE LINE1=%10101 'VARIABLE WITH BIT DATA FOR X=0 TO 4 'READ BITS SCREEN32[X+1]=LINE1.0(X) 'WRITE INTO ARRAY NEXT
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
Last edited by CuriousOne; - 15th December 2020 at 21:44.
I decided to return to this code, and have some advancement, but having issues into reading bits from array into an variable.
I have a SCREEN[32] bit array, which should be read into 4 consecutive variables - SEGA, SEGB, SEGC, SEGD.
I know how to access individual bits within variable, but complete byte?
If I understand correctly, the code should look like this
Is this correct?Code:FOR X=0 to 7 SEGA.0(X)=SCREEN[X] SEGB.0(8+X)=SCREEN[X] SEGC.0(16+X)=SCREEN[16+X] SEGD.0(24+X)=SCREEN[24+X] NEXT
Houston, we're having a problem!
Below is the code which works, but it works only if bits in array are aligned to bytes. If I want to shift them to make them less spaced (characters used have 4 pixel width, +1 pixel for spacing), image becomes garbled and shifted in wrong direction, as shown on attached pictures. What I'm doing wrong?
Code:DATA $60,$90,$90,$90,$90,$90,$90,$60 '0 'digits, left justified 4 bits used in each 8 bits DATA $20,$60,$A0,$20,$20,$20,$20,$F0 '1 DATA $60,$90,$90,$10,$60,$80,$80,$F0 '2 DATA $60,$90,$10,$60,$10,$90,$90,$60 '3 DATA $90,$90,$90,$70,$10,$10,$10,$10 '4 DATA $F0,$80,$80,$E0,$10,$90,$90,$60 '5 DATA $60,$90,$80,$E0,$90,$90,$90,$60 '6 DATA $F0,$10,$10,$20,$20,$40,$40,$40 '7 DATA $60,$90,$90,$60,$90,$90,$90,$60 '8 DATA $60,$90,$90,$70,$10,$90,$90,$60 '9 INVAR=1234 FOR I=0 TO 7 'Read digit data from apropriate positions in EEPROM into own CHAR variables READ 6+I+8*INVAR DIG 3, CHAR1 READ 6+I+8*INVAR DIG 2, CHAR2 READ 6+I+8*INVAR DIG 1, CHAR3 READ 6+I+8*INVAR DIG 0, CHAR4 FOR Y=0 TO 7 'write CHAR DATA INTO ARRAY WITH OFFSET SCREEN32[Y]=CHAR1.0(Y) SCREEN32[Y+8]=CHAR2.0(Y) 'OFSETS ARE SET HERE SCREEN32[Y+16]=CHAR3.0(Y) SCREEN32[Y+24]=CHAR4.0(Y) NEXT 'read array data into 8 bit variables FOR C=0 to 7 SEGA.0(C)=SCREEN32[C] SEGB.0(C)=SCREEN32[8+C] SEGC.0(C)=SCREEN32[16+C] SEGD.0(C)=SCREEN32[24+C] NEXT 'WRITE ARRAY DATA INTO DISPLAY AND GO TO NEXT LINE LOW LOAD shiftout datapin,clockpin,1,[1+I, SEGA] shiftout datapin,clockpin,1,[1+I, SEGB] shiftout datapin,clockpin,1,[1+I, SEGC] shiftout datapin,clockpin,1,[1+I, SEGD] HIGH LOAD NEXT END
![]()
Bookmarks