Passing DAT Symbols
coryco2
Posts: 107
I cobbled together this method for displaying 16 bytes in hex on a 16x2 LCD (8 digit pairs on each row):
Which works, but I'd like to alter it to be able to pass DataSymbol from another method, like this:
It doesn't trigger any errors, but I just get junk data on the display. I am guessing I am making a mistake in utilizing the hex-conversion code (borrowed from another object)? Can anyone see what I am doing wrong?
PUB DisplayTwoLinesHex | bytecounter, displayposition, value, blubb bytecounter:=0 displayposition:=$00 ' beginning of top row REPEAT UNTIL bytecounter==8 LCD.exec( LCD#CMD_INSTR, 000000 + displayposition) value:=DataSymbol[bytecounter] 'hex display value <<= (8 - 2) << 2 repeat blubb from 0 to 1 byte[@hextext+blubb]:=lookupz((value <-= 4) & $F : "0".."9", "A".."F") LCD.exec( LCD#CMD_PRINT, @hextext) bytecounter++ displayposition:= displayposition +2 bytecounter:=8 displayposition:=$40 ' beginning of bottom row REPEAT UNTIL bytecounter==16 LCD.exec( LCD#CMD_INSTR, 000000 + displayposition) value:=DataSymbol[bytecounter] 'hex display value <<= (8 - 2) << 2 repeat blubb from 0 to 1 byte[@hextext+blubb]:=lookupz((value <-= 4) & $F : "0".."9", "A".."F") LCD.exec( LCD#CMD_PRINT, @hextext) bytecounter++ displayposition:= displayposition +2 DAT hextext byte "00000000",0,0,0,0 DataSymbol byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Which works, but I'd like to alter it to be able to pass DataSymbol from another method, like this:
PUB SomeOtherMethod DisplayTwoLinesHex(@Symbol2Pass) PUB DisplayTwoLinesHex(passingSymbol) | bytecounter, displayposition, value, blubb bytecounter:=0 displayposition:=$00 REPEAT UNTIL bytecounter==8 LCD.exec( LCD#CMD_INSTR, 000000 + displayposition) value:=passingSymbol[bytecounter] 'hex display value <<= (8 - 2) << 2 repeat blubb from 0 to 1 byte[@hextext+blubb]:=lookupz((value <-= 4) & $F : "0".."9", "A".."F") LCD.exec( LCD#CMD_PRINT, @hextext) bytecounter++ displayposition:= displayposition +2 bytecounter:=8 displayposition:=$40 REPEAT UNTIL bytecounter==16 LCD.exec( LCD#CMD_INSTR, 000000 + displayposition) value:=passingSymbol[bytecounter] 'hex display value <<= (8 - 2) << 2 repeat blubb from 0 to 1 byte[@hextext+blubb]:=lookupz((value <-= 4) & $F : "0".."9", "A".."F") LCD.exec( LCD#CMD_PRINT, @hextext) bytecounter++ displayposition:= displayposition +2 DAT hextext byte "00000000",0,0,0,0 Symbol2Pass byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
It doesn't trigger any errors, but I just get junk data on the display. I am guessing I am making a mistake in utilizing the hex-conversion code (borrowed from another object)? Can anyone see what I am doing wrong?
Comments
Remember symbol2Pass holds an address and would be better named "address2Pass".
Thanks again for the help.
You said it, not me.
BTW I still make this same mistake time to time.
In my recent massive multi-use modular demo I have a swarm of string functions and found it advantageous to call the region of memory holding a string BUFzzzz and variables that hold pointers to those buffers PTRzzzz. Really helps keep the confusion down because it's almost always @BUF and never @PTR..