Shop OBEX P1 Docs P2 Docs Learn Events
2.4" 320x240 TFT Prop based display module — Parallax Forums

2.4" 320x240 TFT Prop based display module

RaymanRayman Posts: 14,665
edited 2013-03-17 12:36 in Propeller 1
Just got my first photo loaded up on my prototype module...
It really looks good!· Check out this photo:
1093 x 649 - 226K
«1

Comments

  • nicolad76nicolad76 Posts: 164
    edited 2009-02-05 21:54
    it looks great...what module is that?
  • RaymanRayman Posts: 14,665
    edited 2009-02-06 00:08
    Do you mean the TFT? It's your basic cell phone display with ILI9325 driver...
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-02-06 05:04
    So tell us more about the guts on the other side. Are you basically taking in data over USB and outputting it to the display? Or do you have a clever external ram mechanism for a display buffer?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
    www.tdswieter.com
  • BaggersBaggers Posts: 3,019
    edited 2009-02-06 09:04
    Looks great Rayman, fill us in on details [noparse]:D[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • BeanBean Posts: 8,129
    edited 2009-02-06 12:28
    Very Cool !!!

    What is the display ? How much do they cost ? Is it NTSC/PAL, VGA or something custom ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-02-06 13:10
    It certainly looks custom with the circuit board on the back. Soon Brilldea will have a LCD and driver board that has a TV input, but I don't think this is what Rayman is using.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
    www.tdswieter.com
  • RaymanRayman Posts: 14,665
    edited 2009-02-06 13:40
    I posted a photo of the other side of this board a few days ago here:

    http://forums.parallax.com/showthread.php?p=779876

    Not much there...· Just Prop chip, uSD, FTDI USB, 3.3V regulator...

    But there's plenty of room for other stuff.

    The picture was sent over the USB interface, but soon I'll add support for SD card...

    I picked this display because of the 16-bit interface that should allow fast frame rates.··· But, it also has an 8-bit mode that would free up 8 pins for GPIO.

    I'm thinking about modifying the standard TV and VGA drivers to display on this screen instead.· Or, it could just be used as a serial controlled device.

    I'm leaning toward replacing the uSD with a full size SD socket.· I think there's enough room for that.

    I think this thing could be sold for $50.· But, I'm not sure I'm the one to do it [noparse]:)[/noparse]
  • BaggersBaggers Posts: 3,019
    edited 2009-02-06 13:51
    Cool Ray [noparse]:)[/noparse] didn't realise that your first SMT was on the back of a 320x240 LCD [noparse]:)[/noparse] makes it even cooler [noparse]:)[/noparse]
    How much was the display, and where from?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • RaymanRayman Posts: 14,665
    edited 2009-02-06 15:11
    I'd rather not promote my particular source at the moment... Besides, I'm leaning towards switching to a different one with integrated touch screen...
  • BaggersBaggers Posts: 3,019
    edited 2009-02-06 15:54
    ah, right ok [noparse]:D[/noparse] no worries

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • RaymanRayman Posts: 14,665
    edited 2009-02-07 12:22
    But, if you look closely at the picture, you can see the part#...· It's TM240320...
  • BaggersBaggers Posts: 3,019
    edited 2009-02-07 17:42
    yeah, only get a few chinese sites with them on [noparse]:([/noparse]
    know of any decent supplier?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • RaymanRayman Posts: 14,665
    edited 2009-02-08 00:40
    It looks like I can get a touchscreen version for $5 more. Seems well worth it... Then, you can have a total system on one board...

    Post Edited (Rayman) : 2/9/2009 2:06:53 AM GMT
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-02-08 06:17
    I was thinking about this setup. If the Prop is only used to take data from one point and put it on the display, then this is almost like a digital picture frame. In that case I can find displays here in Hong Kong and China that we can use and offer to the group. Also I have some leads on OLED displays. The thing I wish for is more RAM in the Prop so we can also generate graphics, but for displaying picture from an SD card or USB or Ethernet or wireless interface, the setup Rayman has would work well.

    I suppose some creative effort could be done to make a user interface that copies a picture from an SD card, on to the screen, and then copies specific text or indicators on in the display as well. There would have to be some sort of transparency or something in the processing.

    Rayman, did you have a particular application in mind when you created this or just seeing what you can do? Thanks for the inspiration.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
    www.tdswieter.com
  • BaggersBaggers Posts: 3,019
    edited 2009-02-08 10:06
    Rayman, let us know when and where you get your new touchscreen version of it, I'm looking forward to having a play with this one [noparse]:D[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • RaymanRayman Posts: 14,665
    edited 2009-02-09 01:50
    What I have in mind is something like what Primer did for the SMT32... A little, self-contained development platform. But, I'm also aiming it to have a practical side too... So, that it could either be a super-charged display module, or the actual controller for applicaitons.

    I could really use a 64-IO-pin Prop here! I'm leaning towards adding an I2C I/O expander to make up for the lack of pins...

    May be forced to drop back to 8-bit interface to free up 8 pins...

    Right now, I've modified the standard VGA driver to work with the display. Able to do a full screen update in just a few milliseconds. I'm aiming towards replicating the Graphics Demo (but better) on this LCD.
    For compatibility with the usual TV/VGA apps, I'm going to replace the color scheme with an 8-bit CLUT. So, there'll be a CLUT for VGA and another for TV. This way, existing code and concepts can be easily ported back and forth...
    But, a full range of colors will be possible.

    Post Edited (Rayman) : 2/9/2009 2:08:13 AM GMT
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-11-15 17:11
    Hi Rayman,

    The prices of these displays seems to be coming down - $16 including the touch screen http://www.ebay.com.au/itm/170709358010?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649 . The ILI9325 seems a standard driver for many displays.

    These displays are now cheaper than a LCD TV screen, and then if you can replace a mouse with a touch screen that saves even more. And obviously, the display has more colors than the prop. Plus this sort of display frees up hub ram that one might be using as a graphics buffer.

    Re that ebay display, it looks like the SD card connections come to the header so if one were building a propeller board, that would save buying an SD socket and soldering it in. Need to think about the touch screen pins - ? input directly into the prop or ? via a SPI or I2C A to D?

    I am interested in your comments on 8 vs 16 bit comms. I've ended up using propeller pins P16-P23 for displays - TV, VGA, serial displays and now, hopefully, this display.

    Do you have any code you might be able to share?
  • RaymanRayman Posts: 14,665
    edited 2011-11-15 17:58
    My PSM code is posted on my website and I'm sure in this forum too somewhere...
    I have plans for a PSM2, but I keep finding other distractions...
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-11-15 18:53
    Thanks Rayman - I'll check out your website :)
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-11-15 19:58
    @Dr A:

    Good Find!

    http://www.ebay.com/itm/170709358010?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649#ht_6075wt_874

    I couldn't resist grabbing one of these! We should be doing something like this with the prop.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-11-15 21:01
    I agree OBC. I think these displays could be the missing link that can take a command line OS like Kyedos to a GUI where you tap an icon to run a program. ILI9325 datasheet http://www.adafruit.com/datasheets/ILI9325.pdf

    I am very excited about all this!

    Addit: Links to two more board suppliers that appear to be using the same 40 pin format. Hopefully this is a 'standard'

    http://www.ebay.com.au/itm/2-4-TFT-LCD-Display-Touch-Panel-PCB-adapter-Module-/260765262794?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3cb6d223ca

    http://www.ebay.com.au/itm/2-4-TFT-LCD-Module-Display-Touch-Panel-PCB-adapter-/190477028273?pt=LH_DefaultDomain_0&hash=item2c5950cbb1

    Some are using micro SD and some are using standard sized SD. So that adds some flexibility.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-11-16 02:13
    More information. Attached is the schematic for these boards. It appears they have a SD card, 16 megabit flash ram and an A to D converter.

    I'm not 100% sure of the sd card as there are series resistors and my understanding is these need pullups, not series resistors and I've seen pullup values of 10k and so if you use a series resistor of 10k as well, I think that works but I'm not sure.

    The flash ram could be useful for storing data. Though if you already have an SD card, maybe not.

    The A to D is very useful. I think it uses 6 pins, not 4, but I am not entirely sure what the "busy" line does, so maybe it is 5. The datasheet is here http://www.ti.com/lit/ds/symlink/ads7843.pdf

    So - thinking aloud, I'm not entirely sure of all the best possibilities. For Catalina and ?GCC that use caching, the speed of external ram does not matter so much. Say you have 2 pins for download, 2 for eeprom and 2 for keyboard (keyboard could still be useful). Mouse not needed. So 26 propeller pins free. 6 for the touchscreen leaves 20 pins free. 4 for SD card leaves 16. If you had 4 for SPI ram (32k microchip) then you only have 12 pins left - which might be just enough for an 8 bit data system.

    There are other solutions too. Say you took the dracblade format. P16-23 usually do TV or VGA, so those pins could do the touchscreen instead.

    4 pins for SD card, and there are 12 pins free on the dracblade running external memory and with a 138 decoder and latches there are free 138 latches one could use. So the data can be latched out to give 16 bit access to the display.

    And a third option - I believe the ILI9325 can be run in SPI mode. However I think you need to set some pins in a certain way to do that and I don't think those pins are brought out to the 40 pin header.

    This is some C driver code I found. I think what this may show is that the LCD_RD function is never used which means you only write to this device, and that ought to simplify interfacing. I believe this would use 8+8+4 lines.
    [code]
    #include <reg51.h>

    /* http://ttmcu.taobao.com
    952 x 510 - 60K
  • mynet43mynet43 Posts: 644
    edited 2011-11-21 06:21
    Question for you display people :)

    I'm using a very similar display 2.4" 240x320 color. By Newhaven Display.

    Have you done any power measurements on what you're using? I'm trying to use this in a battery powered device.

    I recently measured the current usage, and it seems to take around 50ma. There are 4 built-in backlight LED's that I'm driving from Prop pins.

    The 50ma is so high that it makes it almost unusable for a battery device.

    Do you have any suggestions for very-low-power displays with similar attributes?

    Thank you for your help.

    Jim
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-12-09 21:13
    Got a board soldered up and some colors on the display. Woot!

    I needed to modify the code. I'm using the Dracblade format and so pins 0-11 get shared for the display and for external ram. P16-P23 are for VGA/TV so I am going to use those for the touchscreen. P12-P15 are for the SD card and this display board has an sd card on it, so this saves making another Gadget Gangster board.

    Code is very messy and am doing this in Spin first which I translated from C. It means it should be easy to get C working, though ultimately a Pasm driver will be the best solution.

    Colors fit into 16 bits - 5 bits for red, 6 bits for green, 5 bits for blue.

    Re the question in the post above, the main current consumption is from the backlight. I used a 220 ohm resistor running from 5V and the backlight is a white led so maybe 20mA or less?

    The aim with all this is to have everything backwards compatible with all the Dracblade stuff, so you can still plug in a VGA monitor or a TV or this display.

    The Gadget Gangster board is a 138 chip and three 374 latches.

    Next challenge - get a picture off an SD card and onto this board. All great fun!

    Spin code with the original C code at the bottom.

    [code]
    '' ILI9325 driver using pins P0-P11 for the display and P16-P23 for the touchscreen
    '' James Moxham 2011

    CON


    _clkmode = xtal1 + pll16x ' use crystal x 16
    _xinfreq = 5_000_000


    OBJ
    delay : "timing"

    VAR
    long DisplayPins ' status of all the display pins

    PUB Start | i,j
    DisplayPins := %00000000_00000000_00000000_00000000 ' store the status of the display pins
    EnableLatchPins
    Latch7 ' RS/CS/WR/RD/RESET all low
    Init ' start up the driver
    'Pant($07,$E0)

    ChipSelectLow

    Address_set(40,40,40,140) ' fill up in this block x1,y1 to x2,y2
    repeat 100
    Lcd_Write_Data(%11111111,%11111111) ' white line


    Address_set(100,0,129,29) ' fill up in this block x1,y1 to x2,y2
    repeat 900
    Lcd_Write_Data(%11111000,%00000000)
    Address_set(140,0,169,29) ' fill up in this block x1,y1 to x2,y2
    repeat 900
    Lcd_Write_Data(%00000111,%11100000)

    Address_set(180,0,209,29) ' fill up in this block x1,y1 to x2,y2
    repeat 900
    Lcd_Write_Data(%00000000,%00011111)

    Address_set(0,0,29,29) ' fill up in this block x1,y1 to x2,y2
    repeat 900
    'Lcd_Write_Data(%00000111,%11100000) ' fills up this block with data bytes RRRRRGGGGGGBBBBB 5 red 6 green 5 blue
    Lcd_Write_Data(%11111111,%11111111) ' fills up this block with data bytes RRRRRGGGGGGBBBBB 5 red 6 green 5 blue

    Address_set(40,0,69,29) ' fill up in this block x1,y1 to x2,y2
    repeat 900
    Lcd_Write_Data(%11111111,%11100000)

    Address_set(100,100,131,150) ' fill up in this block x1,y1 to x2,y2
    i := 0
    repeat 50
    repeat 32
    Lcd_Write_Data(i,j)
    j := j+1
    j :=0
    ChipSelectHigh



    PRI Init ' see LCD.c program in c:\propeller\ILI9325\Updated c51 code
    ResetHigh
    delay.pause1ms(5)
    ResetLow
    delay.pause1ms(5)
    ResetHigh
    ChipSelectHigh
    ReadHigh
    WriteHigh
    delay.pause1ms(5)
    ChipSelectLow
    ' ************* Start Initial Sequence **********
    Lcd_Write_Com($00,$E5)
    Lcd_Write_Data($78,$F0) ' set SRAM internal timing
    Lcd_Write_Com($00,$01)
    Lcd_Write_Data($01,$00) ' set SS and SM bit
    Lcd_Write_Com($00,$02)
    Lcd_Write_Data($07,$00) ' set 1 line inversion
    Lcd_Write_Com($00,$03)
    Lcd_Write_Data($10,$30) ' set GRAM write direction and BGR=1.
    Lcd_Write_Com($00,$04)
    Lcd_Write_Data($00,$00) ' Resize register
    Lcd_Write_Com($00,$08)
    Lcd_Write_Data($02,$07) ' set the back porch and front porch
    Lcd_Write_Com($00,$09)
    Lcd_Write_Data($00,$00) ' set non-display area refresh cycle ISC[3:0]
    Lcd_Write_Com($00,$0A)
    Lcd_Write_Data($00,$00) ' FMARK function
    Lcd_Write_Com($00,$0C)
    Lcd_Write_Data($00,$00) ' RGB interface setting
    Lcd_Write_Com($00,$0D)
    Lcd_Write_Data($00,$00) ' Frame marker Position
    Lcd_Write_Com($00,$0F)
    Lcd_Write_Data($00,$00) ' RGB interface polarity
    ' *************Power On sequence ****************//
    Lcd_Write_Com($00,$10)
    Lcd_Write_Data($00,$00) ' SAP, BT[3:0], AP, DSTB, SLP, STB
    Lcd_Write_Com($00,$11)
    Lcd_Write_Data($00,$07) ' DC1[2:0], DC0[2:0], VC[2:0]
    Lcd_Write_Com($00,$12)
    Lcd_Write_Data($00,$00) ' VREG1OUT voltage
    Lcd_Write_Com($00,$13)
    Lcd_Write_Data($00,$00) ' VDV[4:0] for VCOM amplitude
    Lcd_Write_Com($00,$07)
    Lcd_Write_Data($00,$01)
    delay.pause1ms(50) ' Dis-charge capacitor power voltage
    Lcd_Write_Com($00,$10)
    Lcd_Write_Data($10,$90) ' 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
    Lcd_Write_Com($00,$11)
    Lcd_Write_Data($02,$27) ' DC1[2:0], DC0[2:0], VC[2:0]
    delay.pause1ms(50) ' delay
    Lcd_Write_Com($00,$12)
    Lcd_Write_Data($00,$1F) '001C// Internal reference voltage= Vci;
    delay.pause1ms(50) ' delay
    Lcd_Write_Com($00,$13)
    Lcd_Write_Data($15,$00) '$1000//1400 Set VDV[4:0] for VCOM amplitude 1A00
    Lcd_Write_Com($00,$29)
    Lcd_Write_Data($00,$27) '$0012 //001a Set VCM[5:0] for VCOMH //$0025 0034
    Lcd_Write_Com($00,$2B)
    Lcd_Write_Data($00,$0D) ' Set Frame Rate 000C
    delay.pause1ms(50) ' delay
    Lcd_Write_Com($00,$20)
    Lcd_Write_Data($00,$00) ' GRAM horizontal Address
    Lcd_Write_Com($00,$21)
    Lcd_Write_Data($00,$00) ' GRAM Vertical Address
    '
    Adjust the Gamma Curve
    //
    Lcd_Write_Com($00,$30)
    Lcd_Write_Data($00,$00)
    Lcd_Write_Com($00,$31)
    Lcd_Write_Data($07,$07)
    Lcd_Write_Com($00,$32)
    Lcd_Write_Data($03,$07)
    Lcd_Write_Com($00,$35)
    Lcd_Write_Data($02,$00)
    Lcd_Write_Com($00,$36)
    Lcd_Write_Data($00,$08) '//0207
    Lcd_Write_Com($00,$37)
    Lcd_Write_Data($00,$04) '//0306
    Lcd_Write_Com($00,$38)
    Lcd_Write_Data($00,$00) '//0102
    Lcd_Write_Com($00,$39)
    Lcd_Write_Data($07,$07) '//0707
    Lcd_Write_Com($00,$3C)
    Lcd_Write_Data($00,$02) '//0702
    Lcd_Write_Com($00,$3D)
    Lcd_Write_Data($1D,$04) '//1604
    '
    Set GRAM area
    //
    Lcd_Write_Com($00,$50)
    Lcd_Write_Data($00,$00) ' Horizontal GRAM Start Address
    Lcd_Write_Com($00,$51)
    Lcd_Write_Data($00,$EF) ' Horizontal GRAM End Address
    Lcd_Write_Com($00,$52)
    Lcd_Write_Data($00,$00) ' Vertical GRAM Start Address
    Lcd_Write_Com($00,$53)
    Lcd_Write_Data($01,$3F) ' Vertical GRAM Start Address
    Lcd_Write_Com($00,$60)
    Lcd_Write_Data($A7,$00) ' Gate Scan Line
    Lcd_Write_Com($00,$61)
    Lcd_Write_Data($00,$01) ' NDL,VLE, REV
    Lcd_Write_Com($00,$6A)
    Lcd_Write_Data($00,$00) ' set scrolling line
    '
    Partial Display Control
    /

    Lcd_Write_Com($00,$80)
    Lcd_Write_Data($00,$00)
    Lcd_Write_Com($00,$81)
    Lcd_Write_Data($00,$00)
    Lcd_Write_Com($00,$82)
    Lcd_Write_Data($00,$00)
    Lcd_Write_Com($00,$83)
    Lcd_Write_Data($00,$00)
    Lcd_Write_Com($00,$84)
    Lcd_Write_Data($00,$00)
    Lcd_Write_Com($00,$85)
    Lcd_Write_Data($00,$00)
    ' //
    Panel Control
    //
    Lcd_Write_Com($00,$90)
    Lcd_Write_Data($00,$10)
    Lcd_Write_Com($00,$92)
    Lcd_Write_Data($06,$00)
    Lcd_Write_Com($00,$07)
    Lcd_Write_Data($01,$33) ' 262K color and display ON

    ChipSelectHigh

    PRI LCD_Writ_Bus(VH,VL)
    Latch5(VL) ' send low byte
    Latch6(VH) ' send high byte
    WriteLow ' write pin low
    WriteHigh ' toggle write pin

    PRI Lcd_Write_Com(VH,VL)
    RSLow
    LCD_Writ_Bus(VH,VL)

    PRI Lcd_Write_Data(VH,VL)
    RSHigh
    LCD_Writ_Bus(VH,VL)


    PRI EnableLatchPins
    DIRA:=%00000000_00000000_00001111_11111111 ' 138 active, gate active and 8 data lines active
    PRI Tristate ' tristate all pins - needs a pullup on the 138 enable prop pin P8
    DIRA:=%00000000_00000000_00000000_00000000
    PRI ToggleGate
    OUTA[8]:=0 ' set gate pin low
    OUTA[8]:=1 ' and high again - may need a delay in PASM

    PRI Latch5(VL) ' send the low byte xxxx = C,B,A,enable
    VL := VL | %00000000_00000000_00001011_00000000 ' OR with the LCD address 101
    OUTA := VL ' 4 send it to propeller pins
    ToggleGate ' 5 and latch it to the latch

    PRI Latch6(VH) ' send the middle byte
    VH := VH | %00000000_00000000_00001101_00000000 ' 3 OR with the LCD address for latch 6 110
    OUTA := VH ' 4 send it to propeller pins
    ToggleGate ' 5 and latch it to the latch

    PRI Latch7 | i ' send the high byte if DisplayPins to the approprite latch
    i := DisplayPins ' get the value
    i := i >> 16 ' shift right by 16 places
    i := i & %11111111 ' mask the low byte
    i := i | %00000000_00000000_00001111_00000000 ' 3 OR with the LCD address for latch 7 111
    OUTA := i ' 4 send it to propeller pins
    ToggleGate ' 5 and latch it to the latch

    PRI RSLow ' RS pin
    DisplayPins := DisplayPins & %11111111_11111110_11111111_11111111 ' mask the reset pin to zero
    Latch7 ' send to the latch

    PRI RSHigh
    DisplayPins := DisplayPins | %00000000_00000001_00000000_00000000 ' mask the reset pin to 1
    Latch7 ' send to the latch

    PRI WriteLow
    DisplayPins := DisplayPins & %11111111_11111101_11111111_11111111 ' mask the reset pin to zero
    Latch7 ' send to the latch

    PRI WriteHigh
    DisplayPins := DisplayPins | %00000000_00000010_00000000_00000000 ' mask the reset pin to 1
    Latch7 ' send to the latch

    PRI ReadLow
    DisplayPins := DisplayPins & %11111111_11111011_11111111_11111111 ' mask the reset pin to zero
    Latch7 ' send to the latch

    PRI ReadHigh
    DisplayPins := DisplayPins | %00000000_00000100_00000000_00000000 ' mask the reset pin to 1
    Latch7

    PRI ChipSelectLow
    DisplayPins := DisplayPins & %11111111_11110111_11111111_11111111 ' mask the reset pin to zero
    Latch7 ' send to the latch

    PRI ChipSelectHigh
    DisplayPins := DisplayPins | %00000000_00001000_00000000_00000000 ' mask the reset pin to 1
    Latch7

    PRI ResetLow
    DisplayPins := DisplayPins & %11111111_11101111_11111111_11111111 ' mask the reset pin to zero
    Latch7 ' send to the latch

    PRI ResetHigh
    DisplayPins := DisplayPins | %00000000_00010000_00000000_00000000 ' mask the reset pin to 1
    Latch7

    PRI Address_set(x1, y1, x2, y2)
    Lcd_Write_Com($00,$20)
    Lcd_Write_Data(x1>>8,x1)
    Lcd_Write_Com($00,$21)
    Lcd_Write_Data(y1>>8,y1)
    Lcd_Write_Com($00,$50)
    Lcd_Write_Data(x1>>8,x1)
    Lcd_Write_Com($00,$52)
    Lcd_Write_Data(y1>>8,y1)
    Lcd_Write_Com($00,$51)
    Lcd_Write_Data(x2>>8,x2)
    Lcd_Write_Com($00,$53)
    Lcd_Write_Data(y2>>8,y2)
    Lcd_Write_Com($00,$22)

    PRI Pant(VH,VL)
    ChipSelectLow
    Address_set(0,0,240,320)
    Lcd_Write_Data(VH,VL)
    ChipSelectHigh


    {
    #include <reg51.h>

    /* http://ttmcu.taobao.com
    1024 x 768 - 84K
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-12-09 21:25
    Mine is here waiting for free time this weekend.

    Did you remove the resistor at R2 as Nick did here?
    (http://www.gadgetgangster.com/forums/viewtopic.php?f=3&t=20)

    OBC
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-12-09 21:36
    I'm running mine in 16 bit mode so the resistor stays. My code is a bit convoluted as I start out with 8 bits, send it out to two latches to make 16 bits plus another latch to do the wr/rd/reset/cs/rs lines so it is controlled with 21 pins. But I wanted to share the dracblade memory format so it only uses 12 propeller pins.

    It doesn't really matter as the code to translate the data and send it out the latches, vs the code to send it out directly, are very similar. So we can mix and match all sorts of options using different propeller pins and still work together on the project.

    This is the standard LCD_Writ_Bus routine which I modified:
    PRI LCD_Writ_Bus(VH,VL) 
        Latch5(VL)                                          ' send low byte
        Latch6(VH)                                          ' send high byte
        WriteLow                                            ' write pin low
        WriteHigh                                           ' toggle write pin
    

    Looks like GG and myself are now at a similar stage - get the touchscreen working.

    Then we can start playing around with reading icons off an sd card, drawing some icons on the screen, working out which one was pressed, and then chaining another binary program. Kyedos with a GUI instead of typing in the name.

    These displays are very nice. More colors than TV and VGA and they work out cheaper. Plus lots of memory now free in hub as no graphics buffer needed.

    We will probably need a pasm driver - it is a little slow in Spin. Need a routine to move data from an sd card into hub then to the display, probably in tiles ?64x64.

    And a routine to translate 256x256x256 colors into 16 bits RRRRRGGGGGBBBBB
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-12-10 23:04
    We have a picture!

    This display has an amazing resolution. The pixels are too small to see unless you look very closely. The color depth is 65k and I can't see any difference in the picture when I run a vb.net program to decrease the color depth from RRRRRRRRGGGGGGGGBBBBBBBB to RRRRRGGGGGGBBBBB

    Code to do this in vb.net. This displays to a 240x320 picture box, displays the modified picture and then saves a binary file.
      Private Sub Button67_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button67.Click
            Dim R, G, B As Long
            Dim Mycolor As Color
            Dim x, y, t As Integer
            Dim sizex, sizey As Integer
            ' load in the picture
            sizex = 240 - 1 '240x320 (portrait mode)
            sizey = 320 - 1
            Dim PixelArray(sizex, sizey, 5) As Double
            Dim Sourcefile, Destinationfile As String
            Sourcefile = TextBox98.Text
            ' this little bit of code replaces new sytem.drawing.bitmap as the latter leaves the file locked eg so paintshop can't save a new file
            Dim img As Image
            Dim fs As New FileStream(Sourcefile, IO.FileMode.Open)
            img = Image.FromStream(fs)
            fs.Close()
            PictureBox115.Image = img
            ' picture to array
            Dim MyBitmap As New System.Drawing.Bitmap(PictureBox115.Image) 'image from picture box
            For y = 0 To sizey
                For x = 0 To sizex
                    Mycolor = MyBitmap.GetPixel(x, y) ' get the color
                    PixelArray(x, y, 0) = (Int(Mycolor.R) >> 3) << 3 ' red byte 2^5 values
                    PixelArray(x, y, 1) = (Int(Mycolor.G) >> 2) << 2 ' green byte 2^6 values
                    PixelArray(x, y, 2) = (Int(Mycolor.B) >> 3) << 3 ' blue byte 2^5 values
                    ' RRRRRGGGGGGBBBBB
                    R = PixelArray(x, y, 0) >> 3 ' bit shifts
                    G = PixelArray(x, y, 1) >> 2
                    B = PixelArray(x, y, 2) >> 3
                    PixelArray(x, y, 3) = (R << 11) + (G << 5) + B
                    PixelArray(x, y, 4) = PixelArray(x, y, 3) >> 8 ' high byte
                    PixelArray(x, y, 5) = PixelArray(x, y, 3) And 255 ' low byte
                Next
            Next
            'display on a new picturebox
            For y = 0 To sizey
                For x = 0 To sizex
                    Mycolor = Color.FromArgb(255, PixelArray(x, y, 0), PixelArray(x, y, 1), PixelArray(x, y, 2))
                    MyBitmap.SetPixel(x, y, Mycolor) ' set the pixels back to this palette color
                Next x
            Next y
            PictureBox116.Image = MyBitmap ' display the picture after processing
            Dim OutputArray((sizex + 1) * (sizey + 1) * 2) As Byte ' 2 bytes stored
            t = 0
            For y = 0 To sizey
                For x = 0 To sizex
                    OutputArray(t) = PixelArray(x, y, 4) ' high byte
                    t += 1
                    OutputArray(t) = PixelArray(x, y, 5) ' low byte
                    t += 1
                Next
            Next
            Destinationfile = TextBox99.Text
            Dim OutputILI As New FileStream(Destinationfile, FileMode.Create, FileAccess.Write)
            OutputILI.Write(OutputArray, 0, (sizex + 1) * (sizey + 1) * 2) ' save bytes
            OutputILI.Close()
        End Sub
    

    I've bundled up a zip file with the source code and also this binary file. Copy it to an SD card. The code also uses a TV screen on pins 16-18 - this was very useful for debugging to make sure the SD card mounted and to see the first few bytes were correct.

    In the photo the stack of Gadget Gangster grows higher (though not as high as Humanoido's tower!). There is a key/mouse/TV/VGA board, a motherboard with a propeller, a switching regulator board, an external memory board and the ILI9325 board. Also in the picture is a diagnostic leds board with 30 leds for P0-P29 which was very useful for debugging.

    The Gadget Gangster format is proving very useful here as it is possible to mix and match boards in all sorts of ways. This was originally debugged on a standard USB Gadget Gangster board. Both the Gadget Gangster board and the ILI9325 touchscreen board have SD cards on them so there are many ways to get mass storage.

    Speed is an issue and this will be much better in pasm.

    I've attached my schematic - this uses a few extra chips so that it is backwards compatible with the Dracblade memory (and hence can run large C programs) but using propeller pins directly will obviously be simpler to wire up.

    The screenshot from the vb.net program shows the original bitmap and then after processing. I must say I can't tell the difference. This looks just as good on the real display - I have tried many photos but the camera has an autofocus and keeps giving blurry shots. 3 x 4 =12 icons on a screen works out about right for this display. Icons are 96x96 which is about finger size. I can post the binary for that icon picture if anyone wants this as it might be useful for testing the touchscreen.

    Having said all this, I'd really appreciate some help with the ADS7843 driver code. The examples (like the display examples) are in C but with comments all in Chinese so not the easiest to decode. I've taken their example code and stripped out the comments and all the display code and it comes in fairly short now. Some of the functions in 'main' have been deleted as I'm 99% certain these are display functions.
    #include <reg51.h>
    #include <intrins.h>
    
    
    #define Bus_16        
    #define  LCD_DataPortH P2     
    #define  LCD_DataPortL P0
    sbit LCD_RS = P3^5;  		 
    sbit LCD_WR = P3^6;		  
    sbit LCD_RD =P3^7;		     
    sbit LCD_CS=P1^0;			
    sbit LCD_REST = P1^2;	
    
    /* touch panel interface define */
    sbit DCLK	   =    P1^7;   
    sbit CS        =    P1^4;
    sbit DIN       =    P3^0;	
    sbit DOUT      =    P3^1;																			   
    sbit Penirq       =    P3^4;   
    unsigned int TP_X,TP_Y;	   
    
    //**********************************************************
    void spistar()
    {
    CS=1;
    DCLK=1;
    DIN=1;
    DCLK=1;
    }
    //**********************************************************
    void WriteCharTo7843(unsigned char num)          
    {
    unsigned char count=0;
    DCLK=0;
    for(count=0;count<8;count++)
    {
    num<<=1;
    DIN=CY;
    DCLK=0; _nop_();_nop_();_nop_();                
    DCLK=1; _nop_();_nop_();_nop_();
    }
    }
    //**********************************************************
    unsigned int ReadFromCharFrom7843()             
    {
    unsigned char count=0;
    unsigned int Num=0;
    for(count=0;count<12;count++)
    {
    Num<<=1;
    DCLK=1; _nop_();_nop_();_nop_();                
    DCLK=0; _nop_();_nop_();_nop_();
    if(DOUT) Num++;
    }
    return(Num);
    }
    
    void delayms(int count)  
    {
            int i,j;
            for(i=0;i<count;i++)
                    for(j=0;j<1000;j++);
    }
    
    void AD7843(void) {
     CS=0;
    WriteCharTo7843(0x90);        
    DCLK=1; _nop_();_nop_();_nop_();_nop_();
    DCLK=0; _nop_();_nop_();_nop_();_nop_();
    TP_Y=ReadFromCharFrom7843();
    WriteCharTo7843(0xD0); 
    DCLK=1; _nop_();_nop_();_nop_();_nop_();
    DCLK=0; _nop_();_nop_();_nop_();_nop_();
    TP_X=ReadFromCharFrom7843();
    CS=1;
    }
    
    main()
    {
    	unsigned char ss[6];	
    	unsigned int lx,ly;
    	spistar();  
    	while(1)
    	{	
    		if (Penirq==0)
    		{  	
    			AD7843();
    			lx=240-((TP_X-400)/13);
    			ly=320-((TP_Y-400)/10);
    		}
    		else
    		{
    		}
        }
    }
    

    The datasheet is here http://www.ti.com/lit/ds/symlink/ads7843.pdf

    I'm fairly sure this is a SPI type interface with a couple of extra pins.

    I don't know if anyone has written a Spin driver as yet.

    The code I don't understand is this sort of thing:
    DCLK=1; _nop_();_nop_();_nop_();_nop_();
    DCLK=0; _nop_();_nop_();_nop_();_nop_();
    

    where NOP seems to do nothing, and DCLK is a variable that changes. There was code like this in the display driver and I replaced it with spin that did things like change the status of DCLK. But in this code, it seems like in C you change the value of the clock pin, but how do you actually change that to a status change on the pin? Maybe it is a macro?

    And is the _nop_(); function actually doing anything or is it just a delay loop?

    I've been searching for the last hour or so for some driver code for this chip - any help here would be most appreciated.

    A quick note to myself - I'm searching with "ads7843 c code" at the moment for the touchscreen controller.

    We are so close here to a GUI for Kyedos!!!
    800 x 600 - 143K
    800 x 600 - 71K
    888 x 588 - 83K
    549 x 395 - 53K
    800 x 600 - 82K
  • Nick McClickNick McClick Posts: 1,003
    edited 2011-12-20 10:50
    I'm able to read from the touchscreen using Beau's SPI object;
    PUB main | yval, xval  
    SPI.start(3,0)
    'SPI read S, A2, A1, A0, Mode, SER, PD1, PD0
    '         1  0   0   1    1     0    0    0
    ' MSB first
    ' 001 is X
    ' 101 is Y
    repeat
      SPI.SHIFTOUT(19, 21, 5, 8 , %1101_0000)  ' reads y from  500 to 3700  (off < 500 )
      yval := SPI.SHIFTIN(17,21,2, 12)
    
      SPI.SHIFTOUT(19, 21, 5, 8 , %1001_0000)  ' reads x from 420 to 3800 (off > 3800 ) 
      xval := SPI.SHIFTIN(17,21,2, 12)
    

    The values seem to correspond to where I'm touching the screen. First bit is a start bit, A2,A1, And A0 set what axis you want to read. Mode is whether you want 8-bit or 12-bit resolution. SER further sets how you want the measurements returned. PD0 and PD1 are for the power down mode.

    Next thing is to roll this into the Spin version of the SPI object - I'd like the touchscreen to be read without needing another cog.
  • SarielSariel Posts: 182
    edited 2011-12-21 12:26
    Looks like we are all racing toward the same end here. I am using the same display as mynet43, and it is going along quite well. Just to play around a little bit and try to figure out how to work with real displays other than TV or the NewHaven 2x20's, I am able to have the "Little Dog" from the graphics demo crawling across the screen, and "Woof!" growing larger then snapping back to small size. Once I figure out color palates (really getting frustrated with the 4 color per tile thing), I will be able to go forward with my design, and stop all this playing around business.

    Currently, I am waiting on a batch of TSC2007IPW chips to come in with some proto boards for my touch screen. I seem to remember someone in the past having good luck with this and 4 wire resistive touch screens, and I remember archiving a driver they posted on the forums. (cannot remember who exactly it was, but thank you!)
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-12-28 05:30
    Next thing is to roll this into the Spin version of the SPI object - I'd like the touchscreen to be read without needing another cog.

    What would be the best combination regarding cogs? Combine with a SD SPI cog perhaps? That code does look fairly straightforward.

    The touchscreen and display parts are quite separate - different pins, different code, and almost certainly different cogs. The display would replace a TV or VGA object. The touchscreen would be a SPI object. The touchscreen would replace mouse and keyboard, so you can save some cogs there.

    These modules also have SD sockets on them - very handy too. I'm working on a board design that wires them straight through to propeller pins. The SD socket is also quite separate from a hardware perspective. But from a software perspective maybe it makes sense to combine with an SD card. Can you send instructions to the touchscreen in the middle of, say, a block read from an sd card?
Sign In or Register to comment.