Shop OBEX P1 Docs P2 Docs Learn Events
Sparkfun serial LCD backpack code — Parallax Forums

Sparkfun serial LCD backpack code

Buck RogersBuck Rogers Posts: 2,178
edited 2010-10-13 17:04 in BASIC Stamp
Hello!
Ron C, I have a question about your code for the stamp2. It reads as follows:
' {$STAMP BS2}
' {$PBASIC 2.5}
lcd_cmd     CON    $FE   'command prefix
lcd_cmd2    CON    $7C   'special command prefix
clrLCD      CON    $01   'Clear entire LCD screen
displayOff  CON    $08   'Display off
displayOn   CON    $0C   'Display ON
noCurs      CON    $0C   'Make cursor invisible
ulCurs      CON    $0E   'Show underline cursor
blkCurs     CON    $0D   'Show blinking block cursor
curpos      CON    $80   'set cursor  + position  (row 1=0 TO 15, row 2 = 64 TO 79)
scrollRight CON    $1C
scrollLeft  CON    $18
curRight    CON    $14
curLeft     CON    $10
#SELECT $STAMP                          ' Select Baud constants
  #CASE BS2, BS2E, BS2PE
    T1200       CON     813
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
  #CASE BS2SX, BS2P
    T1200       CON     2063
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
  #CASE BS2PX
    T1200       CON     3313
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
#ENDSELECT
Inverted        CON     $4000           'Value for inverted serial format
Baud            CON     T9600      '+ Inverted 8,N,1 inverted
LCD CON 4
i VAR Byte
SEROUT LCD,Baud,[lcd_cmd, displayOn]
SEROUT LCD,Baud,[lcd_cmd, clrLCD]
SEROUT lcd,Baud,[lcd_cmd, curpos+6, "AAA", lcd_cmd, curpos+68, "BBBBB"]
SEROUT lcd,Baud,[lcd_cmd2, $0A]   'ctrl-j   Save Splash screen
PAUSE 2000
SEROUT LCD,Baud,[lcd_cmd, clrLCD, noCurs]
SEROUT LCD,Baud,[lcd_cmd, curpos + 0,"Test line 1"]
PAUSE 500
SEROUT LCD,Baud,[lcd_cmd, curpos + 64,"Test line 2"]
PAUSE 1000
FOR i = 0 TO 5
 SEROUT LCD,Baud,[lcd_cmd, scrollRight]
 PAUSE 500
NEXT
FOR i = 0 TO 5
 SEROUT LCD,Baud,[lcd_cmd, scrollLeft]
 PAUSE 500
NEXT
'Backlight values: 128-157
SEROUT LCD,Baud,[lcd_cmd2, $8C]   '40% backlight
PAUSE 3000
SEROUT LCD,Baud,[lcd_cmd2, $96]   '73% backlight
PAUSE 3000
SEROUT LCD,Baud,[lcd_cmd2, $9D]   '100% backlight
PAUSE 1000
SEROUT LCD,Baud,[lcd_cmd2, $80]   'backlight off
SEROUT LCD,Baud,[lcd_cmd, displayOff]
END ' Finished.

Is it my understanding that the majority of those entries are to be used for one specific purpose, that of confirming that the device can be seen by the selected BS2? (and of course the chosen display):confused:

Reason being is that I now want to move towards applying the display and backpack combo to respond to different logic applications.

Ideally, I can now stick my logic in between the stamp and the two devices, but I would like your opinion.

The code block that describes initializing the backpack seems to be an excellent idea. Yet every time I've used it, all I would do is just connect it to my logic, and then from there, connect the "actuator" (in this case just an action) to the logic--Which is where the stamp comes in.:idea::smilewinkgrin:

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-10-13 16:38
    I'm afraid I don't understand your question.

    The Sparkfun serial LCDs and backback are RS232 devices that allow a BASIC STAMP (or other microcontroller or device) to send data to the LCD using RS232 protocol (SEROUT on the Basic Stamp).

    The constants merely make it easier to write program code instructing the LCD what to do e.g. Clear the screen, move the cursor, etc.

    Most commands need to be proceeded by the 0xFE command prefix.
    For example to clear the display your BS2 instruction would be

    SEROUT LCD,Baud,[lcd_cmd, clrLCD]

    where LCD is the BS2 pin number the display is wired to, and BAUD is the SEROUT mode (e.g. 84 for 9600 bps - see BS2 serout instruction in manual).

    You can select the cursor type and position the cursor before sending text to the display.

    The datasheet gives you all the details about the control codes

    http://www.sparkfun.com/datasheets/LCD/SerLCD_V2_5.PDF
  • Buck RogersBuck Rogers Posts: 2,178
    edited 2010-10-13 17:04
    I'm afraid I don't understand your question.

    The Sparkfun serial LCDs and backback are RS232 devices that allow a BASIC STAMP (or other microcontroller or device) to send data to the LCD using RS232 protocol (SEROUT on the Basic Stamp).

    The constants merely make it easier to write program code instructing the LCD what to do e.g. Clear the screen, move the cursor, etc.

    Most commands need to be proceeded by the 0xFE command prefix.
    For example to clear the display your BS2 instruction would be

    SEROUT LCD,Baud,[lcd_cmd, clrLCD]

    where LCD is the BS2 pin number the display is wired to, and BAUD is the SEROUT mode (e.g. 84 for 9600 bps - see BS2 serout instruction in manual).

    You can select the cursor type and position the cursor before sending text to the display.

    The datasheet gives you all the details about the control codes

    http://www.sparkfun.com/datasheets/LCD/SerLCD_V2_5.PDF

    Hello!
    Actually Ron, I believe most of it flew past you, but you did indeed get the meaning behind it. :roll: My big problem is exactly what you've outlined. I believe I can translate those ideas into everything else I need to do.

    Most of the problem filters down to simply parts selection.
Sign In or Register to comment.