Shop OBEX P1 Docs P2 Docs Learn Events
Displaying Hex with BenkyLCDdriver — Parallax Forums

Displaying Hex with BenkyLCDdriver

coryco2coryco2 Posts: 107
edited 2013-07-03 18:34 in Propeller 1
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:
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

  • coryco2coryco2 Posts: 107
    edited 2013-07-02 14:09
    Oops...should have looked more closely: there's an example in the code :lol:
        ' this part prints the hexadecimal number
        repeat 100
          waitcnt(cnt+clkfreq/20)
          LCD.exec( LCD#CMD_INSTR, ( 000000 + $55 ) )
          LCD.exec( LCD#CMD_PRINT, @text3 )
          hex( counter++, 8 )
    
    
    
  • MagIO2MagIO2 Posts: 2,243
    edited 2013-07-03 12:39
    Nice to hear that someone is using my driver!
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-07-03 18:34
    Kye has done a nice set of spin conversion routines ASCII_StringEngine.spin. I think it is in the Obex. Else look for the KyeDos3.
Sign In or Register to comment.