Shop OBEX P1 Docs P2 Docs Learn Events
Need DAT table help please — Parallax Forums

Need DAT table help please

Don MDon M Posts: 1,653
edited 2011-07-19 18:31 in Propeller 1
I am trying to make this dat table work for a custom character on a serial display. If the individual lines of bytes that are commented out are sent to the display, they work. I was trying to make a table to simulate the individual lines and be able to send it all at once. What am I doing wrong here?
CON

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  TX_PIN        = 8
  BAUD          = 19_200

                     
OBJ

  LCD           : "FullDuplexSerial.spin"


PUB Main

  LCD.start(TX_PIN, TX_PIN, %1000, 19_200)
  waitcnt(clkfreq / 100 + cnt)                ' Pause for FullDuplexSerial.spin to initialize


  LCD.tx(250)                                 ' Define custom character 2 
  LCD.tx(@up_arrow)
'  LCD.str(string(250, @up_arrow))
                                  
                                              ' Now send the eight data bytes
{  LCD.tx(%00100)                              
  LCD.tx(%01110)                             
  LCD.tx(%11111)                              
  LCD.tx(%00100)                              
  LCD.tx(%00100)                              
  LCD.tx(%00100)                              
  LCD.tx(%00100)                              
  LCD.tx(%00100)}                             
  LCD.tx(2)                                   ' Display the new custom character 2

{  LCD.tx(251)                                 ' Define custom character 3
                                              
  LCD.tx(%00100)                              
  LCD.tx(%00100)                              
  LCD.tx(%00100)                              
  LCD.tx(%00100)                                                 
  LCD.tx(%00100)                              
  LCD.tx(%11111)                             
  LCD.tx(%01110)                              
  LCD.tx(%00100) }                           
'  LCD.tx(3)

dat

up_arrow  byte %00100
          byte %01110
          byte %11111
          byte %00100
          byte %00100
          byte %00100
          byte %00100
          byte %00000

dn_arrow  byte %00100
          byte %00100
          byte %00100
          byte %00100
          byte %11111
          byte %01110
          byte %00100
          byte %00000 

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-07-19 18:29
      LCD.tx(250)                                 ' Define custom character 2 
      [COLOR="blue"]LCD.tx(@up_arrow)[/COLOR]
    '  LCD.str(string(250, @up_arrow))
    
    dat
    
    up_arrow  byte %00100
              byte %01110
              byte %11111
              byte %00100
              byte %00100
              byte %00100
              byte %00100
              [COLOR="red"]byte %00000[/COLOR]
    
    Sending an address with tx isn't going to work (with special exceptions) simply because this method only transfers the LSB of its parameter. The str approach is better but would run into trouble if your character definition contains 0 bytes (i.e. it stops at the first one of those).

    Is the definition data always of a fixed size (i.e. 8 bytes)? What about something like this then:
    LCD.tx(prefix)                ' 250
      repeat n from 0 to 7
        LCD.tx(up_arrow[n])
      LCD.tx(suffix)                ' 2
    
    This could easily be wrapped up in a method taking prefix, suffix and address as parameters, e.g.
    PRI define(prefix, suffix, address) : n
    
      LCD.tx(prefix)
      repeat n from 0 to 7
        LCD.tx(byte[address][n])
      LCD.tx(suffix)
    
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-19 18:31
    This is what I'd do:
    pub def_cchar(n, pntr)
    
      lcd.tx(248 + n)
      repeat 8
        lcd.tx(byte[pntr++])
    

    You pass the custom character # and the address of the DAT table holding the definition bytes. You can't use .str() as this is terminated by 0 in the stream; this could cause too few bytes to be sent or too many (if no blank line in character).
Sign In or Register to comment.