Shop OBEX P1 Docs P2 Docs Learn Events
BS2p + Graphic LCD 128x64 Simple Project — Parallax Forums

BS2p + Graphic LCD 128x64 Simple Project

OldSpringOldSpring Posts: 6
edited 2010-03-08 17:57 in Robotics
Hello, all;

This project uses BasicStamp 2P (also you can use PIC MCU) to interface with a GLCD Display and JP SerGLCD Module. Code used is standard PBasic 2.5, it should work on most BasicStamp chips.

Components:
1) Basic Stamp 2P
Manufactory: http://www.parallax.com
Datasheet: http://www.parallax.com/tabid/440/Default.aspx

2) Graphic LCD 128x64
Manufactory: http://www.circuit-ed.com/128x64-BLWH-TOUCHSCREEN-GLCD--P146C8.aspx
Datasheet: http://circuit-ed.com/uplds/GDM12864B.pdf

3) JP SerGLCD Module
Manufactory: http://www.jianpingusa.com/jpserglcd12864.asp
Datasheet: http://www.jianpingusa.com/datasheet/JPSerGLCDUserManual12864.pdf

4) Project video link:
http://www.youtube.com/watch?v=t4Fnp99DRNk
··
5) Projrct Code:
'========================================================= 
' File........OldSpring GLCD 128x64 Simple Project.BSP 
' Purpose.....BS2P + GLCD Display + Serial GLCD Module 
' Auther......OldSpring 
' Email.......oldsprings@yahoo.com 
' WebSite.....http://oldspring.110mb.com 
' Code........Mar 8, 2010 
'======================================================== 
' {$STAMP BS2p} 
' {$PBASIC 2.5} 
SOUT PIN 0 ' Serial output to Rx 
S_IN PIN 1 ' Serial input to Tx 
x VAR Byte 
x1 VAR Byte 
x2 VAR Byte 
y1 VAR Byte 
y2 VAR Byte 
idx VAR Byte 
#SELECT $STAMP 
#CASE BS2, BS2E, BS2PE 
T1200 CON 813 
T2400 CON 396 
T4800 CON 188 
T9600 CON 84 
T19K2 CON 32 
T38K4 CON 6 
#CASE BS2SX, BS2P 
T1200 CON 2063 
T2400 CON 1021 
T4800 CON 500 
T9600 CON 240 
T19K2 CON 110 
T38K4 CON 45 
#CASE BS2PX 
T1200 CON 3313 
T2400 CON 1646 
T480 CON 813 
T9600 CON 396 
T19K2 CON 188 
T38K4 CON 84 
#ENDSELECT 
Inverted CON $4000 
Baud CON T19K2 '+ Inverted 
'============================================================== 
' Main program 
'============================================================== 
Main: 
PAUSE 1000 
GOSUB CleanScreen 
idx = 1 'Set font #1 
GOSUB SetFont 
GOSUB text0 
GOSUB SetFont 
GOSUB text1 
idx = 3 'Set font #3 
GOSUB SetFont 
GOSUB oldspring 
x1 = 0 
y1 = 0 
x2 = 127 
y2 = 63 
GOSUB Draw_Round_Rectang 
x1 = 1 
y1 = 1 
x2 = 126 
y2 = 62 
GOSUB Draw_Round_Rectang 
x1 = 14 
y1 = 12 
x2 = 112 
y2 = 31 
GOSUB Draw_Rectang 
x1 = 15 
y1 = 13 
x2 = 97 
y2 = 18 
GOSUB Invert 
x1 = 15 
y1 = 13 
x2 = 97 
y2 = 18 
GOSUB Shift_Hor 
GOSUB CleanScreen 
x1 = 14 
y1 = 12 
x2 = 112 
y2 = 31 
GOSUB Draw_Rectang 
GOSUB oldspring 
PAUSE 1000 
GOSUB shift_Y 
END 
'=========================== Draw Round Rectang ======================== 
Draw_Round_Rectang: 
PAUSE 100 
SEROUT SOUT, Baud, [noparse][[/noparse]$57] 'Round Rectang function 
SEROUT SOUT, Baud, [noparse][[/noparse]x1] 'x1 
SEROUT SOUT, Baud, [noparse][[/noparse]y1] 'y1 
SEROUT SOUT, Baud, [noparse][[/noparse]x2] 'x2 
SEROUT SOUT, Baud, [noparse][[/noparse]y2] 'y2 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
RETURN 
'============================= Draw Rectang ============================ 
Draw_Rectang: 
PAUSE 100 
SEROUT SOUT, Baud, [noparse][[/noparse]$56] 'Rectang function 
SEROUT SOUT, Baud, [noparse][[/noparse]x1] 'x1 
SEROUT SOUT, Baud, [noparse][[/noparse]y1] 'y1 
SEROUT SOUT, Baud, [noparse][[/noparse]x2] 'x2 
SEROUT SOUT, Baud, [noparse][[/noparse]y2] 'y2 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
RETURN 
'================================ Invert =============================== 
Invert: 
PAUSE 100 
FOR idx = 0 TO 8 
SEROUT SOUT, Baud, [noparse][[/noparse]$27] 'Invert function 
SEROUT SOUT, Baud, [noparse][[/noparse]x1] 'x1 
SEROUT SOUT, Baud, [noparse][[/noparse]y1] 'y1 
SEROUT SOUT, Baud, [noparse][[/noparse]x2] 'w 
SEROUT SOUT, Baud, [noparse][[/noparse]y2] 'h 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 1000 
NEXT 
PAUSE 100 
RETURN 
'=========================== Clean Screen ============================== 
CleanScreen: 
SEROUT SOUT, Baud, [noparse][[/noparse]$23] 
SEROUT SOUT, Baud, [noparse][[/noparse]0] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
RETURN 
'============================= Set Font ================================ 
SetFont: 
SEROUT SOUT, Baud, [noparse][[/noparse]$24] 
SEROUT SOUT, Baud, [noparse][[/noparse]idx] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
RETURN 
'=========================== Screen Text0 =============================== 
Text0: 
SEROUT SOUT, Baud, [noparse][[/noparse]$2B] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]"by OldSpring"] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
SEROUT SOUT, Baud, [noparse][[/noparse]$5F] 
SEROUT SOUT, Baud, [noparse][[/noparse]30] 
SEROUT SOUT, Baud, [noparse][[/noparse]48] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
RETURN 
'=========================== Screen Text1 =============================== 
Text1: 
SEROUT SOUT, Baud, [noparse][[/noparse]$2B] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]"GLCD Simple Project"] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
SEROUT SOUT, Baud, [noparse][[/noparse]$5F] 
SEROUT SOUT, Baud, [noparse][[/noparse]8] 
SEROUT SOUT, Baud, [noparse][[/noparse]38] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
RETURN 
'=========================== OldSpring Screen =============================== 
OldSpring: 
SEROUT SOUT, Baud, [noparse][[/noparse]$2B] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]"OldSpring"] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
SEROUT SOUT, Baud, [noparse][[/noparse]$5F] 
SEROUT SOUT, Baud, [noparse][[/noparse]25] 
SEROUT SOUT, Baud, [noparse][[/noparse]15] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
RETURN 
'=========================== Shift Hor =============================== 
Shift_Hor: 
PAUSE 100 
FOR idx = 0 TO 96 
SEROUT SOUT, Baud, [noparse][[/noparse]$26] 
SEROUT SOUT, Baud, [noparse][[/noparse]x1 + idx] 
SEROUT SOUT, Baud, [noparse][[/noparse]y1] 
SEROUT SOUT, Baud, [noparse][[/noparse]x2 - idx] 
SEROUT SOUT, Baud, [noparse][[/noparse]y2] 
SEROUT SOUT, Baud, [noparse][[/noparse]1] 'Move text to Right side 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
NEXT 
PAUSE 1000 
RETURN 
'=========================== Shift Y =============================== 
Shift_Y: 
PAUSE 100 
FOR idx = 63 TO 32 
SEROUT SOUT, Baud, [noparse][[/noparse]$25] 
SEROUT SOUT, Baud, [noparse][[/noparse]idx] 'Move picture down 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
NEXT 
PAUSE 1000 
FOR idx = 32 TO 76 
SEROUT SOUT, Baud, [noparse][[/noparse]$25] 
SEROUT SOUT, Baud, [noparse][[/noparse]idx] 'Move picture up 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
PAUSE 100 
NEXT 
PAUSE 1000 
SEROUT SOUT, Baud, [noparse][[/noparse]$25] 
SEROUT SOUT, Baud, [noparse][[/noparse]0] 'Back to original position 
SEROUT SOUT, Baud, [noparse][[/noparse]250] 
RETURN 


·
Have fun!
Visit OldSpring Website for detail:· http://oldspring.110mb.com/Index.html
OldSpring
·
·

Post Edited (OldSpring) : 3/8/2010 6:23:33 PM GMT
2816 x 2112 - 2M
2816 x 2112 - 2M
2816 x 2112 - 2M
Sign In or Register to comment.