OLED Technology by 4D Systems

Author: Aki Korhonen
Published: 25.06.2009
Product manufacturer: 4D Systems
In English In English
Suomeksi Suomeksi

OLED Paint - Drawing program using the touch panel

As the module under testing has a touch panel, here's a little drawing program made with 4DGL that uses the touch functions that are available. For touch panel usage 4DGL has function for getting the state of the panel (pressed/dragged/released) and X and Y coordinates.

The drawing programs is just simply made so that it fetches the X and Y coordinates from the touch panel and draws a dot at that place. As the screen isn't cleared in the loop the image stays and you can draw. There is a button for clearing the screen. The fix_coordinates function is just a quick fix I put together to correct the X and Y readings from the panel so the dot is drawn under the pen at all times. There was some offset without it when going near the edges and the drawn dot started to drift away from under the pen so it needed some correcting.


Introcution to 4D Systems OLED Technology
OLED Paint

Below is a video of the program running on the module:

Get Flash to see this player.

The code:

#platform "uOLED-32024-P1T"

* MetkuMods -
* Filename: drawing_program_2.4dg
* Created: 2009/06/11
* Author: Aki Korhonen
* Description: Simple drawing program

#inherit "4DGL_16bitColours.fnc"

var x, y, state;
var x2, y2;

func fix_coordinates()
    if(x < 81)
        x2 := (((810-x*10)/81) * 20)/10;
        x := x + x2;
        x2 := (((1590-(1590-(x*10-810)))/159) * 30)/10;
        x := x - x2;
    if(y < 172)
        y2 := (((1720-y*10)/172) * 20)/10;
        y := y + y2;
        y2 := (((1480-(1480-(y*10-810)))/148) * 30)/10 - 18;
        y := y - y2;

func main()
        gfx_Set(PEN_SIZE, 1); 
        gfx_Rectangle(20, 20, 220, 280, BLUE);
        gfx_Button(UP, 55, 280, GRAY, BLACK, FONT1, 4, 1, "CLEAR");
        txt_MoveCursor(0, 5);
        print("OLED Paint");
        state := touch_Get(TOUCH_STATUS);
        x := touch_Get(TOUCH_GETX);
        y := touch_Get(TOUCH_GETY);
        if(55 < x && x < 185 && 280 < y && y < 300)
            gfx_Set(PEN_SIZE, 0); 
            gfx_Rectangle(21, 21, 219, 279, BLACK);
            gfx_Set(PEN_SIZE, 0); 
            gfx_Circle(x, y, 1, WHITE);

Pages:  1 2 3 4 5 6 7 8 9 10 11 12 

  Content in english!
  Sisältö suomeksi!


 .:Back to top Bandwidth by Mpoli

Copyright ©, All Rights Reserved.
All content and graphics in MetkuMods are sole property of Jani Pönkkö and may not be reproduced or copied in any manner without written permission from him.
All brand names, trademarks and copyrights are the property of their respective owners.Privacy Policy