//--------------------------------------------------------- /* NHD-320240WG-B BASIC Program for writing to Newhaven Display 320x240 Graphic LCD (c)2008 Curt Lagerstam - Newhaven Display International, LLC. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ //---------------------------------------------------------'------------------------------------------------------------------------------- 'NHD-320240WG-B '320 x 240 graphic lcd with Epson 13700 controller 8bit interface ' 'shows Newhaven logo and widget ' 'pin ' 1 GND ' 2 +5V ' 3 Vo ' 4 A0 P3.0 ' 5 R/W P3.7 ' 6 E P3.4 ' 7-14 data P1 '15 /CS P3.1 '16 /RST P3.6 '17 Vee '18 SEL1 P3.2 '19 FG '20 Wait '------------------------------------------------------------------------------- $large Dim A As Byte Dim Count As Long Declare Sub Writecom Declare Sub Writedata Declare Sub Init Declare Sub Clr Declare Sub Text Declare Sub Logo '------------------------------------------------------------------------------- Call Init Do Call Logo Wait 3 Loop End '------------------------------------------------------------------------------- Sub Writecom Set P3.0 'A0 = H = Write command P1 = A 'move data to P1 Reset P3.1 'chip select Reset P3.7 'R/W Set P3.4 'E Reset P3.4 'E Set P3.7 'R/W Set P3.1 'CS End Sub Sub Writedata Reset P3.0 'A0 = L = Write data P1 = A Reset P3.1 Reset P3.7 Set P3.4 Reset P3.4 Set P3.7 Set P3.1 End Sub '------------------------------------------------------------------------------- Sub Init Set P3.2 'SEL=1 = Motorola 6800 write interface Reset P3.6 'RESET Waitms 10 'wait Set P3.6 'RESET done Waitms 100 'wait A = &H40 'system set command Call Writecom A = &H30 'set parameters Call Writedata A = &H87 'horizontal character size=8 Call Writedata A = &H07 'vertical character size=8 Call Writedata A = &H27 'display addresses per line Call Writedata A = &H50 'total address range per line Call Writedata A = &HEF '240 display lines Call Writedata A = &H28 'virtual address1 Call Writedata A = &H00 'virtual address2 Call Writedata A = &H44 'scroll Call Writecom A = &H00 'start address1 Call Writedata A = &H00 'start address2 Call Writedata A = &HEF '240 lines Call Writedata A = &HB0 '2nd screen start1 Call Writedata A = &H04 '2nd screen start2 Call Writedata A = &HEF '2nd screen 240 lines Call Writedata A = &H00 '3rd screen address1 Call Writedata A = &H00 '3rd screen address2 Call Writedata A = &H00 '4th screen address1 Call Writedata A = &H00 '4th screen address2 Call Writedata A = &H5A 'hdot scr Call Writecom A = &H00 'horizontal pixel shift=0 Call Writedata A = &H5B 'overlay Call Writecom A = &H00 'OR Call Writedata A = &H5D 'cursor form Call Writecom A = &H04 '5 pixels Call Writedata A = &H86 'by 7 pixels Call Writedata A = &H4C 'cursor direction = right Call Writecom Call Clr 'clear the screen A = &H59 'disp on/off Call Writecom A = &H14 'on Call Writedata End Sub '------------------------------------------------------------------------------- Sub Clr A = &H46 'set cursor Call Writecom 'to text page A = &H00 Call Writedata A = &H00 Call Writedata A = &H42 'mwrite Call Writecom A = &H20 For Count = 1 To 1200 '1200 spaces Call Writedata Next Count A = &H46 'set cursor Call Writecom A = &HB0 'to graphics page Call Writedata A = &H04 Call Writedata A = &H42 Call Writecom 'mwrite A = &H00 For Count = 1 To 9600 'write 9600 bytes of 0x00 to clear Call Writedata Next Count End Sub '------------------------------------------------------------------------------- Sub Text A = &H46 Call Writecom 'set cursor to text page A = &H31 Call Writedata A = &H02 Call Writedata A = &H42 Call Writecom 'mwrite Restore Dta1 For Count = 1 To 40 Read A Call Writedata 'One line is 40 characters = 28H Next Count End Sub '------------------------------------------------------------------------------- Sub Logo A = &H46 'set cursor to graphics page Call Writecom A = &HB0 Call Writedata A = &H04 Call Writedata A = &H42 Call Writecom 'mwrite Restore Dta2 For Count = 1 To 9600 Read A Call Writedata Next Count End Sub '------------------------------------------------------------------------------- Dta1: "Newhaven Display graphic LCD..." Dta2: 'Newhaven logo 9600 bytes of bitmap data Data &H00, &HFF, &H00, &HFF