Shop OBEX P1 Docs P2 Docs Learn Events
Parallax 120 x 32 Graphic LCD, example program for BS2 — Parallax Forums

Parallax 120 x 32 Graphic LCD, example program for BS2

Kyle WKyle W Posts: 2
edited 2007-11-12 13:44 in BASIC Stamp
Hi,
I know I had an example program at one time, but I can't seem to find it now. Could someone please post an example of writing hello world and some variable to the 120 x 32 Graphic LCD? Item: parallax.com/Store/Accessories/Displays/tabid/159/CategoryID/34/List/0/Level/a/ProductID/48/Default.aspx?SortField=ProductName%2cProductName
Thanks,
Kyle

Comments

  • Kyle WKyle W Posts: 2
    edited 2007-11-12 13:36
    I have answered my own question. I'm posting this snippet of BASIC for anyone else who might be working on something similar. Note that I am using a BS2 with the above mentioned graphic display and two Memsic dual axis accelerometers.
    BS2 said...
    ' {$STAMP BS2}

    '
    [noparse][[/noparse] I/O Definitions ]

    'XinA PIN 8 ' X input from Memsic 2125
    'YinA PIN 9 ' Y input from Memsic 2125

    'XinB PIN 14 ' X input from Memsic 2125
    'YinB PIN 15 ' Y input from Memsic 2125

    '
    [noparse][[/noparse] Constants ]

    CLR CON 12 ' Clear entire LCD screen.
    POSHOME CON 1
    CTLC CON 3 ' Control-C: control character to end right-align.
    POS CON 16 ' Position cursor.
    LNF CON 10 ' linefeed
    RTALGN CON 18 ' Right-align.
    ESC CON 27 ' Escape code for graphics instructions.
    n9600 CON $4054 ' Baudmode for 9600 bps, inverted.
    XMAX CON 20 ' Max value for graph X coord.
    BIG CON 67 ' Shortcut for 3 (big font).
    SMALL CON 64 ' Shortcut for 0 (small font).
    BLACK CON 65 ' Shortcut for 1 (black ink)
    WHITE CON 64 ' Shortcut for 0 (white ink)
    DEGR CON 128 ' ASCII code for degree symbol added to font.

    LCD CON 7 'LCD conection

    ' Set scale factor for PULSIN

    '#SELECT $STAMP
    ' #CASE BS2, BS2E
    Scale CON $200 ' 2.0 us per unit
    ' #CASE BS2SX
    ' Scale CON $0CC ' 0.8 us per unit
    ' #CASE BS2P
    ' Scale CON $0C0 ' 0.75 us per unit
    ' #CASE BS2PE
    ' Scale CON $1E1 ' 1.88 us per unit
    '#ENDSELECT

    HiPulse CON 1 ' measure high-going pulse
    LoPulse CON 0

    '
    [noparse][[/noparse] Variables ]

    xRaw VAR Word ' pulse from Memsic 2125
    xmGA VAR Word ' g force (1000ths)
    xmGB VAR Word

    yRaw VAR Word
    ymGA VAR Word
    ymGB VAR Word

    '
    [noparse][[/noparse] Program Code ]

    Main:
    PAUSE 1000
    SEROUT LCD, n9600, [noparse][[/noparse]CLR,14]
    GOTO Loop

    Loop:
    GOSUB Read_Accel ' reads G-force and Tilt
    SEROUT LCD, n9600, [noparse][[/noparse]"xA: ", (xmGA.BIT15 * 13 + " "), DEC (ABS xmGA / 1000), ".", DEC3 (ABS xmGA), " g", 13, "yA: ", (ymGA.BIT15 * 13 + " "), DEC (ABS ymGA / 1000), ".", DEC3 (ABS ymGA), " g", 13, "xB: ", (xmGB.BIT15 * 13 + " "), DEC (ABS xmGB / 1000), ".", DEC3 (ABS xmGB), " g", 13, "yB: ", (ymGB.BIT15 * 13 + " "), DEC (ABS ymGB / 1000), ".", DEC3 (ABS ymGB), " g", 13]
    GOTO Loop
    'END


    '
    [noparse][[/noparse] Subroutines ]

    Read_Accel:
    PULSIN 8, HiPulse, xRaw ' read pulse output
    xRaw = xRaw */ Scale ' convert to uSecs
    xmGA = ((xRaw / 10) - 500) * 8 ' calc 1/1000 g
    PULSIN 9, HiPulse, yRaw
    yRaw = yRaw */ Scale
    ymGA = ((yRaw / 10) - 500) * 8
    PULSIN 14, HiPulse, xRaw ' read pulse output
    xRaw = xRaw */ Scale ' convert to uSecs
    xmGB = ((xRaw / 10) - 500) * 8 ' calc 1/1000 g
    PULSIN 15, HiPulse, yRaw
    yRaw = yRaw */ Scale
    ymGB = ((yRaw / 10) - 500) * 8
    RETURN
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-11-12 13:44
    Kyle W--

    I like your code!

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
Sign In or Register to comment.