3.5" Color LCD code example


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 45
  1. #1
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94

    Default 3.5" Color LCD code example

    I recently bought a 3.5" color lcd from China from
    http://cgi.ebay.com/3-5-262k-TFT-240...item1c153a8de4
    for $35.00 including shipping. It also has a touch screen and controller , eeprom, and sd socket.

    Below is the test code. This should get you started if you want to play with this color display.

    I am using 8 bit control for the LCD and hardware SPI for the touch screen controller.

    Here are the spec's

    3.5" QVGA 262k TFT-LCD module
    240*RGB*320 pixels
    LCD driver is SSD2119
    2.7-3.3V operating voltage
    RS1843 touch panel controller onboard directly compatible with ADS7843
    Standard 2.54mm PCB headers for prototyping
    Support a SD card interface(SPI mode)
    Support a ATMEL DataFlash AT45DBxxx series device
    Optional 8-bit or 16-bit parallel bus interface and
    Optional 3 wire SPI or 4 wire SPI interface with PS3、PS2、PS1、PS1 jump select
    4-wire Touch Panel support

    I have to give credit to Darrel Taylor, mister_e, skimask and anyone else I may have used their code over the years.
    Code:
    ' ************************************************************
    ' * Auto generated EasyHID file. PBP 2.60 and above          *
    ' ************************************************************
    
    ' include the HID descriptor
    include	"DESC_TFT.bas"
    
    DEFINE OSC 48
    DEFINE LOADER_USED 1
    
    ADCON1 = $F       'port A digital
    CMCON = 7         'PortA Digital
    INTCON2.7 = 0     'weak pullups portB
    'INTCON2.4 = 0     'INT2 falling edge
    USBBufferSizeMax   con 64  ' maximum buffer size
    USBBufferSizeTX    con 64  ' input
    USBBufferSizeRX    con 64  ' output
    
    ' the USB buffer...
    USBBuffer        Var Byte[USBBufferSizeMax] 
    USBBufferCount   Var Byte 
    
    
    SPI_Buf_out   var        byte[8]      'spi output buffer
    SPI_Buf_in   var        byte[8]       'spi input buffer
    spi_cnt      var        byte          ' Transmit counter
    ts_y      var        word
    ts_x      var        word
    ts_cs     var        PORTB.5
    number    var        word
    len       var        byte
    high      ts_cs
    ' LCD VARS__________________________________________________________
    
    LCD_Dat         var    PORTD
    LCD_CS          var    PORTE.2
    LCD_RS          var    PORTB.3
    LCD_RD          var    PORTE.0
    LCD_WR          var    PORTE.1
    LCD_RST         var    PORTC.6
    CMD             var    word
    DAT             var    word
    Color           var    word
    fColor           var    word
    bColor           var    word
    ' Color
    RED	    con  $f800
    GREEN	con  $07e0
    BLUE	con  $001f
    YELLOW	con  $ffe0
    CYAN	con  $07ff
    MAGENTA	con  $f81f
    BLACK	con  $0000
    WHITE	con  $ffff
    rlb   var    byte
    rhb   var    word
    i     var    long
    j     var    long
    k     var    long
    m     var    byte
    n     var    byte
    
    '** Graphic vars *************************************************************
    cx          var     long
    cy          var     long
    sx          var     long
    ex          var     long
    sy          var     long
    ey          var     long
    x           var     word
    y           var     word
    ypos        var     long
    rad         var     long
    rad2         var    long
    color_buf   var     word
    sx_buff      var     word
    ex_buff      var     word
    'Circle constants and variables
    gl_pi			con	2	'PI as an integer
    glc_x			var     BYTE	'Calculation var
    glc_y			var     BYTE	'Calculation var
    glc_s			var     WORD	'Slope
    glc_cx			var     BYTE	'Center x
    glc_cy  		var     BYTE	'Center y
    glc_r			var     BYTE	'Radius
    gl_x1			var     word
    gl_x2           var     word
    gl_y1           var     BYTE
    gl_y2           var     BYTE
    b_inp1	 		var     BYTE
    b_inp2	 		var     BYTE
    b_inp3	 		var     BYTE
    gl_i		var	word
    gl_j		var BYTE
    gl_k		var	BYTE
    gl_l        var BYTE
    gl_m        var BYTE
    gl_x		var	WORD
    gl_y		var	WORD
    '===============================================================================
    Invert          var bit
    charsel          var byte[8]
    char_row         var byte
    lu1              var byte
    charpos          var byte
    addr             var word
    addrb            var byte
    addrb = 0
    addr1            var word
    char             var chardata[0]
    chardata         var byte[8]
    temp             var byte
    temp1            var byte
    temp5            var byte
    Im1              var word
    temp2            var byte
    a               var byte
    LCDx    var byte    '  Col position
    LCDy    var byte    '  Row position
    big     var byte
    big = 0
    Row var byte
    col var byte
    
    picdat  var byte
    
    lcdcharloop var byte
    lcdchardata var byte[8]
    tp_cs      var PORTB.5
    
    SSPEN VAR SSPCON1.5   ' SSP Enable bit
    CKP   VAR SSPCON1.4   ' Clock Polarity Select
    SMP   VAR SSPSTAT.7  ' Data input sample phase
    CKE   VAR SSPSTAT.6  ' Clock Edge Select bit
    SSPIF VAR PIR1.3     ' SPI interrupt flag
    WCOL		Var	SSPCON1.7	' SSP write collision
    BF		    Var	SSPSTAT.0	' SSP buffer full
    SSPCON1 = %00000010	
    Pen_Down  var PORTB.2
    TRISA = %00000000
    TRISB = %00000101
    TRISC = %00000000
    TRISD = %00000000
    TRISE.0 = 0
    TRISE.1 = 0
    TRISE.2 = 0
    latD = %11111111
    high lcd_cs
    high lcd_RD
    high lcd_wr
    high lcd_rs
    high lcd_rst
    
        '   Interrupt definition
        '   ====================
            '   USB interrupt used to keep USB connection alive
    INCLUDE "DT_INTS-18.bas"    ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts
    ASM
    INT_LIST  macro    ; IntSource,         Label,  Type, ResetFlag?
            INT_Handler    INT2_INT,  _TS_INT,   ASM,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    @    INT_ENABLE  INT2_INT      ; enable external (INT) interrupt
    
    ASM	;printstr2 to color LCD macro,	'@ printstr2 x,y, "string2 to lcd at x,y"
    printstr2	macro x2, y2, str2
    		local thestring2, overstr2
    	
    		bra overstr2
    thestring2
    		data str2,0
    overstr2
    		MOVE?CB x2, _LCDx
    		MOVE?CB y2, _Row
    		MOVE?CW thestring2, _addr
    		L?CALL _stringout2
    		endm
    ENDASM
    
    
    pause 1000
    'include "USB_ASM_Service.pbp"
    lcd_dat = $FF
    goto programstart
    '******************************************************************************
    LCD_Write_CMD:
    high lcd_RD
    low lcd_rs
    low lcd_cs
    low lcd_wr
    lcd_dat = cmd.highbyte
    high lcd_wr
    low lcd_wr
    LCD_Dat = cmd.lowbyte
    high lcd_wr
    high lcd_rs
    high lcd_cs
    
    Return
    '******************************************************************************
    LCD_Write_Dat:
    high lcd_RD
    high lcd_rs
    low lcd_cs
    low lcd_wr
    lcd_dat = dat.highbyte
    high lcd_wr
    low lcd_wr
    LCD_Dat = dat.lowbyte
    high lcd_wr
    high lcd_cs
    
    return
    '******************************************************************************
    LCD_Read_Dat:           ' only works with 16 bit control
    TRISD = $FF
    color_buf = 0
    low lcd_cs
    high lcd_rs
    high lcd_wr
    
    
    low lcd_rd      'dummy read
    high lcd_rd
    
    low lcd_rd
    color_buf.lowbyte = lcd_dat 
    high lcd_rd
                                                            'lcd_dat
    low lcd_rd
    color_buf.highbyte = lcd_dat 
    high lcd_rd
    
                                                               'lcd_dat
    TRISD = $00
    high lcd_cs
    return
    '******************************************************************************
    
    LCD_RESET:
    low lcd_rst
    pause 500
    high lcd_rst
    pause 1000
    return
    '******************************************************************************
    LCD_Test:
    gosub lcd_home
    for i = 0 to 319
        for j = 0 to 239
            if i > 279 then 
            dat = black
            elseif i > 239 then 
            dat = blue
            elseif i > 199 then 
            dat = green
            elseif i > 159 then 
            dat = cyan
            elseif i > 119 then 
            dat = red
            elseif i > 79 then 
            dat = magenta
            elseif i > 39 then 
            dat = yellow
            else 
            dat = white
            
            endif
            gosub lcd_write_dat
        next j       
    
    
    
    
    next i
    return
    '******************************************************************************
    LCD_INIT:
    gosub lcd_reset
    cmd = $0028 : gosub lcd_write_CMD : dat = $0006 : gosub lcd_write_dat
    
    pause 10
    cmd = $0000 : gosub lcd_write_CMD : dat = $0001 : gosub lcd_write_dat ' Start OSC
    cmd = $0010 : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    cmd = $0001 : gosub lcd_write_CMD : dat = $30EF : gosub lcd_write_dat  ' Driver output  32EF
    cmd = $0002 : gosub lcd_write_CMD : dat = $0600 : gosub lcd_write_dat   
    cmd = $0003 : gosub lcd_write_CMD : dat = $6A64 : gosub lcd_write_dat   
    cmd = $0011 : gosub lcd_write_CMD : dat = $6830 : gosub lcd_write_dat   
    
    cmd = $000F : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    
    cmd = $000B : gosub lcd_write_CMD : dat = $5308 : gosub lcd_write_dat
    cmd = $000C : gosub lcd_write_CMD : dat = $0003 : gosub lcd_write_dat
    cmd = $000D : gosub lcd_write_CMD : dat = $000A : gosub lcd_write_dat
    cmd = $000E : gosub lcd_write_CMD : dat = $2E00 : gosub lcd_write_dat
    
    cmd = $001E : gosub lcd_write_CMD : dat = $002B : gosub lcd_write_dat '
    cmd = $0025 : gosub lcd_write_CMD : dat = $8000 : gosub lcd_write_dat
    cmd = $0026 : gosub lcd_write_CMD : dat = $7000 : gosub lcd_write_dat 
    cmd = $004E : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    cmd = $004F : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    
    cmd = $0012 : gosub lcd_write_CMD : dat = $08D9 : gosub lcd_write_dat
     ' Gama Curve
    cmd = $0030 : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    cmd = $0031 : gosub lcd_write_CMD : dat = $0104 : gosub lcd_write_dat
    cmd = $0032 : gosub lcd_write_CMD : dat = $0100 : gosub lcd_write_dat
    cmd = $0033 : gosub lcd_write_CMD : dat = $0305 : gosub lcd_write_dat
    cmd = $0034 : gosub lcd_write_CMD : dat = $0505 : gosub lcd_write_dat
    cmd = $0035 : gosub lcd_write_CMD : dat = $0305 : gosub lcd_write_dat
    cmd = $0036 : gosub lcd_write_CMD : dat = $0707 : gosub lcd_write_dat
    cmd = $0037 : gosub lcd_write_CMD : dat = $0300 : gosub lcd_write_dat
    cmd = $003A : gosub lcd_write_CMD : dat = $1200 : gosub lcd_write_dat
    cmd = $003B : gosub lcd_write_CMD : dat = $0800 : gosub lcd_write_dat
    pause 150
    cmd = $0007 : gosub lcd_write_CMD : dat = $0033 : gosub lcd_write_dat
    pause 200
    
    Return
    '******************************************************************************
    LCD_HOME:
    
    cmd = $004E : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat  ' RAM Addsress set X
    cmd = $004F : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat  ' RAM Addsress set Y
    cmd = $0044 : gosub lcd_write_CMD : dat = $EF00 : gosub lcd_write_dat  'Vertical start/end RAM address position
    cmd = $0045 : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat  'Horizontal start RAM address position 
    cmd = $0046 : gosub lcd_write_CMD : dat = $013F : gosub lcd_write_dat   ' Horizontal end RAM address position
    cmd = $0022 : gosub lcd_write_CMD     'RAM data write/read
    
    return
    '******************************************************************************
    CLR_DISP:
    color = white
    for i = 0 to 319
        for j = 0 to 239
        dat = color
        gosub lcd_write_dat
        next j
    next i
    return
    '******************************************************************************
    '  Need sx (start x), ex (end x) sy (start y), ey (end y) and Color
    '
    '******************************************************************************
    Fill_Rect:
    ypos.highbyte = ey
    ypos.lowbyte = sy
    
    
    cmd = $004E : gosub lcd_write_CMD : dat = sx : gosub lcd_write_dat  ' RAM Addsress set X
    cmd = $004F : gosub lcd_write_CMD : dat = sy : gosub lcd_write_dat  ' RAM Addsress set Y
    cmd = $0044 : gosub lcd_write_CMD : dat = ypos: gosub lcd_write_dat  'Vertical start/end RAM address position
    cmd = $0045 : gosub lcd_write_CMD : dat = sx : gosub lcd_write_dat  'Horizontal start RAM address position 
    cmd = $0046 : gosub lcd_write_CMD : dat = ex : gosub lcd_write_dat   ' Horizontal end RAM address position
    cmd = $0022 : gosub lcd_write_CMD     'RAM data write/read
    x = ex - sx + 1
    y = ey - sy + 1
    dat = color
    for j = 0 to y
        for i = 0 to x
        gosub lcd_write_dat
        next i
    next j
    return
    
    '******************************************************************************
    '  Need cx (center x), cy (center y), rad (radius) and Color
    '
    '******************************************************************************
    
    '******************************************************************************
    '    need  x, y, color
    '
    '******************************************************************************
    Setdot:
    cmd = $004E : gosub lcd_write_CMD : dat = x : gosub lcd_write_dat  ' RAM Addsress counter set X
    cmd = $004F : gosub lcd_write_CMD : dat = y : gosub lcd_write_dat  ' RAM Addsress counter set Y
    cmd = $0022 : gosub lcd_write_CMD 
    dat = color
    gosub lcd_write_dat
    
    return
    
    ' ***** Set x,y Points *****
    set8:
    	x = glc_x+glc_cx : y=glc_y+glc_cy	        '1
    	gosub setdot
    	x = glc_cx-glc_x : y=glc_y+glc_cy		'2	
    	gosub setdot
    	x = glc_cx+glc_x : y=glc_cy-glc_y		'3	
    	gosub setdot
    	x = glc_cx-glc_x : y=glc_cy-glc_y		'4	
    	gosub setdot
    	x = glc_y+glc_cx : y=glc_x+glc_cy		'5
    	gosub setdot			
    	x = glc_cx-glc_y : y=glc_cy+glc_x		'6	
    	gosub setdot
    	x = glc_cx+glc_y : y=glc_cy-glc_x		'7	
    	gosub setdot
    	x = glc_cx-glc_y : y=glc_cy-glc_x		'8	
    	gosub setdot
    return
    
    '*** gl_circle d = diameter r = radius x,y are point locations ***
    '***** Given Center = glc_cx,glc_cy and Radius = glc_r **********
    gl_circ:
      glc_x = 0
      glc_y = glc_r
      glc_s = gl_pi-2*glc_r
      
    
      while (glc_x <= glc_y) 
     
          gosub set8
    
    	if (glc_s.15 =1) then
               glc_s = glc_s + (4*glc_x + 6)
             else
               glc_s = glc_s + (4*(glc_x-glc_y) + 10)
               glc_y = glc_y - 1
    	endif
    
    	glc_x = glc_x + 1
      wend
    
    return
    'Rectangle subroutine given gl_x1,gl_x2,gl_y1, gl_y2
    gl_rect:
    
            gosub chk_xy         
    	for gl_i= gl_x1 to gl_x2 step 1
    		x = gl_i
    		y = gl_y1
    		gosub setdot
    	        y = gl_y2
    		gosub setdot
    	next gl_i
    
    	for gl_i= gl_y1 to gl_y2 step 1
    		y = gl_i
    		x = gl_x1
    		gosub setdot
    		x = gl_x2
    		gosub setdot
    	next gl_i
    
    return
    
    chk_xy:
    	if gl_x1 > gl_x2 then
    		swap gl_x1,gl_x2
            endif
    	if gl_y1 > gl_y2 then
    		swap gl_y1,gl_y2
            endif
    return
    
    
    
    '*******************************************************************************
    '           Text
    '*******************************************************************************
    stringout2:		
    lcdy = row
    Readcode addr, char : 
    If char = 0 then return 
    
    gosub putclcdtext : 
    addr = addr + 1 : 
    lcdx = lcdx + 1 : 
    
    lcdy = row 
    
    goto stringout2
    
    
    putclcdtext:	
    if char < 20 then return
     if char > $7f then return
     
     for char_row = 0 to 4
         if char < $50 then
            charpos  = (((char & $ff)- $20)*5)
            gosub table1
            
         endif
    
         if char > $4f then
            charpos  = (((char & $ff)- $50)*5)
            gosub table2
          endif 
    
    next char_row
    if big = 0 then      ' Normal 5x7 font
        for j = 0 to 7   ' data bits 0 - 7
                    
                	cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat  ' RAM Addsress counter set X
                    cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat  ' RAM Addsress counter set Y    
        
                       
            for k = 1 to 5
        
        	        dat = fcolor
                    temp = chardata[k]
                    if temp.0[j] = 0 then 
                        dat = bcolor
                    endif
                    cmd = $0022 : gosub lcd_write_CMD 
                    gosub lcd_write_dat
        	next k
        	dat = bcolor
            gosub lcd_write_dat
            lcdy = lcdy + 1
        
        next j 
        lcdx = lcdx + 6
        
    
    elseif big = 1 then      ' big 10x14 font
        for j = 0 to 7   ' data bits 0 - 7
        for n = 0 to 1
                     
                	cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat  ' RAM Addsress counter set X
                    cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat  ' RAM Addsress counter set Y    
        
        
            for k = 1 to 5
            for m = 0 to 1    
        	        dat = fcolor
                    temp = chardata[k]
                    if temp.0[j] = 0 then 
                        dat = bcolor
                    endif
                    cmd = $0022 : gosub lcd_write_CMD 
                    gosub lcd_write_dat
        	next m
            next k
        	
            dat = bcolor
            gosub lcd_write_dat
            lcdy = lcdy + 1
        next n
        next j 
        lcdx = lcdx + 10       '20X24
    elseif big = 2   then
        for j = 0 to 7   ' data bits 0 - 7
        for n = 0 to 3
                     
                	cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat  ' RAM Addsress counter set X
                    cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat  ' RAM Addsress counter set Y    
        
        
            for k = 1 to 5
            for m = 0 to 3    
        	        dat = fcolor
                    temp = chardata[k]
                    if temp.0[j] = 0 then 
                        dat = bcolor
                    endif
                    cmd = $0022 : gosub lcd_write_CMD 
                    gosub lcd_write_dat
        	next m
            next k
        	
            dat = bcolor
            gosub lcd_write_dat
            lcdy = lcdy + 1
        next n
        next j 
        lcdx = lcdx + 24
    
    endif
    return
    
    '=================
    'FONT SAMPLE 5x7
    '=================
    
    Table1:
    lu1 = charpos + char_row
    
    lookup lu1, [0,0,0,0,0,_             'space
                $00,$00,$5f,$00,$00,_	'// 21 !
    			$00,$07,$00,$07,$00,_	' 22 "
    			$14,$7f,$14,$7f,$14,_	 ' 23 #
    			$24,$2a,$7f,$2a,$12,_	 ' 24 $
    			$23,$13,$08,$64,$62,_	'  25%
    			$36,$49,$55,$22,$50,_	 ' 26 &
    			$00,$05,$03,$00,$00,_	 ' 27 '
    			$00,$1c,$22,$41,$00,_	 ' 28 (
    			$00,$41,$22,$1c,$00,_	 ' 29 )
    			$14,$08,$3e,$08,$14,_	 ' 2a *
    			$08,$08,$3e,$08,$08,_	 ' 2b +
    			$00,$50,$30,$00,$00,_	 ' 2c ,
    			$08,$08,$08,$08,$08,_	 ' 2d -
    			$00,$60,$60,$00,$00,_	 ' 2e .
    			$20,$10,$08,$04,$02,_	 ' 2f /
    			$3e,$51,$49,$45,$3e,_	 ' 30 0
    			$00,$42,$7f,$40,$00,_	 ' 31 1
    			$42,$61,$51,$49,$46,_    ' 32 2
    			$21,$41,$45,$4b,$31,_    ' 33 3
    			$18,$14,$12,$7f,$10,_    ' 34 4
    			$27,$45,$45,$45,$39,_    ' 35 5
    			$3c,$4a,$49,$49,$30,_    ' 36 6
    			$01,$71,$09,$05,$03,_    ' 37 7
    			$36,$49,$49,$49,$36,_    ' 38 8
    			$06,$49,$49,$29,$1e,_	'// 39 9
    			$00,$36,$36,$00,$00,_	'// 3a :
    			$00,$56,$36,$00,$00,_	'// 3b ;
    			$08,$14,$22,$41,$00,_	'// 3c <
    			$14,$14,$14,$14,$14,_	'// 3d =
    			$00,$41,$22,$14,$08,_	'// 3e >
    			$02,$01,$51,$09,$06,_	'// 3f ?
    			$32,$49,$79,$41,$3e,_	'// 40 @
    			$7e,$11,$11,$11,$7e,_	'// 41 A
    			$7f,$49,$49,$49,$36,_	'// 42 B
    			$3e,$41,$41,$41,$22,_	'// 43 C
                $7f,$41,$41,$22,$1c,_	'// 44 D
    			$7f,$49,$49,$49,$41,_	'// 45 E
    			$7f,$09,$09,$09,$01,_	'// 46 F
    			$3e,$41,$49,$49,$7a,_	''// 47 G
    			$7f,$08,$08,$08,$7f,_	'// 48 H
    			$00,$41,$7f,$41,$00,_	'// 49 I
    			$20,$40,$41,$3f,$01,_	'// 4a J
    			$7f,$08,$14,$22,$41,_	'// 4b K
    			$7f,$40,$40,$40,$40,_	'// 4c L
    			$7f,$02,$0c,$02,$7f,_	'// 4d M
    			$7f,$04,$08,$10,$7f,_	'// 4e N
    			$3e,$41,$41,$41,$3e],temp	'// 4f O
    chardata[char_row + 1] = temp
    
    
    Return
    
    Table2:
    lu1 = charpos + char_row
    
    lookup lu1, [$7f,$09,$09,$09,$06,_	'// 50 P
                $3e,$41,$51,$21,$5e,_	'// 51 Q
    			$7f,$09,$19,$29,$46,_	'// 52 R
    			$46,$49,$49,$49,$31,_	'// 53 S
    			$01,$01,$7f,$01,$01,_	'// 54 T
    			$3f,$40,$40,$40,$3f,_	'// 55 U
    			$1f,$20,$40,$20,$1f,_	'// 56 V
    			$3f,$40,$38,$40,$3f,_	'// 57 W
    			$63,$14,$08,$14,$63,_	'// 58 X
    			$07,$08,$70,$08,$07,_	'// 59 Y
    			$61,$51,$49,$45,$43,_	'// 5a Z
    			$00,$7f,$41,$41,$00,_	'// 5b [
    			$02,$04,$08,$10,$20,_	'// 5c
    			$00,$41,$41,$7f,$00,_	'// 5d
    			$04,$02,$01,$02,$04,_	'// 5e
    			$40,$40,$40,$40,$40,_	'// 5f
    			$00,$01,$02,$04,$00,_	'// 60
    			$20,$54,$54,$54,$78,_	'// 61 a
    			$7f,$48,$44,$44,$38,_	'// 62 b
    			$38,$44,$44,$44,$20,_	'// 63 c
    			$38,$44,$44,$48,$7f,_	'// 64 d
    			$38,$54,$54,$54,$18,_	'// 65 e
    			$08,$7e,$09,$01,$02,_	'// 66 f
    			$0c,$52,$52,$52,$3e,_	'// 67 g
    			$7f,$08,$04,$04,$78,_	'// 68 h
    			$00,$44,$7d,$40,$00,_	'// 69 i
    			$20,$40,$44,$3d,$00,_	'// 6a j 
    			$7f,$10,$28,$44,$00,_	'// 6b k
    			$00,$41,$7f,$40,$00,_	'// 6c l
    			$7c,$04,$18,$04,$78,_	'// 6d m
    			$7c,$08,$04,$04,$78,_	'// 6e n
    			$38,$44,$44,$44,$38,_	'// 6f o
    			$7c,$14,$14,$14,$08,_	'// 70 p
    			$08,$14,$14,$18,$7c,_	'// 71 q
    			$7c,$08,$04,$04,$08,_	'// 72 r
    			$48,$54,$54,$54,$20,_	'// 73 s
    			$04,$3f,$44,$40,$20,_	'// 74 t
    			$3c,$40,$40,$20,$7c,_	'// 75 u
    			$1c,$20,$40,$20,$1c,_	'// 76 v
    			$3c,$40,$30,$40,$3c,_	'// 77 w
    			$44,$28,$10,$28,$44,_	'// 78 x
    			$0c,$50,$50,$50,$3c,_	'// 79 y
    			$44,$64,$54,$4c,$44,_	'// 7a z
    			$00,$08,$36,$41,$00,_	'// 7b
    			$00,$00,$7f,$00,$00,_	'// 7c
    			$00,$41,$36,$08,$00,_	'// 7d
    			$10,$08,$08,$10,$08,_	'// 7e
    			$78,$46,$41,$46,$78], temp '	// 7f
    chardata[char_row + 1] = temp
    
    
    Return  
    '******************************************************************************
    
    
    
    
    
    '******************************************************************************
    
    '******************************************************************************
    
    '''*******************************************************************************
    spi_Write:
    		
           SPI_Buf_out[0] = $90    'read y   ADS7843
           SPI_Buf_out[1] = 0
           SPI_Buf_out[2] = $D0    'read x   ADS7843                                                  '
           SPI_Buf_out[3] = 0
           SPI_Buf_out[4] = 0 
           low tp_cs               ' enable touch screen
            
            
            SPI_Buf_in = SSPBUF	' Clear the buffer.
    		SSPIF = 0		' Clear the interrupt flag.
    for spi_cnt = 0 to 4
    		SSPBUF = SPI_Buf_out[spi_cnt]	' Send the byte.
      		While !SSPIF		' Wait for send to complete.
    		Wend
            SPI_Buf_in[spi_cnt] = SSPBUF    'receive data and put in array
            SSPIF = 0          ' reset flag
    next spi_cnt        
    '-------------------Calabration-----------------------------------------------
    ' spi returns a  12 bit number highest is 4095
    ' if the desplay is 320X240  x = 320  so-- 4095/320 = 12.80
    ' we must use integer math,  multiply the spi result by 100, 
    ' then devide that result by the calibration factor  1280 ( 12.80 * 100 )
    ' adjust this number to your display, then do the same for the Y
    '---------------------------------------------------------------------------
         high tp_cs                ' disable touch screen
         ts_y = SPI_Buf_in[1] <<5
         ts_y = 240-(((ts_y +  SPI_Buf_in[2] >>3)*100)/1800)   ' Calibration = 1800 very rough number, change to suit your scteen
         ts_x = SPI_Buf_in[3] <<5
         ts_x = 320-(((ts_x +  SPI_Buf_in[4] >>3)*100)/1244)     
    return
    '*******************************************************************************
    Print_Number:    ' need lcd_x , lcd_y , number, len, 
         temp5 = lcdy
       for i = len to 0 step -1
       char = number dig i  + 48
       gosub putclcdtext
       lcdy = temp5
        next i
    
    return
    '*******************************************************************************
    
    
    
    '*******************************************************************************
    
    '*******************************************************************************
    
    
    
    '*******************************************************************************
    
    TS_Init:       ' Touch initalization
    '---SPI ________________________________
    'SSPCON1.2 = 1
    SSPEN = 1         ' enable SPI pins  = 1
    CKP = 0           ' clock idle low
    CKE = 1           ' transmit on idle to active transition
    SSPIF = 0         ' clear buffer full status
    SMP = 0            ' sample in middle of data
    
    Return
    '---[INT - interrupt handler]---------------------------------------------------
    TS_INT:
     
    gosub LCD_HOME
    gosub clr_disp
    bcolor = white
    fcolor = black
     color = red
     sx = 159
     ex = 161
     sy = 119
     ey = 121
    gosub fill_rect      'Center dot to check calibration
    gosub LCD_HOME
    gosub  spi_write
    while pen_down = 0
    @ printstr2 125,20, "X = "
    @ printstr2 125,30, "Y = "
    lcdx = 165
    lcdy = 20
    len = 3
    number = ts_x
    gosub  print_number
    lcdx = 165
    lcdy = 30
    len = 3
    number = ts_y
    gosub  print_number   
    wend
       
    @ INT_RETURN
    
    
    ' ************************************************************
    ' * receive data from the USB bus                            *
    ' ************************************************************
    DoUSBIn:
       USBBufferCount = USBBufferSizeRX              ' RX buffer size
       USBIn 1, USBBuffer, USBBufferCount, DoUSBIn   ' read data, if available
       return
        
    ' ************************************************************
    ' * wait for USB interface to attach                         *
    ' ************************************************************
    DoUSBOut:
       USBBufferCount = USBBufferSizeTX              ' TX buffer size
       USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
       return
    ' ************************************************************
    ' * main program loop - remember, you must keep the USB      *
    ' * connection alive with a call to USBService every couple  *
    ' * of milliseconds or so...                                 *
    ' ************************************************************   
    ProgramStart: 
     gosub lcd_init
     gosub lcd_home
     gosub clr_disp
     pause 3000
     gosub lcd_test
     pause 3000
     gosub clr_disp
    
     color = blue
     sx = 0
     ex = 319
     sy = 0
     ey = 239
     gosub fill_rect
    
     color = black
     sx = 0
     ex = 319
     sy = 0
     ey = 70
     gosub fill_rect                
    
    fcolor = white
    bcolor = black
    @ printstr2 25,20, "Testing SSD2119 Controller"
     gosub lcd_home
     color = black
     sx = 20
     ex = 80
     sy = 90
     ey = 130
     gosub fill_rect
    
     color = yellow
     sx = 30
     ex = 90
     sy = 100
     ey = 140
     gosub fill_rect      
    
     color = black
     sx = 20
     ex = 80
     sy = 160
     ey = 200
     gosub fill_rect
    
     color = red
     sx = 30
     ex = 90
     sy = 170
     ey = 210
     gosub fill_rect  
    
      color = white
     sx = 195
     ex = 205
     sy = 71
     ey = 239
     gosub fill_rect 
    for k = 26 to 30
    glc_cx = 160
    glc_cy  = 120
    glc_r = k
    color = magenta
    gosub  gl_circ
    next k
    pause 2000
    gosub lcd_home
    gosub clr_disp
    big = 0
    bcolor = white
    fcolor = black
    @ printstr2 25,5, "Small"
    big = 1
    @ printstr2 25,20, "Bigger"
    big = 2
    @ printstr2 25,50, "Biggest"
    big = 0
    
    
    pause 3000
    gosub lcd_home
    gosub clr_disp
    
    glc_cx = 160
    glc_cy  = 120
    glc_r = 30
    color = green
    gosub  gl_circ
    gl_x1 = 10
    gl_x2 = 310
    gl_y1 =  10 
    gl_y2 = 230
    color = black
    gosub gl_rect
    gosub lcd_home
    bcolor = white
    fcolor = black
    @ printstr2 25,20, "SSD2119 Controller"
    @ printstr2 25,28, "Dave Cutliff "
    @ printstr2 25,36, "TFT Color LCD Model Rev 1.0"
    @ printstr2 25,44, "320xRGBx240"
    @ printstr2 25,60, "PicBasic Pro6.0 "
    @ printstr2 25,68, "Sept 8,2010"
    gosub ts_init
    Loop1:
    ' gosub DoUSBIn
    '  gosub DoUSBOut
    goto loop1

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Nice work!
    I placed it in the wiki.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    Good Job.

    Congrats!

    Ioannis

  4. #4
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Thanks

    I will be adding SD read and a function to make a digital photo frame next.

    Dave

  5. #5
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    Great Job!!!!!!!
    Thanks and Regards;
    Gadelhas

  6. #6
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Short video of project

    Here is a short (poor) video of the color LCD, I added code to scroll through pictures from the SD card.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    I like it !
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    I have ordered a sample of the LCD.

    Is it the quality of the picture as it seems on the video?

    What about he touch feeling?

    Ioannis

  9. #9
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Short video of project

    Ioannis

    The quality is much better than in the video. I used a cheap web cam to film the video that was to close to get good focus. The touch screen works very well. My program just demonstrates the basic functions of the LCD board. I have not used the on board EEPROM yet. It could be used for different fonts and pictures also. If you would like the source code, drop me a line at [email protected].

    It is a fun project. I am using PICKit2 to power the project, the max voltage is 3.3 volts. When you get your display you will need to change the solder jumpers on the back of the board (PS2 & PS3) need to be soldered for 8 bit control.

    Good luck

    Dave

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    OK. Thanks for the tips.

    I would like the demo as a starting point, thanks.

    Will send you in PM my mail.

    Ioannis

  11. #11
    Join Date
    Feb 2007
    Posts
    55


    Did you find this post helpful? Yes | No

    Default

    Very impressive..thanks for sharing

  12. #12
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Hi Dave, This is a very impressive project/product. I want to order a few, but I have some questions maybe you can answer.

    1. Do you get the feeling this is a regular product that would be available anytime in the near future?
    2. Any idea why my phone number is required for the shipping? I get nervous about this kind of thing.

    Any help will be great! Thanks.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  13. #13
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    The product is available from a few vendors both in China and in the US. I am not sure of the quantity available or how long they may be available. I paid with PayPal, don't remember having to give out my phone number. It took two weeks to get it here in the US. No problems.

    You may want to ask them about availability in quantities.

    Good luck
    Dave

  14. #14
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Awesome, gonna go order some now. Thanks!!
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  15. #15
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Wow, nice work

  16. #16


    Did you find this post helpful? Yes | No

    Default

    Dave, Super Project!

    I just ordered one. In your code you have a
    include file "DESC_TFT.bas". Could you explain it's purpose?

    Thanks

  17. #17
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Thanks

    "DESC_TFT.bas" is the USB descriptor file. The basic code was generated with EasyHid I will eventually connect to a VB program via USB. For now I am not using the USB capability.

  18. #18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DaveC3 View Post
    Thanks

    "DESC_TFT.bas" is the USB descriptor file. The basic code was generated with EasyHid I will eventually connect to a VB program via USB. For now I am not using the USB capability.
    Okay, I won't be needing that for now.

    Regards

  19. #19
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Here's an app done with a similar TFT LCD using an Atmel processor.


  20. #20
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    That is really cool, way beyond my ability.

    Thanks for sharing

  21. #21
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default 3.5" tft

    This file just reads the SD card and displays BMP images. I took out all the other stuff to make it easier to see how to load a BMP file. The pictures stored on the card need to be 320X240 24bit color. You can fiddle with the code to view more pictures if you like.

    It start with a splash screen, then lists the files on the SD card and then loops through the pictures. Notice that BMP files store the image from bottom to top.

    BTW this is a 18F4550 @ 20Mhz

    enjoy

    Dave
    Code:
    '****************************************************************
    '*  Name    : SD_PicFrame_TFT.BAS                               *
    '*  Author  : Dave Cutliff                                      *
    '*  Notice  : Copyright (c) 2010 You can take all you want      *
    '*          : All Rights Reserved                               *
    '*  Date    : 9/21/2010                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    DEFINE OSC 20
    DEFINE LOADER_USED 1
    ADCON1 = $F       'port A digital
    CMCON = 7         'PortA Digital
    INTCON2.7 = 0     'weak pullups portB
    
    Include "SDFSR.pbp"
    SDC_UseHardSPI = TRUE
    
    SPI_Buf_out   var        byte[8]      'spi output buffer
    SPI_Buf_in   var        byte[8]       'spi input buffer
    spi_cnt      var        byte          ' Transmit counter
    ts_y      var        word
    ts_x      var        word
    ts_cs     var        PORTB.5
    number    var        word
    len       var        byte
    high      ts_cs
    ' LCD VARS__________________________________________________________
    
    LCD_Dat         var    PORTD
    LCD_CS          var    PORTE.2
    LCD_RS          var    PORTB.3
    LCD_RD          var    PORTE.0
    LCD_WR          var    PORTE.1
    LCD_RST         var    PORTC.6
    CMD             var    word
    DAT             var    word
    Color           var    word
    fColor           var    word
    bColor           var    word
    rgb              var    word
    cnt              var    word
    first            var    word
    
    
    ' Color
    RED	    con  $f800
    GREEN	con  $07e0
    BLUE	con  $001f
    YELLOW	con  $ffe0
    CYAN	con  $07ff
    MAGENTA	con  $f81f
    BLACK	con  $0000
    WHITE	con  $ffff
    rlb   var    byte
    rhb   var    word
    b     var    byte
    c     var    byte
    i     var    long
    j     var    long
    k     var    long
    m     var    byte
    n     var    byte
    p     var    byte
    '** Graphic vars *************************************************************
    cx          var     long
    cy          var     long
    sx          var     long
    ex          var     long
    sy          var     long
    ey          var     long
    x           var     word
    y           var     word
    ypos        var     long
    rad         var     long
    rad2         var    long
    color_buf   var     word
    sx_buff      var     word
    ex_buff      var     word
    'Circle constants and variables
    gl_pi			con	2	'PI as an integer
    glc_x			var     BYTE	'Calculation var
    glc_y			var     BYTE	'Calculation var
    glc_s			var     WORD	'Slope
    glc_cx			var     BYTE	'Center x
    glc_cy  		var     BYTE	'Center y
    glc_r			var     BYTE	'Radius
    gl_x1			var     word
    gl_x2           var     word
    gl_y1           var     BYTE
    gl_y2           var     BYTE
    b_inp1	 		var     BYTE
    b_inp2	 		var     BYTE
    b_inp3	 		var     BYTE
    gl_i		var	word
    gl_j		var BYTE
    gl_k		var	BYTE
    gl_l        var BYTE
    gl_m        var BYTE
    gl_x		var	WORD
    gl_y		var	WORD
    '===============================================================================
    Invert          var bit
    charsel          var byte[8]
    char_row         var byte
    lu1              var byte
    charpos          var byte
    addr             var word
    addrb            var byte
    addrb = 0
    addr1            var word
    char             var chardata[0]
    chardata         var byte[8]
    temp             var byte
    temp1            var byte
    temp5            var byte
    Im1              var word
    temp2            var byte
    a               var byte
    LCDx    var byte    '  Col position
    LCDy    var byte    '  Row position
    big     var byte
    big = 0
    Row var byte
    col var byte
    tmp_color        var       word
    tmp1_color        var       word
    
    buffer           var      byte[10]
    TempData         var      byte[3] 
    NoOfChar         var      byte
    TextBuffer       var      byte[64]
    File1            var      byte[11]
    File2            var      byte[11]
    File3            var      byte[11]
    File4            var      byte[11]
    File5            var      byte[11]
    File6            var      byte[11]
    FileNum          var      byte
    BMP_data_offset  var      byte[4]
    
    picdat  var byte
    
    lcdcharloop var byte
    lcdchardata var byte[8]
    tp_cs      var PORTB.5
    
    
    Pen_Down  var PORTB.2
    TRISA = %00000000
    TRISB = %00000101
    TRISC = %00000000
    TRISD = %00000000
    TRISE.0 = 0
    TRISE.1 = 0
    TRISE.2 = 0
    latD = %11111111
    high lcd_cs
    high lcd_RD
    high lcd_wr
    high lcd_rs
    high lcd_rst
    
    
    ASM	;printstr2 to color LCD macro,	'@ printstr2 x,y, "string2 to lcd at x,y"
    printstr2	macro x2, y2, str2
    		local thestring2, overstr2
    	
    		bra overstr2
    thestring2
    		data str2,0
    overstr2
    		MOVE?CB x2, _LCDx
    		MOVE?CB y2, _Row
    		MOVE?CW thestring2, _addr
    		L?CALL _stringout2
    		endm
    ENDASM
    
    
    pause 1000
    'include "USB_ASM_Service.pbp"
    lcd_dat = $FF
    goto programstart
    '******************************************************************************
    LCD_Write_CMD:
    high lcd_RD
    low lcd_rs
    low lcd_cs
    low lcd_wr
    lcd_dat = cmd.highbyte
    high lcd_wr
    low lcd_wr
    LCD_Dat = cmd.lowbyte
    high lcd_wr
    high lcd_rs
    high lcd_cs
    
    Return
    '******************************************************************************
    LCD_Write_Dat:
    high lcd_RD
    high lcd_rs
    low lcd_cs
    low lcd_wr
    lcd_dat = dat.highbyte
    high lcd_wr
    low lcd_wr
    LCD_Dat = dat.lowbyte
    high lcd_wr
    high lcd_cs
    
    return
    '******************************************************************************
    LCD_Read_Dat:           ' only works with 16 bit control
    TRISD = $FF
    color_buf = 0
    low lcd_cs
    high lcd_rs
    high lcd_wr
    
    
    low lcd_rd      'dummy read
    high lcd_rd
    
    low lcd_rd
    color_buf.lowbyte = lcd_dat 
    high lcd_rd
                                                            'lcd_dat
    low lcd_rd
    color_buf.highbyte = lcd_dat 
    high lcd_rd
    
                                                               'lcd_dat
    TRISD = $00
    high lcd_cs
    return
    '******************************************************************************
    
    LCD_RESET:
    low lcd_rst
    pause 500
    high lcd_rst
    pause 1000
    return
    '******************************************************************************
    LCD_Test:
    gosub lcd_home
    for i = 0 to 319
        for j = 0 to 239
            if i > 279 then 
            dat = black
            elseif i > 239 then 
            dat = blue
            elseif i > 199 then 
            dat = green
            elseif i > 159 then 
            dat = cyan
            elseif i > 119 then 
            dat = red
            elseif i > 79 then 
            dat = magenta
            elseif i > 39 then 
            dat = yellow
            else 
            dat = white
            
            endif
            gosub lcd_write_dat
        next j       
    
    
    
    
    next i
    return
    '******************************************************************************
    LCD_INIT:
    gosub lcd_reset
    cmd = $0028 : gosub lcd_write_CMD : dat = $0006 : gosub lcd_write_dat
    
    pause 10
    cmd = $0000 : gosub lcd_write_CMD : dat = $0001 : gosub lcd_write_dat ' Start OSC
    cmd = $0010 : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    cmd = $0001 : gosub lcd_write_CMD : dat = $30EF : gosub lcd_write_dat  ' Driver output  32EF
    cmd = $0002 : gosub lcd_write_CMD : dat = $0600 : gosub lcd_write_dat   
    cmd = $0003 : gosub lcd_write_CMD : dat = $6A64 : gosub lcd_write_dat   
    cmd = $0011 : gosub lcd_write_CMD : dat = $6830 : gosub lcd_write_dat   
    
    cmd = $000F : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    
    cmd = $000B : gosub lcd_write_CMD : dat = $5308 : gosub lcd_write_dat
    cmd = $000C : gosub lcd_write_CMD : dat = $0003 : gosub lcd_write_dat
    cmd = $000D : gosub lcd_write_CMD : dat = $000A : gosub lcd_write_dat
    cmd = $000E : gosub lcd_write_CMD : dat = $2E00 : gosub lcd_write_dat
    
    cmd = $001E : gosub lcd_write_CMD : dat = $002B : gosub lcd_write_dat '
    cmd = $0025 : gosub lcd_write_CMD : dat = $8000 : gosub lcd_write_dat
    cmd = $0026 : gosub lcd_write_CMD : dat = $7000 : gosub lcd_write_dat 
    cmd = $004E : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    cmd = $004F : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    
    cmd = $0012 : gosub lcd_write_CMD : dat = $08D9 : gosub lcd_write_dat
     ' Gama Curve
    cmd = $0030 : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat
    cmd = $0031 : gosub lcd_write_CMD : dat = $0104 : gosub lcd_write_dat
    cmd = $0032 : gosub lcd_write_CMD : dat = $0100 : gosub lcd_write_dat
    cmd = $0033 : gosub lcd_write_CMD : dat = $0305 : gosub lcd_write_dat
    cmd = $0034 : gosub lcd_write_CMD : dat = $0505 : gosub lcd_write_dat
    cmd = $0035 : gosub lcd_write_CMD : dat = $0305 : gosub lcd_write_dat
    cmd = $0036 : gosub lcd_write_CMD : dat = $0707 : gosub lcd_write_dat
    cmd = $0037 : gosub lcd_write_CMD : dat = $0300 : gosub lcd_write_dat
    cmd = $003A : gosub lcd_write_CMD : dat = $1200 : gosub lcd_write_dat
    cmd = $003B : gosub lcd_write_CMD : dat = $0800 : gosub lcd_write_dat
    pause 150
    cmd = $0007 : gosub lcd_write_CMD : dat = $0033 : gosub lcd_write_dat
    pause 200
    
    Return
    '******************************************************************************
    LCD_HOME:
    
    cmd = $004E : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat  ' RAM Addsress set X
    cmd = $004F : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat  ' RAM Addsress set Y
    cmd = $0044 : gosub lcd_write_CMD : dat = $EF00 : gosub lcd_write_dat  'Vertical start/end RAM address position
    cmd = $0045 : gosub lcd_write_CMD : dat = $0000 : gosub lcd_write_dat  'Horizontal start RAM address position 
    cmd = $0046 : gosub lcd_write_CMD : dat = $013F : gosub lcd_write_dat   ' Horizontal end RAM address position
    cmd = $0022 : gosub lcd_write_CMD     'RAM data write/read
    
    return
    '******************************************************************************
    CLR_DISP:
    color = white
    for i = 0 to 319
        for j = 0 to 239
        dat = color
        gosub lcd_write_dat
        next j
    next i
    return
    '******************************************************************************
    '  Need sx (start x), ex (end x) sy (start y), ey (end y) and Color
    '
    '******************************************************************************
    Fill_Rect:
    ypos.highbyte = ey
    ypos.lowbyte = sy
    
    
    cmd = $004E : gosub lcd_write_CMD : dat = sx : gosub lcd_write_dat  ' RAM Addsress set X
    cmd = $004F : gosub lcd_write_CMD : dat = sy : gosub lcd_write_dat  ' RAM Addsress set Y
    cmd = $0044 : gosub lcd_write_CMD : dat = ypos: gosub lcd_write_dat  'Vertical start/end RAM address position
    cmd = $0045 : gosub lcd_write_CMD : dat = sx : gosub lcd_write_dat  'Horizontal start RAM address position 
    cmd = $0046 : gosub lcd_write_CMD : dat = ex : gosub lcd_write_dat   ' Horizontal end RAM address position
    cmd = $0022 : gosub lcd_write_CMD     'RAM data write/read
    x = ex - sx + 1
    y = ey - sy + 1
    dat = color
    for j = 0 to y
        for i = 0 to x
        gosub lcd_write_dat
        next i
    next j
    return
    
    '******************************************************************************
    '  Need cx (center x), cy (center y), rad (radius) and Color
    '
    '******************************************************************************
    
    '******************************************************************************
    '    need  x, y, color
    '
    '******************************************************************************
    Setdot:
    cmd = $004E : gosub lcd_write_CMD : dat = x : gosub lcd_write_dat  ' RAM Addsress counter set X
    cmd = $004F : gosub lcd_write_CMD : dat = y : gosub lcd_write_dat  ' RAM Addsress counter set Y
    cmd = $0022 : gosub lcd_write_CMD 
    dat = color
    gosub lcd_write_dat
    
    return
    
    ' ***** Set x,y Points *****
    set8:
    	x = glc_x+glc_cx : y=glc_y+glc_cy	        '1
    	gosub setdot
    	x = glc_cx-glc_x : y=glc_y+glc_cy		'2	
    	gosub setdot
    	x = glc_cx+glc_x : y=glc_cy-glc_y		'3	
    	gosub setdot
    	x = glc_cx-glc_x : y=glc_cy-glc_y		'4	
    	gosub setdot
    	x = glc_y+glc_cx : y=glc_x+glc_cy		'5
    	gosub setdot			
    	x = glc_cx-glc_y : y=glc_cy+glc_x		'6	
    	gosub setdot
    	x = glc_cx+glc_y : y=glc_cy-glc_x		'7	
    	gosub setdot
    	x = glc_cx-glc_y : y=glc_cy-glc_x		'8	
    	gosub setdot
    return
    
    '*** gl_circle d = diameter r = radius x,y are point locations ***
    '***** Given Center = glc_cx,glc_cy and Radius = glc_r **********
    gl_circ:
      glc_x = 0
      glc_y = glc_r
      glc_s = gl_pi-2*glc_r
      
    
      while (glc_x <= glc_y) 
     
          gosub set8
    
    	if (glc_s.15 =1) then
               glc_s = glc_s + (4*glc_x + 6)
             else
               glc_s = glc_s + (4*(glc_x-glc_y) + 10)
               glc_y = glc_y - 1
    	endif
    
    	glc_x = glc_x + 1
      wend
    
    return
    'Rectangle subroutine given gl_x1,gl_x2,gl_y1, gl_y2
    gl_rect:
    
            gosub chk_xy         
    	for gl_i= gl_x1 to gl_x2 step 1
    		x = gl_i
    		y = gl_y1
    		gosub setdot
    	        y = gl_y2
    		gosub setdot
    	next gl_i
    
    	for gl_i= gl_y1 to gl_y2 step 1
    		y = gl_i
    		x = gl_x1
    		gosub setdot
    		x = gl_x2
    		gosub setdot
    	next gl_i
    
    return
    
    chk_xy:
    	if gl_x1 > gl_x2 then
    		swap gl_x1,gl_x2
            endif
    	if gl_y1 > gl_y2 then
    		swap gl_y1,gl_y2
            endif
    return
    
    
    
    '*******************************************************************************
    '           Text
    '*******************************************************************************
    stringout2:		
    lcdy = row
    Readcode addr, char : 
    If char = 0 then return 
    
    gosub putclcdtext : 
    addr = addr + 1 : 
    lcdx = lcdx + 1 : 
    
    lcdy = row 
    
    goto stringout2
    
    
    putclcdtext:	
    if char < 20 then return
     if char > $7f then return
     
     for char_row = 0 to 4
         if char < $50 then
            charpos  = (((char & $ff)- $20)*5)
            gosub table1
            
         endif
    
         if char > $4f then
            charpos  = (((char & $ff)- $50)*5)
            gosub table2
          endif 
    
    next char_row
    if big = 0 then      ' Normal 5x7 font
        for j = 0 to 7   ' data bits 0 - 7
                    
                	cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat  ' RAM Addsress counter set X
                    cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat  ' RAM Addsress counter set Y    
        
                       
            for k = 1 to 5
        
        	        dat = fcolor
                    temp = chardata[k]
                    if temp.0[j] = 0 then 
                        dat = bcolor
                    endif
                    cmd = $0022 : gosub lcd_write_CMD 
                    gosub lcd_write_dat
        	next k
        	dat = bcolor
            gosub lcd_write_dat
            lcdy = lcdy + 1
        
        next j 
        lcdx = lcdx + 6
        
    
    elseif big = 1 then      ' big 10x14 font
        for j = 0 to 7   ' data bits 0 - 7
        for n = 0 to 1
                     
                	cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat  ' RAM Addsress counter set X
                    cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat  ' RAM Addsress counter set Y    
        
        
            for k = 1 to 5
            for m = 0 to 1    
        	        dat = fcolor
                    temp = chardata[k]
                    if temp.0[j] = 0 then 
                        dat = bcolor
                    endif
                    cmd = $0022 : gosub lcd_write_CMD 
                    gosub lcd_write_dat
        	next m
            next k
        	
            dat = bcolor
            gosub lcd_write_dat
            lcdy = lcdy + 1
        next n
        next j 
        lcdx = lcdx + 10       '20X24
    elseif big = 2   then
        for j = 0 to 7   ' data bits 0 - 7
        for n = 0 to 3
                     
                	cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat  ' RAM Addsress counter set X
                    cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat  ' RAM Addsress counter set Y    
        
        
            for k = 1 to 5
            for m = 0 to 3    
        	        dat = fcolor
                    temp = chardata[k]
                    if temp.0[j] = 0 then 
                        dat = bcolor
                    endif
                    cmd = $0022 : gosub lcd_write_CMD 
                    gosub lcd_write_dat
        	next m
            next k
        	
            dat = bcolor
            gosub lcd_write_dat
            lcdy = lcdy + 1
        next n
        next j 
        lcdx = lcdx + 24
    
    endif
    return
    
    '=================
    'FONT SAMPLE 5x7
    '=================
    
    Table1:
    lu1 = charpos + char_row
    
    lookup lu1, [0,0,0,0,0,_             'space
                $00,$00,$5f,$00,$00,_	'// 21 !
    			$00,$07,$00,$07,$00,_	' 22 "
    			$14,$7f,$14,$7f,$14,_	 ' 23 #
    			$24,$2a,$7f,$2a,$12,_	 ' 24 $
    			$23,$13,$08,$64,$62,_	'  25%
    			$36,$49,$55,$22,$50,_	 ' 26 &
    			$00,$05,$03,$00,$00,_	 ' 27 '
    			$00,$1c,$22,$41,$00,_	 ' 28 (
    			$00,$41,$22,$1c,$00,_	 ' 29 )
    			$14,$08,$3e,$08,$14,_	 ' 2a *
    			$08,$08,$3e,$08,$08,_	 ' 2b +
    			$00,$50,$30,$00,$00,_	 ' 2c ,
    			$08,$08,$08,$08,$08,_	 ' 2d -
    			$00,$60,$60,$00,$00,_	 ' 2e .
    			$20,$10,$08,$04,$02,_	 ' 2f /
    			$3e,$51,$49,$45,$3e,_	 ' 30 0
    			$00,$42,$7f,$40,$00,_	 ' 31 1
    			$42,$61,$51,$49,$46,_    ' 32 2
    			$21,$41,$45,$4b,$31,_    ' 33 3
    			$18,$14,$12,$7f,$10,_    ' 34 4
    			$27,$45,$45,$45,$39,_    ' 35 5
    			$3c,$4a,$49,$49,$30,_    ' 36 6
    			$01,$71,$09,$05,$03,_    ' 37 7
    			$36,$49,$49,$49,$36,_    ' 38 8
    			$06,$49,$49,$29,$1e,_	'// 39 9
    			$00,$36,$36,$00,$00,_	'// 3a :
    			$00,$56,$36,$00,$00,_	'// 3b ;
    			$08,$14,$22,$41,$00,_	'// 3c <
    			$14,$14,$14,$14,$14,_	'// 3d =
    			$00,$41,$22,$14,$08,_	'// 3e >
    			$02,$01,$51,$09,$06,_	'// 3f ?
    			$32,$49,$79,$41,$3e,_	'// 40 @
    			$7e,$11,$11,$11,$7e,_	'// 41 A
    			$7f,$49,$49,$49,$36,_	'// 42 B
    			$3e,$41,$41,$41,$22,_	'// 43 C
                $7f,$41,$41,$22,$1c,_	'// 44 D
    			$7f,$49,$49,$49,$41,_	'// 45 E
    			$7f,$09,$09,$09,$01,_	'// 46 F
    			$3e,$41,$49,$49,$7a,_	''// 47 G
    			$7f,$08,$08,$08,$7f,_	'// 48 H
    			$00,$41,$7f,$41,$00,_	'// 49 I
    			$20,$40,$41,$3f,$01,_	'// 4a J
    			$7f,$08,$14,$22,$41,_	'// 4b K
    			$7f,$40,$40,$40,$40,_	'// 4c L
    			$7f,$02,$0c,$02,$7f,_	'// 4d M
    			$7f,$04,$08,$10,$7f,_	'// 4e N
    			$3e,$41,$41,$41,$3e],temp	'// 4f O
    chardata[char_row + 1] = temp
    
    
    Return
    
    Table2:
    lu1 = charpos + char_row
    
    lookup lu1, [$7f,$09,$09,$09,$06,_	'// 50 P
                $3e,$41,$51,$21,$5e,_	'// 51 Q
    			$7f,$09,$19,$29,$46,_	'// 52 R
    			$46,$49,$49,$49,$31,_	'// 53 S
    			$01,$01,$7f,$01,$01,_	'// 54 T
    			$3f,$40,$40,$40,$3f,_	'// 55 U
    			$1f,$20,$40,$20,$1f,_	'// 56 V
    			$3f,$40,$38,$40,$3f,_	'// 57 W
    			$63,$14,$08,$14,$63,_	'// 58 X
    			$07,$08,$70,$08,$07,_	'// 59 Y
    			$61,$51,$49,$45,$43,_	'// 5a Z
    			$00,$7f,$41,$41,$00,_	'// 5b [
    			$02,$04,$08,$10,$20,_	'// 5c
    			$00,$41,$41,$7f,$00,_	'// 5d
    			$04,$02,$01,$02,$04,_	'// 5e
    			$40,$40,$40,$40,$40,_	'// 5f
    			$00,$01,$02,$04,$00,_	'// 60
    			$20,$54,$54,$54,$78,_	'// 61 a
    			$7f,$48,$44,$44,$38,_	'// 62 b
    			$38,$44,$44,$44,$20,_	'// 63 c
    			$38,$44,$44,$48,$7f,_	'// 64 d
    			$38,$54,$54,$54,$18,_	'// 65 e
    			$08,$7e,$09,$01,$02,_	'// 66 f
    			$0c,$52,$52,$52,$3e,_	'// 67 g
    			$7f,$08,$04,$04,$78,_	'// 68 h
    			$00,$44,$7d,$40,$00,_	'// 69 i
    			$20,$40,$44,$3d,$00,_	'// 6a j 
    			$7f,$10,$28,$44,$00,_	'// 6b k
    			$00,$41,$7f,$40,$00,_	'// 6c l
    			$7c,$04,$18,$04,$78,_	'// 6d m
    			$7c,$08,$04,$04,$78,_	'// 6e n
    			$38,$44,$44,$44,$38,_	'// 6f o
    			$7c,$14,$14,$14,$08,_	'// 70 p
    			$08,$14,$14,$18,$7c,_	'// 71 q
    			$7c,$08,$04,$04,$08,_	'// 72 r
    			$48,$54,$54,$54,$20,_	'// 73 s
    			$04,$3f,$44,$40,$20,_	'// 74 t
    			$3c,$40,$40,$20,$7c,_	'// 75 u
    			$1c,$20,$40,$20,$1c,_	'// 76 v
    			$3c,$40,$30,$40,$3c,_	'// 77 w
    			$44,$28,$10,$28,$44,_	'// 78 x
    			$0c,$50,$50,$50,$3c,_	'// 79 y
    			$44,$64,$54,$4c,$44,_	'// 7a z
    			$00,$08,$36,$41,$00,_	'// 7b
    			$00,$00,$7f,$00,$00,_	'// 7c
    			$00,$41,$36,$08,$00,_	'// 7d
    			$10,$08,$08,$10,$08,_	'// 7e
    			$78,$46,$41,$46,$78], temp '	// 7f
    chardata[char_row + 1] = temp
    
    
    Return  
    '******************************************************************************
    
    Print_Number:    ' need lcd_x , lcd_y , number, len, 
         temp5 = lcdy
       for i = len to 0 step -1
       char = number dig i  + 48
       gosub putclcdtext
       lcdy = temp5
        next i
    
    return
    '*******************************************************************************
    
    ProgramStart: 
     gosub lcd_init
     gosub lcd_home
     gosub clr_disp
    
    bcolor = white
    fcolor = black
    @ printstr2 25,20, "SSD2119 Controller"
    @ printstr2 25,28, "Dave Cutliff "
    @ printstr2 25,36, "TFT Color LCD Model Rev 1.0"
    @ printstr2 25,44, "320xRGBx240"
    @ printstr2 25,60, "PicBasic Pro6.0 "
    @ printstr2 25,68, "Sept 8,2010"
    'gosub ts_init
    pause 2000
    gosub lcd_home
    gosub clr_disp
    Gosub FSInit
         
    @ printstr2 25,20, "INT: "
               
            lcdx = 50
            lcdy = 20
            len = 1
            number = FAT_error 
            gosub print_number    
                
             lcdx = 80
            lcdy = 20
            len = 2
            number = SDC_status 
            gosub print_number           
    
             lcdx = 120
            lcdy = 20
            len = 2
            number =  SDC_response 
            gosub print_number           
      	
        
    If (FAT_error != 0) Then Stop
    
    	 'Display card directory
            lcdx = 50
            row = 70
        filenum = 1
    Gosub FINDfirst		' Find first file on card
    	While (FAT_error = 0)
           ' number of char = 11
            for b = 0 to 10
     
                
                select case filenum
                    case 1
                         for c = 0 to 10
                         file1[c] =  FAT_FileName[c]
                         next c
                    case 2
                         for c = 0 to 10
                         file2[c] =  FAT_FileName[c]
                         next c        
                    case 3
                         for c = 0 to 10
                         file3[c] =  FAT_FileName[c]
                         next c        
                    case 4
                         for c = 0 to 10
                         file4[c] =  FAT_FileName[c]
                         next c        
                    
                    case 5
                         for c = 0 to 10
                         file5[c] =  FAT_FileName[c]
                         next c        
                end select
                
            next b
    	                 lcdx = 50
                         for c = 0 to 10
                         char = FAT_FileName[c]
                         lcdy = row
                         gosub putclcdtext
                         next c
                         lcdy = row
    
                         
          	Gosub FINDnext	' Find next file on card
    
             filenum = filenum + 1
    	     row = row + 10
        Wend
        filenum = filenum - 1      'number of file on card
    
    pause 2000
    ImageLoop:
    for p = 1 to filenum   
         select case p
                    case 1
                         for c = 0 to 10
                         FAT_FileName[c] = file1[c]  
                         next c
                    case 2
                         for c = 0 to 10
                         FAT_FileName[c] = file2[c]
                         next c        
                    case 3
                         for c = 0 to 10
                         FAT_FileName[c] = file3[c]
                         next c         
                    case 4
                         for c = 0 to 10
                         FAT_FileName[c] = file4[c]
                         next c        
                    
                    case 5
                         for c = 0 to 10
                         FAT_FileName[c] = file5[c]
                         next c      
          end select
        
        ' Open a file for read
        FAT_mode = "r"		' Read mode
        Gosub FSfopen		' Open file pointed to by Byte array FAT_FileName
        
        If (FAT_error != 0) Then Stop
    
    
        ' Read and display the whole file
        FAT_count = 512	' Read 512 byte to buffer at a time
        gosub clr_disp
        gosub  lcd_home
        lcdx = 0
        lcdy = 0
        x = 0
        cnt = 0
        rgb = 0
        first = 0
        gl_x = 0
        gl_y = 240
    
        Gosub FSfread
       if first = 0 then
          cnt = fat_dest[$0A]         'read where data starts
          first = 1
       else
           cnt = 0
       endif
       
    While (FAT_error = 0)
        While cnt < 512
              
                 
    
                    tmp_color = 0
                    tmp1_color = 0
                    select case rgb
                    case 0 
                     tmp_color = fat_dest[cnt]>>3
                     dat = tmp_color
                     k =k + 1
                    case 1
                     tmp_color = fat_dest[cnt]>>2
                     tmp1_color = tmp_color<< 5
                     dat = dat + tmp1_color
                     k =k + 1
                    case 2 
                     tmp_color = fat_dest[cnt]>>3
                     tmp1_color = tmp_color<< 11
                     color = dat + tmp1_color
                     
            
                    end select 
                    cnt = cnt + 1 
                    rgb = rgb + 1
                 if rgb = 3 then
                     y =  gl_y
                     gosub setdot
                     color = 0
                     x = x + 1
                     rgb = 0
                     if x >= 320 then
                         x = 0
                         gl_y = gl_y - 1
                     endif
                 endif
              wend 
    
            FAT_count = 512	' Read 512 byte to buffer at a time
        	cnt = 0
            Gosub FSfread
    Wend
            pause 5000
            pause 5000
    next p
    goto imageloop
    
    
    
    Loop1:
    ' gosub DoUSBIn
    '  gosub DoUSBOut
    goto loop1

  22. #22
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

  23. #23
    Join Date
    Oct 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    Thanks for sharing your code.
    The only thing that's not clear to me how do you have the PS3,PS2,PS1,PS1 jumper on the back of the board.

  24. #24


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Edje11 View Post
    Hi Dave,

    Thanks for sharing your code.
    The only thing that's not clear to me how do you have the PS3,PS2,PS1,PS1 jumper on the back of the board.
    Hello,

    See post number 9 in this thread. Dave's program uses the 8bit mode. Solder jumpers PS2
    and PS3, remove solder from PS0 and PS1.

    I received my display Monday. It came with PS0, PS2 and PS3 soldered, which is the 16bit mode.

    With out a data sheet its a bit confusing at first. Unsoldered = 1 and soldered = 0, its because they use pull-up resistors.

    Mark

  25. #25
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mark_s View Post

    With out a data sheet its a bit confusing at first. Unsoldered = 1 and soldered = 0, its because they use pull-up resistors.

    Mark
    Here it goes. This is the datasheet for the SSD2119 controller, which is what this display uses. The right PS combination is on page 28.

    http://www.crystalfontz.com/controllers/SSD2119.pdf
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  26. #26
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Also be sure you make the chip select for the touch screen controller high. If you leave it floating the SD card reader may not work (hard lesson learned ;-)

    If you guys make something cool be sure to show us.

    Take care

    Dave

  27. #27


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rsocor01 View Post
    Here it goes. This is the datasheet for the SSD2119 controller, which is what this display uses. The right PS combination is on page 28.

    http://www.crystalfontz.com/controllers/SSD2119.pdf
    Thanks Robert,

    I have the controller data sheet, I ment data for the development board. It does not come with any schematics or info. But the pcb is clearly silk screened. It has a lot of features for the money. DC to DC converter for vlcd, touch screen controller, SD card socket, pads for eeprom expansion. The best part, is you don't have to deal with the 0.5mm FFC cable connections.

    @Dave,

    Have not fired it up yet, need to change my pcb to 3.3v. Will report back when I get it
    going with an interesting app.

    Thanks

  28. #28
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    You can get the schematic and other data here http://cgi.ebay.com/3-5-TFT-LCD-Modu...ts_Supplies_ET

    Scroll down to the "Download"

    If you have any trouble finding it let me know and I will send it to you.

    Dave

  29. #29


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DaveC3 View Post
    You can get the schematic and other data here http://cgi.ebay.com/3-5-TFT-LCD-Modu...ts_Supplies_ET

    Scroll down to the "Download"

    If you have any trouble finding it let me know and I will send it to you.

    Dave
    Dave,

    Thanks for the info! That guy is selling them for almost double. I ordered a second one for $35 in case that seller raises his prices or runs out. You can't build this for under a $100 in small quantities. Display $54 (Crystalfontz), PCBs $59 (expressPCB), chips, connectors etc. Unreal!

  30. #30
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Yes, it is a real deal at $35 including shipping if you are willing to wait the two weeks delivery. For me it was well worth the wait. They have other displays even cheaper.

    Dave

  31. #31
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    I agree also, its semms a steal. I ordered 3, received them all in good order and time. now to find a project for them, hmm....
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  32. #32
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    Anyone done anything with this LCD yet? Mine is getting dust.

    Ioannis

  33. #33
    Join Date
    Oct 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    I did something with it, only with an avr and Bascom.
    http://evertdekker.com/Joomla/index....d=77&Itemid=84
    Shouldn't to hard to port to pic

  34. #34
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    I left all 3 in the nice bubble wrap so the dust is staying off. Actually I would love to just get 1 wired up to even start playing. But so far that has not happened. Maybe we need a workshop thread for this thing. Maybe something like an agreed upon uP and bunches of shared knowledge?

    Not gonna lie here, really just am not sure where to start with the beast. I guess uP would be a pretty good place to start.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  35. #35
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    I feel the same for the LCD. Big with many connections, don't know where to start either.

    Also the 3.3 is also setting me back. Would be my first on 3,3 Volts.

    Ioannis

  36. #36
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Thumbs up Re: 3.5" Color LCD code example

    Wow, very interesting.

    I'm a flight sim enthusiast and plan on building a panel, soon. I'm still debating between using a full size LCD monitor with an overlay panel, or going with multiple small LCDs.

    The nice thing with the monitor is that you can get a 19" for under $100 and can have several instrument displays on it; more economical than small LCDs at current prices. And the monitor can be driven directly from the PC at HD quality graphics.

    Example panel; a 19" monitor on the left could extend under the 3 smaller dials and a 15" monitor would be sufficient on the right:



    As much as I'd love to PIC-my-ride, it's still not cost-efficient yet.
    Last edited by Demon; - 11th May 2011 at 16:01.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  37. #37
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    Hi, Thanks heaps
    If I do look into a gfx LCD I'll probably begin with this one.

    The circle drawing routine needs to check if the value for radius is less than 3.
    If it is allowed to draw the circle too small it messes up the display,
    and also addresses the screen buffer out of bounds, potentially crashing
    if either you or the display software isn't checking bounds.

  38. #38
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    Wow! This thing is HUGE!

    Is anyone here that can compile and run this demo currently?
    Since I stole the circles, it's only fair that I put back diagonal lines
    I think it's a very simple mod on what's in my small LCD code.
    The screen coords need to be words instead of bytes,
    and the midpoint adjusted for words, but it is already unsigned integer math.

  39. #39
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    Art

    Are you referring to the clock project I posted in 2011. If so, yes it is big, I have not played with it for a while. Most of my project have no long term purpose. I tinker with things just to see if I can do it. It compiled and ran fine on a 18F4550.


    take care

    Dave

  40. #40
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: 3.5" Color LCD code example

    Hi Dave,
    You haven't called it a clock:
    Code:
    @ printstr2 25,20, "SSD2119 Controller"
    @ printstr2 25,28, "Dave Cutliff "
    @ printstr2 25,36, "TFT Color LCD Model Rev 1.0"
    @ printstr2 25,44, "320xRGBx240"
    @ printstr2 25,60, "PicBasic Pro6.0 "
    @ printstr2 25,68, "Sept 8,2010"
    It looks like a general demo how to talk to the LCD,
    and SD Card, etc. (Quite a head start)
    nor do I see any clock code or line draw routines
    but I do see circles and straight lines for rectangles.
    I assumed you ran into the same problem with integer math,
    because normally the diagonal lines come first, then other 2D routines.

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts