Problem with using the LCD display as a debug output terminal

Hello!
I am using this code sequence for confirming that the original TI calculator to BS2 will send things to an LCD display. (One of the firm's serial enabled two line displays.)
' {$STAMP BS2}
' {$PBASIC 2.5}

serData  VAR  Byte
T2400    CON  396
T300     CON 3313
T600     CON 1646
T1200    CON 813

' -----[ I/O Definitions ]-------------------------------------------------

TX              PIN 12             ' serial output to LCD


' -----[ Constants ]-------------------------------------------------------

LcdBkSpc        CON     $08             ' move cursor left
LcdRt           CON     $09             ' move cursor right
LcdLF           CON     $0A             ' move cursor down 1 line
LcdCls          CON     $0C             ' clear LCD (use PAUSE 5 after)
LcdCR           CON     $0D             ' move pos 0 of next line
LcdBLon         CON     $11             ' backlight on
LcdBLoff        CON     $12             ' backlight off
LcdOff          CON     $15             ' LCD off
LcdOn1          CON     $16             ' LCD on; cursor off, blink off
LcdOn2          CON     $17             ' LCD on; cursor off, blink on
LcdOn3          CON     $18             ' LCD on; cursor on, blink off
LcdOn4          CON     $19             ' LCD on; cursor on, blink on
LcdLine1        CON     $80             ' move to line 1, column 0
LcdLine2        CON     $94             ' move to line 2, column 0

Reset:
  HIGH TX                               ' setup serial output pin
  PAUSE 100                             ' allow LCD to initialize
Main:
PAUSE 250
'DEBUG DEC serData, CR
SERIN 15,T2400,[serData]
SEROUT TX,T2400,[serData]
'SEROUT TX,T2400, [LcdRt]
SEROUT TX,T2400,[HEX serData, CR]
'DEBUG DEC serData, CR
serData = serData + 1
'DEBUG DEC serData, CR
SEROUT 15,T2400,[serData]
SEROUT TX,T2400, [DEC serData, CR]
PAUSE 750
'SEROUT 14,T2400, [serData]
SEROUT TX,T2400,[HEX serData, CR]
PAUSE 750
'DEBUG DEC serData, CR
GOTO Main

It runs okay, but during the duration of pressing the enter button on the calculator I can see the numbers scrolling on the display. But, ah, the numbers aren't clearing the full width of the line. It seems to be overlaying the new number on top of the old. I tried using a clear display command after extending the second pause command from 750 to 7500 instead, but it just did not seem to work.
I mean this is what the pause command says it does from the help:
PAUSE
Syntax: PAUSE Duration

Function
Pause the program (do nothing) for the specified Duration. 

Duration is a variable/constant/expression* (0 - 65535) that specifies the duration of the pause. The unit of time for Duration is one millisecond. 

However I believe I am missing the obvious. (And he's not working here today.)

Comments

  • Buck,

    Sending a CR to the LCD will reposition the cursor to the next line, or if it's on the bottom line, back up to the top line. The LCD doesn't have vertical scrolling, so if that's what you want, you will have to re-write the first line with whatever is on the second line before you write to the second line.
    Sapphire
  • Sapphire wrote: »
    Buck,

    Sending a CR to the LCD will reposition the cursor to the next line, or if it's on the bottom line, back up to the top line. The LCD doesn't have vertical scrolling, so if that's what you want, you will have to re-write the first line with whatever is on the second line before you write to the second line.

    So I just send a regular carriage return to the display it should promptly continue? Remember this is one of this members devices and they are not like this fellow and his relatives The first is a 2X16 display, and the second one is a 4X20 display.

    This is where it gets baroque, the idea of embedding a carriage return after each sent to the display, is not presently available for the Stamp 1, so the display does get filled up. Here the display is being used as debug terminal would.

    It happens that I first ran the original idea behind the code on a Stamp 1, that is when the group was putting up with Yahoo, an individual mentioned he had both a TI83Plus calculator and a BS2 and was interested in connecting them together. A chap whose business model in extending the functionality of the calculator who was monitoring our discussions responded, and described the code he'd written, it is still able from his site.

    At the time I only the Stamp 1, one our group, (Hello Jon!), translated the Stamp 2 code into a form that the Stamp 1 would understand and I was off and running. I still use it to confirm that a Stamp 1 that I'd received works.

    However, at the moment I'm trying to discern an easy application method for the whole business. And it got a rousing reception at my LUG's hack night last night.
  • Buck,

    Looking at your code I notice that you print the incoming value (in decimal I assume) and then print the HEX value followed by a CR.
    After you increment the value and sent it back you print both the decimal and hex values, each followed by a CR.

    You might want to just make line 1 of the LCD for the incoming value and the use line 2 for the outgoing value.
    You could also print IN: and OUT: at the start of each line and then DEC= and HEX= before each value to make it easy to understand.
    Making the value printing into a subroutine will save space as the code repeats.
Sign In or Register to comment.