Shop OBEX P1 Docs P2 Docs Learn Events
Using a 3.5" color touchscreen in a 2-color mode — Parallax Forums

Using a 3.5" color touchscreen in a 2-color mode

HarleyHarley Posts: 997
edited 2010-07-10 22:23 in Propeller 1
I have the need to display a heart pulse waveform. I'd previously implemented this on a 132 x 64 monochrome LCD. I'd like to utilize most of my previous effort using the 3.5" LCD. I've been studying the PTP Paint! and PTP Graphics demo programs, but don't quite catch what is necessary for making the display work as desired.

I'm assuming the 320 RGB pixels x 240 lines of this color screen requires just 320/32 * 240 = 2400 longs or 9600 bytes for the graphics buffer. In a previous project wrote a 1 to RAM for each A/D sample received. The 1 was posted proportional to amplitude; the remaining column pixels 'vertically' were erased/cleared and then the 1 written at the amplitude of the sample. The '1' vs a '0' would hopefully be 'painted' on the color LCD forming an 'oscilloscope' type display.

I'd like to adapt my program to the PTP Paint program; eliminating the 'paint' portion adding in my routines, but writing my data to the screen. How does one define how many colors are to be displayed? I note the PTP Paint! demo displays 6 colors; yellow on blue for the title, blue background, and user choosable white, red, green, or black for background and lines in the drawing area. How does one limit it to just 2 colors and using a 0 or 1 to display background or trace colors, respectively? Of course I'd like to use more colors (like for the menu).

Since the LCD has a touch screen I'd also like to use it to select menu items. They probably would be at the top of the screen with the waveform positioned on the lower portion of the screen. Does this seem feasible? Does to me, unless there is something I've missed after pouring over the source listings for days. I'd prefer to learn of pitfalls before spending days trying to get every bit of my code merged with the remaining portion of Paint!, using that as a starting point.

Note: this is only for hobby/personal use. yeah.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Post Edited (Harley) : 7/10/2010 9:52:04 PM GMT

Comments

  • RaymanRayman Posts: 14,889
    edited 2010-07-10 11:27
    Harley, the PTP 3.5" touchscreen driver works the same way as the VGA driver, from which it was derived...

    It's a tile based driver where the screen is divided into 16x16 pixel tiles.· Each tile can have it's own four color palette.· Usually, each tile shows a character from the ROM font, but you can use Graphics.spin to draw custom graphics..

    For oscope, I would use Graphics.spin to draw the traces.· The PTP "Graphics Demo" shows how to use Graphics.spin with double buffering.· Also demonstrates how to use only a portion of the screen as graphics and the rest as regular ROM font characters.

    But, double-buffering·a large area, like that example, uses up almost all of memory,·so I'd recommend not using double buffering or restricting the·graphics area to a smaller portion of the screen.·



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

    My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • HarleyHarley Posts: 997
    edited 2010-07-10 16:33
    Rayman, thank you for the hints. I'm not used to workiing with tiles or colors, so it is a whole different world of thinking.

    I don't wish to have to redraw the whole screen as a trace is being developed. But I suppose one could 'plot' a vertical line which would erase any pixels in that column of pixels prior to plotting a new pixel representing the next amplitude of a trace. Fortunately a heart pulse is quite slow, normally; so several per second would be a fast pulse but slow for the Prop.

    I couldn't find any way to make smallish text characters; at least plowing through Graphics.spin I didn't recognize anything related to size of a font. Maybe it is the way Chip's font table was designed that I don't notice any reference to sizing of a font.

    I'll just have to modify Paint in small steps to realize what's needed for my application. Like try to put text on boxes to make it stand out, for example.

    It appears the PTP board has only 6 I/Os not used. I'll need that to generate the D/A output simulating a plus waveform, and for a sigma-delta A/D for inputting an amplified pulse signal. The D/A is for initial testing without need for any pulse amplification and human to supply a pulse signal from a sensor. I didn't need double buffering with the previous monochrome LCD; hopefully not with this either. Attached is a photo of the monochrome display

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    640 x 480 - 52K
  • HarleyHarley Posts: 997
    edited 2010-07-10 22:23
    OK, I'm making some progress adapting Paint for my use.

    Ran into one problem. How does one display the value of a variable using Chip's Graphic driver? I didn't see any instruction to handle that.

    I don't see the equivalent as in TV_text. I can print zero terminated strings, but would now like to display some of the variables on screen used in this program to make debugging easier.

    If I use printStr(string("touchx = ")) that produces 'huge' size font vs what Graphic does when an instruction such as gr.text(100,85,@menu4a) is used. That's almost too small; is there a way to maybe double the latter? My eyes aren't quite what they used to be. Guess for now I'll just have to use the big font; can't put as much onscreen though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
Sign In or Register to comment.