Shop OBEX P1 Docs P2 Docs Learn Events
LCD Problem. Drawing dots on a SGX-120L — Parallax Forums

LCD Problem. Drawing dots on a SGX-120L

neotericneoteric Posts: 144
edited 2006-02-25 01:52 in BASIC Stamp
Hope I am not wearing out my welcome.· Have some free time this week, so working on a few projects.
I am continuing to experiment with my Tiny Touch Pad.· Now I want to draw on it and have the dots show on my SGX-120L.

My code looks right to me, and the SGX-120L part should work. (hehe)· Could someone look at it for me.· I really appreciate it.
SGX-120L.· I have read some other posts, and suspect I am not sending the correct information in the ESC P line?

Thanks, I really appreciate guidance on this. (note to Jon:· Notice I am finally using your template [noparse]:)[/noparse])
'   {$STAMP BS2p}
'   {$PBASIC 2.5}
' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
RX              PIN     0       ' input device = Tiny Touch Pad
LCD             PIN     4        'LCD
' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T1200       CON     813
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    TMidi       CON     12
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T1200       CON     2063
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    TMidi       CON     60
    T38K4       CON     45
  #CASE BS2PX
    T1200       CON     3313
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
    TMidi       CON     108
    T38K4       CON     84
#ENDSELECT
SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000
Baud            CON     T9600
clrLCD          CON   12                 ' Clear entire LCD screen.
posCmd          CON   16                 ' Position cursor.
ESC             CON   27                 ' Escape code for graphics instructions.
ibaud           CON T9600+Inverted       ' 9600bps/inv. baud for LCD
LCDLghtOn       CON     14
' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
whatsit VAR Byte(5)
x VAR Word
y VAR Word
newx VAR Word
newy VAR Word
divx VAR Word
divy VAR Word
loopit VAR Word
finx VAR Byte
finy VAR Byte
'-----------[noparse][[/noparse]MAIN}---------------------------
Main:
PAUSE  10000                     'let lcd power up
SEROUT lcd,ibaud,[noparse][[/noparse]clrLCD]        ' Clear screen.
DEBUG "Begin"                    ' to pc debug screen
SEROUT lcd,iBaud,[noparse][[/noparse]LCDlghtOn]     'works
SEROUT lcd,ibaud,[noparse][[/noparse]"hello"]       'works, but sometime inverted
DO
SERIN RX, baud,[noparse][[/noparse]STR whatsit\5]          ''
x = whatsit(2)<< 7 + whatsit(1)-115     ''  Reads X,Y from input device
y = whatsit(4)<< 7 + whatsit(3)-90      ''
IF whatsit(0) = 137  THEN               ''
'DEBUG "x = ",DEC x,",y=",DEC y,CR      ''
newx=119*x/1650                         ''   Converts to <120
newy=31*y/3850                          ''   Converts to <32
finx=newx                               ''   Stores as Byte
finy=newy                               ''   Stores as Byte
DEBUG DEC x," - ", DEC y,"   ",DEC finx,"    ", DEC finy,CR  'View results on PC Screen  Works'
[b]SEROUT LCD,ibaud,[noparse][[/noparse]ESC,"P",finx,finy]    ''' draw point   DRAWS GARBAGE?????[/b]
ENDIF
LOOP
END

Post Edited (neoteric) : 2/23/2006 9:13:15 PM GMT

Comments

  • neotericneoteric Posts: 144
    edited 2006-02-24 15:33
    I am just wondering about the one line in bold...
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-24 15:34
    Without knowing the display or having one to try out it would be hard to figure out why one specific line isn't doing what it's supposed to do.· You might want to review the data sheet to verify that command.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • neotericneoteric Posts: 144
    edited 2006-02-24 17:02
    Chris, this was purchased from Parallax. http://www.parallax.com/detail.asp?product_id=27936.· I guess I should have mentioned that.· The Seetron site shows it as an SGX-120L. (I always do my research before I ask on the forum.)

    Anyway, I figured it out from the docs.· I misunderstood it in thier sample code.
    Thier doc on thier site·says "Numbers can be expressed either as ASCII text (e.g. "123") followed by a throwaway character, or as single-byte shortcuts. Shortcuts are the one-byte sum of the number to be sent, plus 64. Numbers up to 191 can be sent this way to increase serial throughput. See the user manual for examples."· To plot a point at x,y·- ESC P X,Y.·
    Apparently I need to add 64.· So the code would read:
    newx=119*x/1650                         ''   Converts to <120
    newy=31*y/3850                          ''   Converts to <32
    finx=newx[b] +64[/b]                              ''   Stores as Byte
    finy=newy [b]+64[/b]                            ''   Stores as Byte
    DEBUG DEC x," - ", DEC y,"   ",DEC finx,"    ", DEC finy,CR  'View results on PC Screen  Works'
    [b]SEROUT LCD,ibaud,[noparse][[/noparse]ESC,"P",finx,finy]    ''' draw point   ?????[/b]
    

    Thanks.· Sometimes these docs are a little difficult for a beginner.· Like the phrase "followed by a throwaway character."· What the heck is a throwaway character?· Sometimes a newbie has to read a line from the doc, do a google search.· Read the next line, do a google search.· Its·very easy to miss something, or get confused.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-25 01:52
    I didn't get your message before I left the office today.· I will have to try one Monday if you're still having problems.· Or I might be able to get a hold of one tomorrow.· That display is not one I had/used before.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.