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, 05: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


            • #7
              Hi.
              I have been trying this example because I also have difficulties to communicate between PICASO and ATmega. I am using a 4Duino.
              I have been using exactly the code indicated by Daniel here above.

              In the serial monitor in Arduino IDE, I can see the serial communication. but it doesn't go further to the PICASO.

              Do I need to make any other hardware connections on my 4Duino to get this running?
              Thanks
              Last edited by MohamedMomboz; 7th April 2017, 12:12 AM.

              Comment


              • #8
                what do you mean? the screen built into the 4duino uses Serial1 for the display
                if you give us a sketch we can see if anythings wrong

                Comment


                • #9

                  Hi tonton81 The code I am trying is exactly the one above in this thread, i.e.
                  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
                  I haven't added or deleted anything from it. Many thanks
                  Last edited by MohamedMomboz; 7th April 2017, 01:59 AM.

                  Comment


                  • #10
                    your using visigenie for the 4duino 2.4" screen or your using another lcd on 4duino? genie doesnt work on 4duino right now, but will soon

                    Comment


                    • ESPsupport
                      ESPsupport commented
                      Editing a comment
                      You can use Genie in the 'normal way' on the 4Duino. The 'Genie Graphics' that is not yet available, is supposed to be a slightly easier to start with Genie . But since it would only be slightly easier to start with it is not a high priority.

                  • #11
                    I am using the display that is included in the 4Duino hardware itself, i.e. uLCD-24PTU and I am trying to run all this in a ViSi Genie environment.
                    As an attachment, my Workshop 4 user interface.

                    If you allow me, still 2 further questions.
                    Do you know when the ViSi Genie will be available for 4Duino? and
                    Is there any alternative to do my programming 4Duino which such a nice interface as under Workshop 4?

                    Attached Files

                    Comment


                    • #12
                      to use the genie library in the 4duino itself, please open workshop and goto File, Options, then Genie tab. Set your baud to 200,000 and select COM1 comms port. Load up a new uLCD-24PTU project with the genie environment selected, then upload. Once you write it to your picasso using the 4D programmer cable/adaptor on the back picasso header of the 4duino, put the sdcard programmed with workshop in the 4duino. Your genie should work now on 4duino, using Serial1 as before.

                      it's important comms 1 is selected in genie options as the picasso on 4duino uses a fixed RX1/TX1 comm port for the atmel processor connection as per the datasheet, and comms 0 on the lcd is actually used for programming the lcd. Enjoy

                      Tony
                      Last edited by tonton81; 7th April 2017, 04:11 AM.

                      Comment


                      • #13
                        Note, for the genie demo code or your own, the reset line pin number on the 4duino is pin #30, the sketch originally has pin4 as the shield, you will be using pin30 instead on 4duino, You may also still continue using the esp8266 on the 4duino with genie as well, with the ITEAD esp8266 library and software serial.

                        Tony

                        Comment


                        • #14
                          Dear Toni
                          ... more frustrated then before .......

                          I have been following your indications and, I hope I didn't any mistake, and I couldn't succeed.
                          Beside setting the options under the IDE, i.e. comms port on 1 and comms speed on 200'000 bps, the example below, which I picked from this thread, still doesn't work.
                          As you can notice I have changed the reset line pin number.
                          But these changes, I have been doing the rest as usual.

                          Many thanks anyway! That was a trial.

                          Code:
                          #include <genieArduino.h>
                          #define RESETLINE 30
                          
                          Genie genie;
                          int slider_val;
                          void setup() {
                            // put your setup code here, to run once:
                          Serial.begin(9600);
                          genie.Begin(Serial);
                          
                          genie.AttachEventHandler (myGenieEventHandler);
                          
                          Serial.println("Setup..");
                          pinMode(RESETLINE, OUTPUT);
                          digitalWrite(RESETLINE, 1);
                          delay(100);
                          digitalWrite(RESETLINE, 0);
                          delay(3500);
                          Serial.println("ok..");
                          
                          }
                          
                          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

                          Comment


                          • #15

                            genie.Begin(Serial) please use
                            genie.Begin(Serial1) as i mentioned before, do you at least see the lcd images come on?

                            Comment

                            Working...
                            X