Announcement

Collapse
No announcement yet.

Create extra "screen view" runtime

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create extra "screen view" runtime

    Hello,
    it's my first project in 4d systems. I have a uLCD-24PT where I print data coming from a raspberry pi through serial bus. The data are being printed inside some panels with string I have created.

    I want to do the following task: when the user touches the screen (inside a panel), the screen should create an extra "panel" (or something like that) with "extended infos". Which is the most efficient way?

    - Should I create an extra form? If yes, in the runtime?
    - Is the object String Book the suitable way? It seemed to me that does the exact thing, but I cannot understand how you handle an object String, and change "pages" inside it. Can I handle string object from raspberry?
    - Should I use Genie instead of ViSi?

    Thanks for your time

  • #2
    Hello,

    Welcome to the forum.

    You are using the right environment for your project as it offers you the best flexibility for the features you are trying to create.

    You could create an extra form or as you are using Visi, remove/disable all the objects on screen and then use another panel on the blank form and fill it with the data you have received from the Pi. If you want to return to the previous form you will have to delete the new panel and redraw all the objects to the form.

    Or you could create a new panel on top of the existing objects, fill it with the data from the Pi. When you want to return just redraw and re-enable the objects under the panel that was on top.

    This is a simple example using panels and touch.

    #platform "uLCD-32PTU"


    // Program Skeleton 1.3 generated 04/09/2017 19:56:14

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    #inherit "panelstestConst.inc"

    var trx;
    var try;
    var n;
    var x;
    var y;
    var state;
    var mode;

    func main()

    touch_Set(TOUCH_ENABLE);
    drawmainpage();

    repeat

    state := touch_Get(TOUCH_STATUS); // get touchscreen status
    x := touch_Get(TOUCH_GETX);
    y := touch_Get(TOUCH_GETY);
    if (state == TOUCH_PRESSED)

    if (mode == 0)
    if (x > 12 && x < 230 && y > 14 && y < 54) drawinfopanel(1, 18, y);
    if (x > 12 && x < 230 && y > 72 && y < 112) drawinfopanel(2, 18, y);
    if (x > 12 && x < 230 && y > 130 && y < 170) drawinfopanel(3, 18, y);
    if (x > 12 && x < 230 && y > 188 && y < 228) drawinfopanel(4, 18, y);
    endif
    if (mode == 1)
    if (x > trx && x < (trx + 26) && y > try && y < (try + 26)) drawmainpage();
    endif

    endif

    forever
    endfunc

    func drawmainpage()

    mode := 0;
    gfx_Panel(PANEL_SUNKEN, 3, 1, 234, 314, WHEAT) ;
    gfx_Panel(PANEL_SUNKEN, 12, 14, 216, 40, WHEAT) ;
    gfx_Panel(PANEL_SUNKEN, 12, 72, 216, 40, WHEAT) ;
    gfx_Panel(PANEL_SUNKEN, 12, 130, 216, 40, WHEAT) ;
    gfx_Panel(PANEL_SUNKEN, 12, 188, 216, 40, WHEAT) ;

    txt_FGcolour(BLACK);
    txt_BGcolour(WHEAT);
    gfx_MoveTo(20, 20);
    print("Data set 1");
    gfx_MoveTo(20, 78);
    print("Data set 2");
    gfx_MoveTo(20, 136);
    print("Data set 3");
    gfx_MoveTo(20, 194);
    print("Data set 4");

    endfunc

    func drawinfopanel(var panelno, var xpos, var ypos)

    mode := 1;
    if(panelno == 1)
    gfx_Panel(PANEL_RAISED, xpos, ypos, 230 - xpos, 60, WHEAT) ;
    gfx_MoveTo(xpos + 6,ypos + 6);
    print("This is more data") ;
    gfx_MoveTo(xpos + 6,ypos + 36);
    print("for dataset 1");
    gfx_Button(1, 230 - xpos - 9, ypos, RED, YELLOW, FONT1, 2, 2, "X") ;
    trx := 230 - xpos - 9;
    try := ypos;
    endif

    if(panelno == 2)
    gfx_Panel(PANEL_RAISED, xpos, ypos, 230 - xpos, 60, WHEAT) ;
    gfx_MoveTo(xpos + 6,ypos + 6);
    print("This is more data") ;
    gfx_MoveTo(xpos + 6,ypos + 36);
    print("for dataset 2");
    gfx_Button(1, 230 - xpos - 9, ypos, RED, YELLOW, FONT1, 2, 2, "X") ;
    trx := 230 - xpos - 9;
    try := ypos;
    endif

    if(panelno == 3)
    gfx_Panel(PANEL_RAISED, xpos, ypos, 230 - xpos, 60, WHEAT) ;
    gfx_MoveTo(xpos + 6,ypos + 6);
    print("This is more data") ;
    gfx_MoveTo(xpos + 6,ypos + 36);
    print("for dataset 3");
    gfx_Button(1, 230 - xpos - 9, ypos, RED, YELLOW, FONT1, 2, 2, "X") ;
    trx := 230 - xpos - 9;
    try := ypos;
    endif

    if(panelno == 4)
    gfx_Panel(PANEL_RAISED, xpos, ypos, 230 - xpos, 60, WHEAT) ;
    gfx_MoveTo(xpos + 6,ypos + 6);
    print("This is more data") ;
    gfx_MoveTo(xpos + 6,ypos + 36);
    print("for dataset 4");
    gfx_Button(1, 230 - xpos - 9, ypos, RED, YELLOW, FONT1, 2, 2, "X") ;
    trx := 230 - xpos - 9;
    try := ypos;
    endif
    endfunc


    I hope this helps

    Best regards

    Paul
    Attached Files

    Comment


    • #3
      Thank you Paul, I will follow your suggestion!

      I have another question. I saw in an example, that you can handle events and object from raspberry pi, with the Genie library (writing C). Is it true? If yes, it seems that there is no need to send data through serial, but you can show on screen data from raspberry instead..? I guess it's not true, but I thought I would give it a try and ask.

      Best regards

      Comment


      • #4
        Hello,

        You can use the Visi-Genie Raspberry Pi library and create your images/buttons etc in the Visi-Genie environment. You will find this method far easier and requires less or sometimes no coding on the display.

        You will find the RPi Library here. https://github.com/4dsystems

        I hope this helps

        Best regards

        Paul

        Comment


        • #5
          You were right, Genie Library is a lot easier than programming in ViSi environment!!

          Just a last question, for the record.. If someone works in ViSi environment and wants to print data from Raspberry Pi, the only way is to send them in a bytestream way and the screen to handle them for printing? I mean, you cannot do something like "genieWriteStr()" like with Genie Library for Rpi?

          Thanks a lot

          Comment


          • #6
            Hello,

            Yes that is correct, it would have to be sent as a bytestream and then you would have to create a routine in Visi to handle the bytestream. The Visi-genie way handles all of that for you.

            Best regards

            Paul

            Comment

            Working...
            X