Announcement

Collapse
No announcement yet.

genie.GetEventData(&Event); not stating variable.

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

  • genie.GetEventData(&Event); not stating variable.

    Hi, I've been looking through app notes and forum posts but haven't found a solution to my issue. My current set up is; 7" Diablo display, newest Ver Arduino Shield, and a Arduino UNO.
    I have them both communicating successfully. On the Workshop IDE when a Form is activated it is set to "Report Message". This triggers the GENIE_REPORT_EVENT, then correctly prints "Form#". Buttons are set within the Workshop as well and not used within the Arduino code.

    The issue is genie.GetEventData(&Event); doesn't have the correct value appropriate to the Form. The serial monitor just prints 0. When the display switches to a new form for example; the screen switches to form 2 the serial monitor on the UNO IDE still displays 0.
    I'm not sure what i'm missing.
    Any help is appreciated thanks.


    Code:
    #include <genieArduino.h>
    #include <SoftwareSerial.h>
    
    #define RESETLINE 4  // Change this if you are not using an Arduino Adaptor Shield Version 2 (see code below)
    
    Genie genie;
    
    SoftwareSerial serial(10, 11);
    int cform;
    int pform;
    int fform;
    boolean firststart = true;
    
    void setup()
    {
      Serial.begin(4800);  // Console in Arduino IDE on Serial0
      serial.begin(9600);  
      genie.Begin(serial); // display connected to a software serial port
    
      genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing events
    
      pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      digitalWrite(RESETLINE, 1);  // Reset the Display via D4
      delay(100);
      digitalWrite(RESETLINE, 0);  // unReset the Display via D4  
      delay (5000); //let the display start up after the reset (This is important)  
      genie.WriteContrast(15); 
    
    
    }
    
    void loop()
    {
      genie.DoEvents();
      if (firststart == true)
      {
      Serial.print("Start Splash \n"); //Debugging
      genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
      delay(5000);
      genie.WriteObject(GENIE_OBJ_FORM, 1, 0);
      Serial.print("Splash Complete \n"); //Debugging
      firststart = false;
      }
    
      if (firststart == false)
      {
      Serial.print("Waiting for input... Form:\n"); //Debugging
    
      delay(500);
      genie.DoEvents();
    }
    }
    void myGenieEventHandler(void)
    {
      genieFrame Event;
      genie.DequeueEvent(&Event); 
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
      {
        if (Event.reportObject.object == GENIE_OBJ_FORM)
        {
            cform = genie.GetEventData(&Event);
            Serial.println(genie.GetEventData(&Event));
            Serial.print("Form #: ");
            Serial.println(cform);
        }
      }
    }

  • #2
    I found the solution to my problem.
    I referred to this https://forum.4dsystems.com.au/forum...gation-arduino.

    From looking at my code I added
    Code:
    Event.reportObject.index
    within the
    Code:
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
      { //Added it here
        Serial.print("Form #: ");
        Serial.println(Event.reportObject.index);
        if (Event.reportObject.object == GENIE_OBJ_FORM)
        { //Adding it here also worked.
            cform = genie.GetEventData(&Event);
            Serial.println(Event.reportObject.index);
            Serial.println(genie.GetEventData(&Event));
            Serial.print("Form #: ");
            Serial.println(cform);
        }
      }
    I'm assuming genie.GetEventData(&Event) isn't getting the index of the form?

    Comment


    • #3
      Hello,

      Welcome to the forum!

      To answer your question, genie.GetEventData(&Event)does not return the index of the form or any widgets in general. What it returns is the value of the widget sending the report event command as a 16-bit integer.

      It is right for you to use Event.reportObject.index since this returns the index of the widget which the event is from.

      I hope this would help! Let us know if we can provide further assistance.

      Best Regards,
      Kimberly

      Comment


      • #4
        Kimberly, that makes sense. Thanks for the explanation.
        ​​​​​​
        I would like to thank you, all the 4d staff, and the people on here, for providing such detailed walkthroughs and documentation. On top of that actively helping whether a small project or a large one. I really appreciate amount of support available.

        Comment


        • #5
          Hello again,

          Thank you for those kind words.

          You are most welcome. It is always our pleasure to provide assistance to all our customers.

          Do not hesitate to reach out to us and we will do our best to help in any way we can.

          Best Regards,
          Kimberly
          Last edited by Kimberly; 4th September 2018, 10:40 AM.

          Comment

          Working...
          X