Displaying Hex with BenkyLCDdriver
coryco2
Posts: 107
Hello,
I am playing with the excellent BenkyLCDdriver, and am trying to figure out how to use it to display hex values for variables. It has a simple enough to use printDec method in its demo for displaying decimal values:
I see there is also a method for doing something with hex:
But that doesn't print the hex values to the display. I tried to adapt it, but I'm feeling a bit lost in the weeds. Any suggestions would be greatly appreciated.
I am playing with the excellent BenkyLCDdriver, and am trying to figure out how to use it to display hex values for variables. It has a simple enough to use printDec method in its demo for displaying decimal values:
PUB printDec( val ) | i i:=10 if val>0 repeat while val<>0 i-- num[i]:="0"+val//10 val:=val/10 else LCD.exec( LCD#CMD_WRITE, "0" ) LCD.exec( LCD#CMD_PRINT, @num+i ) dat num byte 0[11]
I see there is also a method for doing something with hex:
PUB hex(value, digits) | blubb value <<= (8 - digits) << 2 repeat blubb from 0 to digits-1 byte[@text3+blubb]:=lookupz((value <-= 4) & $F : "0".."9", "A".."F")
But that doesn't print the hex values to the display. I tried to adapt it, but I'm feeling a bit lost in the weeds. Any suggestions would be greatly appreciated.
Comments