Shop OBEX P1 Docs P2 Docs Learn Events
Passing DAT Symbols — Parallax Forums

Passing DAT Symbols

coryco2coryco2 Posts: 107
edited 2013-07-24 17:30 in Propeller 1
I cobbled together this method for displaying 16 bytes in hex on a 16x2 LCD (8 digit pairs on each row):
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

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-23 13:55
    I haven't looked at it all but you need "byte[symbol2Pass][bytecounter]" instead of "symbol2Pass[bytecounter]".

    Remember symbol2Pass holds an address and would be better named "address2Pass".
  • coryco2coryco2 Posts: 107
    edited 2013-07-23 14:03
    Ah, yes. Seems I made that same mistake a few days ago... :tongue:

    Thanks again for the help.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-23 14:05
    coryco2 wrote: »
    Ah, yes. Seems I made that same mistake a few days ago... :tongue:

    Thanks again for the help.

    You said it, not me. :smile:

    BTW I still make this same mistake time to time.
  • localrogerlocalroger Posts: 3,451
    edited 2013-07-24 17:30
    Duane Degn wrote: »
    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..
Sign In or Register to comment.