Announcement

Collapse
No announcement yet.

How do I pass a vabiable value back from myGenieEventHandler(void) to void loop()

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

  • How do I pass a vabiable value back from myGenieEventHandler(void) to void loop()

    Good Morning

    Most of my code is situated in the void loop() and is programmed in gate logic so I can have multiple things happening at once
    I simply need a flag/variable in the loop() to be changed on a button input from the display.

    e.g.

    void loop()
    {
    // Some Local Variables
    int flag a
    int flag b
    int flag c
    while(0==0)
    {
    genie.DoEvents(); // This calls the library each loop to process the queued responses from the display
    do lots of stuff defendant on inputs and flags a,b&c..........
    }
    }

    void myGenieEventHandler(int &flag1, int &flag2, int &flag3)
    {
    genieFrame Event;
    genie.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below
    if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
    {
    if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
    {
    flag a =1;
    flag b =1;
    flag c =1;
    }
    }
    }

    This does not work as I do not call the myGenieEventHandler function, I can get around it using global variables, but whats the best way to pass the values, e.g. flag a, flag b and flag c back to the main loop() ?

    Thanks Jon
    Last edited by Jon; 29th August 2017, 10:32 PM.

  • #2
    Hello Jon

    Welcome to the forum.

    The easiest way would be to use global variables. Is there a reason why you don't want to use globals. The method you used above is correct but is just not right for this particular purpose because you will not be calling myGenieEventHandler.

    Use the global variables

    int flaga;
    int flagb;
    int flagc;

    I hope this helps

    Best regards

    Paul

    Comment

    Working...
    X