'-------------------------------------------------------------------------------- 'name : GLCD_DMF5001_example2 'purpose : Graphic LCD DMF5001NY control example 'micro controller : Mega168 (Kyohritsu-Digit, AVR168 Universal board) 'Hardware : Graphic LCD DMF5001NY (Toshiba T6963C controller) ' : 160x128 dots. monochro. (20 char. x 16 line) ' '-------------------------------------------------------------------------------- ' Rem Used ports '-------------------------------------------------------------------------------- ' RESERVED PORTS (unable to use by user) ' ' PB3-5 : reserved by SPI program ' PC6 : reserved by Reset ' ' ' GLCD control ports ' ' PD0-7 : LCD - ' Data port must be settled into one 8-bit port. ' In the above case, PortD. ' PC0 : LCD /WR ' PC1 : LCD /RD ' PC2 : LCD /CE ' PC3 : LCD C/D ' PC4 : LCD /Res ' Control lines must be settled into the same port. ' In the above case, all control lines are set to PortC. ' ' PB0 : test SW (tacticle push SW) ' PB1 : test LED (H = emit) ' '-------------------------------------------------------------------------------- $regfile = "m168def.dat" $crystal = 8000000 ' internal OSC $hwstack = 32 $swstack = 64 $framesize = 40 Const Dly1 = 300 ' LED toggle ms Const Dly2 = 200 ' SW wait time Rem port definitions Config Portb.0 = Input Sw1 Alias Pinb.0 Config Portb.1 = Output Led Alias Portb.1 ' test LED Rem type definition of variables Dim I As Integer , J As Integer , I2 As Integer , J2 As Integer Dim S As String * 40 Dim X As Single , Y As Single , X2 As Single , Y2 As Single Dim Mode_n As Byte , Mode_n2 As Byte ' Mode_n number Dim Swf1 As Bit ' SW flag Rem program start ' LED test ' toggle the LED bits Reset Led For I = 1 To 3 Toggle Led ' change bit 1/0 Waitms Dly1 ' wait Dly1 ms Next I Reset Led Waitms 300 ' wait LCD power-up Rem Port initialize ' define LCD Config Graphlcd = 240 * 128 , Dataport = Portd , Controlport = Portc , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 8 ' NOTE: Fs = 5 is dummy definition (un-used). Unless, a BASCOM error occurs. ' BASCOM supports Toshiba T6963C controller by Config Graphlcd command as default. ' After the declaration of the above statement, ' many control commands for GCLD are ready to use on BASCOM. ' Therefore, it is very easy to use the DMF5001 Graphic LCD. Rem initialize variables Mode_n = 0 ' Mode_n-0 Mode_n2 = 1 ' old Mode_n (If Mode_n <> Mode_n2 then renew display) Set Swf1 ' SW1 flag = 1 = not-pushed Rem Main loop Mloop: Gosub Mdisp ' mode display If Sw1 = 0 Then ' SW1 pushed -> mode select Set Swf1 Incr Mode_n If Mode_n > 3 Then Mode_n = 0 Mode_n2 = Mode_n + 1 Gosub Sw1wait End If Goto Mloop ' LOOP End Rem subroutines ' wait SW change Sw1wait: Waitms Dly2 Bitwait Sw1 , Set ' wait for SW1 release Reset Swf1 Return ' Mode display Mdisp: If Mode_n = Mode_n2 Then Return Mode_n2 = Mode_n Select Case Mode_n Case 0: Cls Locate 1 , 1 Lcd "GLCD DMF5001" Locate 2 , 1 Lcd "160 x 128 dots" Case 1: ' Draw line Line(1 , 1) -(27 , 52) , 1 Case 2: ' Draw circle Circle(120 , 64) , 40 , 1 Case 3: Locate 5 , 6 Lcd "Sine curve" Gosub Sine_curve End Select Return Rem draw sine curve Sine_curve: Y = 3.1416 Y = Y / 50 X2 = 0 X = 0 For I = 1 To 800 Y2 = Sin(x) X = X + Y Y2 = Y2 * 75 Y2 = 100 - Y2 I2 = X2 J2 = Y2 Pset I2 , J2 , 1 X2 = X2 + 1 Next I Return