Shop OBEX P1 Docs P2 Docs Learn Events
320(rgb)x240 lcd — Parallax Forums

320(rgb)x240 lcd

DaveC3DaveC3 Posts: 8
edited 2008-10-26 00:42 in Propeller 1
I am new to the Propeller, however I have been programming PIC micros for many years. I acquired a couple of 320(RGB)X240 displays for a buck a peace. They do not have a controller chip. So far I have been able to modify R. A. Paz Schmidt's LCD.spin (thanks for the kick start) to display color bars. Now I am stuck. I want to be able to display text and graphics on this display. I have ordered the Hydra book (maybe this will point the way).

Here are the signals that I need to control
Frame = High during the first scan line
Load   = a pulse after each scan line
CP = clock pulse 
DISP = turn on display high signal
VEE = turn on lcd drive voltage ~27v high signal
Data = one byte
[noparse][[/noparse]code]
KCS057QV1AD RGB  Display connected to 74LCX245 (as buffer 3.3v to 5v logic):
                    PIXEL              1  2  3   4  5   6  7  8 ............. 320
D0..D7 PA0..7       Data      RGBRGBRG BRGBRGBR GBRGBRGB ............
                          bit      76543210


              '  dec val     146       73       36
              'Red  %10010010_01001001_00100100
              '         73       36      146
              'Green %01001001 00100100 10010010
              '         36      146       73
              'Blue  %00100100 10010010 01001001
              '        182      219      109




Any help would be appreciated

Thanks

Dave

Comments

  • mparkmpark Posts: 1,305
    edited 2008-10-24 20:15
    A buck each? Where?!

    Displaying text and graphics on the Propeller is divided into two parts: drawing and displaying. For the drawing part, you'll probably use the Graphics object. It has methods for drawing lines, text, etc. It does its work on a bitmap. To actually display the bitmap, you'll use a TV object if you're hooked up to a TV, a VGA object if you're connected to a VGA monitor, or in your case, well, you're out of luck.

    The Propeller doesn't have built-in support for 24-bit pixels, so you've got your work cut out for you. Maybe you could use the VGA driver to start with. It outputs 6 bits per pixel, 2 each for R, G, B. Connect them to the most-significant bits of your LCD's RGB inputs. You still have to figure out the sync signals.

    Eventually you'll have to get into assembly language and devote a cog (or two?) to pumping out pixels.
  • 4Alex4Alex Posts: 119
    edited 2008-10-24 21:13
    @mpark:

    Probably from SparkFun. They sell a Color QVGA 2.3" 320x240 for $1USD. Sku is LCD-08843.

    Cheers,

    Alex
  • DaveC3DaveC3 Posts: 8
    edited 2008-10-24 23:27
    No, this is a 5 1/2" display. My guess it was used as a point of sale. It is a Kyocera KCS057QV1. I got them in a electronics surplus store in Austin TX. It also has a touch screen attached (eight elements).

    As I said I am real new to the propeller. I will do some more reading on the video and VGA drivers to see if I can modify something.

    Each pixel has three bits (RGB) but the data bus is eight bits wide so I have to figure out how to get 2 & 2/3 pixels per byte.

    Thanks for the reply's

    Dave
  • AleAle Posts: 2,363
    edited 2008-10-25 06:44
    Well Dave I'm glad the driver was of any use wink.gif. (I'm the one who wrote it).

    What I think you have is a Color STN display. or I'm wrong ?. This displays make up the colors using frame dithering, That means that to get shades of a color use set a pixel in one frame and do not set in subsequent frames. Very complicated. Why they do not have 6 or 9 data pins is everybody's guess.

    The easiest way to drive it would be to use full colors, just one shade of any color. And build a table depending which pixel you are driving because after some pixels you start over with the combination:

    1st byte : RGB RGB RG
    2nd byte : B RGB RGB R
    3rd byte : GB RGB RGB
    4th byte : RGB RGB RG
    ...

    As you see after 3 bytes the scheme repeats. So you have 2 solutions, either you have a 27kbytes buffer in memory and use 1 shade of each color (8 colors) and have the bitmap in memory with exactly this structure (easy to drive the display because you only send the data as they are in memory.

    2nd: You reorder the data from memory before you send it to the display. Well... There is not enough memory to use say 4 bits per pixel because that would mean more than 32k for he buffer.

    Well try the first approach smile.gif.

    How to draw something ?, well each pixel occupies 3 bits so you have to calculate in bits and then get the byte and bit index out of the x and y coordinates. Not utterly complicated.

    If it is a TFT display... the driving will be different, but with your : it has 8 bits and 1 per color sounds like a CSTN.

    Have fun and if you have more questions, here we are.

    Ale
  • DaveC3DaveC3 Posts: 8
    edited 2008-10-25 15:27
    Ali

    Thanks for the reply. I have been able to make full screen one color, different color bars and and split screen with different colors. I used the method you suggested by making 3 bytes in a specific color pattern. That gives eight pixels for three bytes of data.

    I will try your suggestion #1

    And thanks again for posting lcd.spin it was a great help getting started.

    Dave
  • AleAle Posts: 2,363
    edited 2008-10-25 19:07
    That was the idea! Post some fotos, we all love fotos of electronic equipment to je..., ahem to look at and get nice ideas :-D
  • DaveC3DaveC3 Posts: 8
    edited 2008-10-25 20:05
    Ali

    Here is a picture of the display and the various supporting boards. To the far right you can see the Propeller USB board, just to the left of that is a 3,3v to 5v adapter. I used two 74LCX245's. Jut to the lft of that is a small board that has the 5v to 27v biasa supply and supplies 5v to the display as well as all the LCD connections. As you can see I can ge te display to produce color bars. In this case red, green, blue.

    Here is the code.


    
    KCS057QV1AD RGB  Display connected to 74LCX245 (as buffer 3.3v to 5v logic):
                        PIXEL      1  2  3   4  5   6  7  8 ............. 320
    D0..D7 PA0..7       Data      RGBRGBRG BRGBRGBR GBRGBRGB ............
    DISPON PA11          bit      76543210
    CP PA10
    LOAD PA9
    FRM PA8
    VEE PA12
    
                  '        146       73       36
                  'Red  %10010010_01001001_00100100
                  '         73       36      146
                  'Green %01001001 00100100 10010010
                  '         36      146       73
                  'Blue  %00100100 10010010 01001001
                  '        182      219      109
                  'R&B   %10110110 11011011 01101101
                  '         73      146       36
                  '/BLUE  %01001001_10010010_00100100
                  '         36       73      146
                  '/RED   %00100100_01001001_10010010
                  /GREEN  %10010010_00100100_01001001
    
    }
              'Constants to be located here
    '***************************************
    '  System Definitions      
    '***************************************
    
      _OUTPUT       = 1             'Sets pin to output in DIRA register
      _INPUT        = 0             'Sets pin to input in DIRA register  
      _HIGH         = 1             'High=ON=1=3.3v DC
      _ON           = 1
      _LOW          = 0             'Low=OFF=0=0v DC
      _OFF          = 0
      _ENABLE       = 1             'Enable (turn on) function/mode
      _DISABLE      = 0             'Disable (turn off) function/mode
      _BLACK        = %00000000
      _WHITE        = %11111111
    
    '**************************************
    '***************************************
    '  LCD Interface to Propeller      
    '***************************************
    
    ' _LCD_Data    = 7..0          ' Data lines (This line is here for reference, not for code)
      _LCD_FRM     = 256             'Synchronous signal for driving scanning line
      _LCD_LOAD    = 512             'Data signal latch clock 
      _LCD_CP      = 1024            'Data signal shift clock
      _LCD_DISP    = 6144           'Display control signal and VEE on            
    
    
    'k_FRM    = 256
    'k_LOAD   = 2
    'k_CP     = 4
    'k_DISP   = 8
    'k_VEE   = 16
    k_SHL    = 256
    
    k_GRAPH  = $8000 - 320*240/8       ' 0x3500
    k_TEXT   = k_GRAPH - 320*240/48
    k_GRAPHD = k_TEXT - 1
    k_FONT   = $8000
    
    
    
    PUB start 
    
      cognew(@cog1start, 0)
      cognew(@cog2start, 0)
      repeat
    
    
    
    DAT
    cog1start     mov       OUTA,#0
                  mov       DIRA,cnt_dira
                  mov       _cont,#0                ' resets frame counter
    
    ' waveform:
    '
    ' CP is used on the falling edge to transfer data
    ' FRM is high during the first line before to after the last column group
    ' LOAD is used at the end of last column to load the data
    
    
    refresh_main  mov       _a,#240                  ' line counter
                  cmp       _cont,#0 wz
            if_nz mov       _touta,cnt__LCD_DISP     ' turns on VEE
            if_z  mov       _touta,cnt__LCD_FRM
    '              mov       _y,#0                     'reset y
                  
                  
    refresh       mov       OUTA,_touta
    
                  or        _touta,cnt__LCD_CP         ' reises clock
                  mov       _b,#40                     ' column counter
    '              mov       _x,#0                      '  reset x
                 
    ref_line
    
                 call #color                    ' get color of pixals from cog2
                                        ' now we send the data to the display
    
                  mov       _d,_c                   ' put color data in d
                  and       _d,cnt_dout             ' and color with %00000000_00000000_00000000_11111111
                  or        _d,_touta
                  mov       OUTA,_d                 ' outputs data and clock
                  shr       _c,#8                   ' shifts data
                  andn      OUTA,cnt__LCD_CP        ' resets clock
    
                  mov       _d,_c
                  and       _d,cnt_dout
                  or        _d,_touta
                  mov       OUTA,_d                 ' outputs data and clock
                  shr       _c,#8                   ' shifts data
                  andn      OUTA,cnt__LCD_CP        ' resets clock
    
                  mov       _d,_c
                  and       _d,cnt_dout
                  or        _d,_touta
                  mov       OUTA,_d                 ' outputs data and clock
                  andn      OUTA,cnt__LCD_CP        ' resets clock
    '              add       _x,#8                   ' add 8 pixels to x
                  djnz      _b,#ref_line            ' Decrement colume cpunter and jump to ref_line if not zero 
                                                       
                  mov       _b,CNT
                  add       _b,#40                  ' wait 1 us
                  waitcnt   _b,#80
                  or        OUTA,cnt__LCD_LOAD
                  waitcnt   _b,#84
                  andn      OUTA,cnt__LCD_LOAD
                  waitcnt   _b,#0
    
                  andn      _touta,cnt__LCD_FRM
                  andn      OUTA,cnt__LCD_FRM          '
                  
                  djnz      _a,#refresh
    
                  add       _cont,#1
                  jmp       #refresh_main           ' another 
                  
    _a            long      0
    _b            long      0
    _c            long      0
    _d            long      0
    _t            long      0
    _cont         long      0 ' frame counter, used to activate negative voltage
    _ptr          long      0
    _touta        long      0
    _toutb        long      0
    cnt_dout      long      %00000000_00000000_00000000_11111111
    cnt_dira      long      %00000000_00000000_00011111_11111111
    contr_out     long      %00000000_00000000_00011111_00000000
    contr_dir     long      %00000000_00000000_00011111_00000000 
    cnt_50ms      long      50*80_000
    cnt_AA        long      $10101010'20202020'40404040'30303030'60606060'c0c0c0c0
    cnt__LCD_CP   long      _LCD_CP<<k_SHL
    cnt__LCD_FRM  long      _LCD_FRM<<k_SHL
    cnt__LCD_LOAD long      _LCD_LOAD<<k_SHL
    cnt__LCD_DISP long      (_LCD_DISP<<k_SHL)|(_LCD_FRM<<k_SHL)           ' turn on VEE
    cnt_RED       long      %00100100_01001001_10010010 
    cnt_BLUE      long      %01001001_10010010_00100100
    cnt_WHITE     long      %11111111_11111111_11111111 
    cnt_BLACK     long      %00000000_00000000_00000000
    cnt_GREEN     long      %10010010_00100100_01001001 
    '              fit
    
    DAT
    
    cog2start
    
    color
    
    
                 cmp       _a,#80  wc
            if_b mov       _c,cnt_BLUE    
            if_a mov       _c,cnt_GREEN
    
                 cmp        _a,#160  wc
            if_a mov       _c,cnt_RED
    '              jmp       #color
                  
    '             cmp        _x,#160  wc
    '        if_a mov        _c,cnt_RED
            '     cmp       _x,#120 wc 
            'if_a mov       _c,cnt_WHITE    
            'if_b mov       _c,cnt_WHITE         
    color_ret        ret               
             
    
    red           long      %001
    green         long      %010
    blue          long      %100
    _t0           byte      0
    _t1           long      0
    _t2           long      0
    _t3           long      0
    
    _x            long      0
    _y            long      0
    _chptr        long      0
    _dptr         long      0
    _str          long      $2a0
    cnt_k2_FONT   long      k_FONT
    cnt_k2_GRAPH  long      k_GRAPH
    cnt_80m32     long      80*32-2
    
    



    There is a bunch of stuff that is not needed, just been to lazy to take it out.

    Thanks

    Dave
    1399 x 631 - 80K
  • Dennis FerronDennis Ferron Posts: 480
    edited 2008-10-26 00:04
    Hey! I recognize that black power supply you have in the background there - it's the same one I used to power the LCD TV on my suitcase computer when the TV's built in supply went bad. +12, +5, and -12, right? (LCD TV's require a negative bias voltage as well as positive, or the image gets washed out.) Where did you buy it? I got mine from some surplus stuff EPO Electronics in Houston had, but they were unmarked units and I never knew what purpose they were originally for. Nice little power supply units though; I wish I'd had the money to buy more than 1 at that time, because they were quickly sold out.

    Wowsers, that 320x240 LCD is bigger than I thought; formerly I thought you were talking about a Nokia cell phone LCD.
  • DaveC3DaveC3 Posts: 8
    edited 2008-10-26 00:42
    Dennis

    Good eye, yes it is most likely the same supply. I bought two or three from Tanner electronics in Dallas. I do not remember what I paid for them but not more than $10 more likely in the $5 range(I am cheap). I use the one in the picture for my bench supply.

    I picked up this display in Austin. They were a real bargain, $1.00 each. They did not have any data on them so I did a search and gave them the data sheet, they gave me another for free. Up to now I have not thought it possible to run the display (in a useful manner). I normally build my projects around PIC Micros. It would be very hard to do it with a PIC and using a non-asm programing language. I thought the Propeller looked like it could handle the job so I sent for one a couple of weeks ago. Now I have to learn another language cry.gif

    Take care

    Dave
Sign In or Register to comment.