Announcement

Collapse
No announcement yet.

Running myGenieEventHandler

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

  • Running myGenieEventHandler

    Hello!

    I am very new to my uLCD 43-PT display. I am connecting the display to a SparkFun RedBoard (suppose to be the same as Arduino Uno in terms of functions and programming) with the arduino shield mark two. While fiddling, I have found that I can not get my code to ever go into myGenieEventHandler. I have attached the code to show how simple it is. In visi-genie, all that I have is a slider and led digits. The slider is set to report message on change, and on changing. I read in tutorials and such that the handler is called when the system is ideal, and an event is in the queue. I am requesting help with what is needed to trigger the EventHandler, and what I should change to do just that. Thank you.
    Code:
    #include <genieArduino.h>
    #define RESETLINE 4 // Change this if you are not using an Arduino Adaptor Shield Version 2
    Genie genie;
    void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600);  // Serial0 @ 9600 (9.6K) Baud
      genie.Begin(Serial);  
      genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing event
      pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - genie Reset)
      digitalWrite(RESETLINE, 1);  // Reset the genie via D4
      delay(100);
      digitalWrite(RESETLINE, 0);  // unReset the genie via D4
    
      delay (3500); //let the genie start up after the reset (This is important)
      genie.WriteContrast(10);
    
    }
    void loop() {
      // put your main code here, to run repeatedly:
      genie.WriteObject(GENIE_OBJ_LED_DIGITS,0x00, 0001);
      genie.DoEvents(); // This calls the library each loop to process the queued responses from the genie
      genie.WriteObject(GENIE_OBJ_LED_DIGITS,0x00, 0002);
    }
    void myGenieEventHandler(void)
    {
      genie.WriteObject(GENIE_OBJ_LED_DIGITS,0x00, 0003);
    }
    Daniel
    Attached Files

  • #2
    Hi Daniel,

    I have here a sample genie file and an Arduino file.
    What it does is get the value of the slider form the lcd then write back to the LED digits.

    Code:
    void loop() {
      // put your main code here, to run repeatedly:
    
      genie.DoEvents();
    
    }
    
    void myGenieEventHandler(void)
    {
      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_SLIDER)              // If the Reported Message was from a User LED
        {
          if (Event.reportObject.index == 0)                              // If UserLed0 (Index = 0)
          {
              slider_val =  genie.GetEventData(&Event);
             genie.WriteObject(GENIE_OBJ_LED_DIGITS,0x00, slider_val);
          }
        }
      }
    } // end of loop
    Hope this helps,
    Attached Files
    Last edited by Joseph Herrera; 7th February 2017, 06:25 PM.

    Comment


    • #3
      Hi Daniel,

      In your first post, the program you used, did you have the Event set on the Slider object in Workshop4?
      The way the genieMyEventHandler works is it is triggered when comms comes from the display, so unless you are triggering the comms by setting the output of the slider to Report Message from the Events tab, then nothing will be sent to the Arduino, so the handler will never be triggered.

      Regards
      James

      Comment


      • #4
        Thank you for the replies!

        Joseph, I have tried that exact code before, with no luck.

        James, I have set the slider in the events tab to report message on changed and changing.

        Furthermore I have gone back to the very basics by trying to get the genieArduino_Demo to work. While the coolGauge will increment, all pieces that require EventHandler to work do not. I am coming to believe that the redBoard can send information to update the display, but it is failing to receive any information from the display. As a last ditch effort to get anything to trigger EventHandler, I set all items to report message while changing, or changed. This included the continuously changing coolGauge. Nothing happened. Should I be trying SoftSerial to find different ways to get information to the Arduino?

        Daniel

        Comment


        • #5
          Hi Daniel

          In your program in post 1, you have it writing to 3 different LED Digits. I assume you have more than 1 form?
          Just want to make sure you are not writing to an object which does not exist, as that will cause problems.

          Can you confirm if you are getting any data going from the Redboard to the display?
          Is it just the handler which isnt firing, or are you not getting any data flowing at all?

          Please can you describe how you have connected everything up?
          You also have the baud rate set to be the same on both Display and Arduino Sketch, right?
          James

          Comment


          • #6
            Hey guys,

            So after a couple hours of trouble shooting it appears that my RedBoard requires jumpers wires from RX to D0 (pin set J3 in 'ViSi-Genie Connecting a 4D Display to an Arduino' workshop) and TX to D1 (J4) for proper communication. Thank you for the help!

            Comment

            Working...
            X