How multiple windows are seamlessly managed in TFT

Discussion in 'General Electronics Chat' started by aamirali, Jul 13, 2013.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    Hi
    I am working on one of my project in which I am using TFT.Suppose I have one window opened on it displaying some text. Now button press a pop up message appear on screen & ask user to continue or not. If yes then stay on screen else go to new screen. If user pressed back button then come back to first screen.

    First to print pop up message ,I have to clear the part of screen & display my pop up message, & if user pressed cancel, then I have to remove pop up box which leads to delete the entire screen & reprint it again.

    Also when user get back from new screen to first screen then first I have to clear new screen & then reprint all again first screen.

    However in many projects , I have seen this is seamlessly managed.Also like multiple windows are managed in OS How to do that. I don't think that only due to speed which creates that seamless behavior there must be some programming technique to do that.
     
    Last edited: Jul 13, 2013
  2. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    The main technique is to copy a chunk of screen to memory when drawing a window over it. Then when the window is removed, the screen contents are copied back from memory.

    If you don't have tons of memory, the other common way is just to destroy the screen area when you write the window over it, then to restore the screen contents you just write the whole screen data again.
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    If TFT refers to thin film transistor LCD, then TFT has nothing to do with windows.

    It is all handled in your graphics package.
    I am doing the same thing on a single chip mcu with no extra external memory. I don't have enough memory to copy every window. I use a single screen memory.
    I simply redraw the affected area or window.
    For example, think of what happens when you select and drag a window that overlaps other windows.
     
  4. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    I am using 32 bit cortex m3 , so memory isn't a problem & I am not using any graphic lib I have written my own lib for this. Can you have some example code in which multiple screen management is shown
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    The code is not difficult to write. There is nothing special except simple program management. You can write your own code.

    As RB has pointed out, you can do this two ways.
    One way is to copy the area of the graphics screen that will be overwritten.

    When you are finished with the popup, simply replace the area with the copy.
    This is what I do to move the mouse pointer around.

    The second method is to tag the underlying window as being invalid. Refresh any invalid windows. I have multiple windows on my screen and this is what I do when I move them around. Even with overlapping windows, they all appear "seamlessly" with no fancy programming. I do not use any ready made libraries.

    Sorry, I cannot provide you with code.
     
  6. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    It's easy to say "memory isn't a problem" because you have an Arm processor, but even a modest sized screen is 320x240 pixels x 2 bytes per pixel colour data. So a single "screen" saved to memory takes 153.6 kb of ram!

    My suggestion would be to keep things easy to suit your skill level. The easiest method is just to trash the screen when making a popup, then redraw the entire screen to clear the popup. With your processor and decent code an entire screen draw from scratch should be very fast and not cause a problem for the user.
     
Loading...