Announcement

Collapse
No announcement yet.

Read form

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

  • Read form

    Hello

    Is it possible to read the current form from the display to arduino.
    I use VISI GENIE

    I have 3 forms 1 video, 1 home and 1 information screen

  • #2
    Hello,

    If you have Workshop4 Pro, the 'CurrentForm' variable can be used in Genie-Magic code to give you the current form.

    However, if you would like to keep track of the current form in your Arduino code and you are using the genieArduino library, you can use the 'Report Message' event to tell the Arduino you have switched forms.

    To do this, go to each form object in your ViSi-Genie project and click on the 'Events' tab. Then for the 'OnActivate' event, select 'Report Message'. Here is an example of me setting a form event. Do this for every form in your project.

    Click image for larger version

Name:	Screenshot 2020-11-13 165240.png
Views:	44
Size:	20.0 KB
ID:	74262

    Then, in your Arduino code, you can use the genie.EventIs function to check whether the current form has been changed. Here is what your event handler would look like in Arduino.

    Code:
    void myGenieEventHandler(void) {
    genieFrame Event;
    genie.DequeueEvent(&Event); //loops through each form, so if you add more forms, make sure to change the upper bound.
    for(int i = 0; i <= 3; i++) {
    //checks if the form has been changed
    if(genie.EventIs(&Event, GENIE_REPORT_EVENT, GENIE_OBJ_FORM, i)){
    currentForm = i; // the current form number will be stored in this variable, you will most likely have this variable initialised globally
    }
    }
    }
    This will make sure the current form number is always stored in a variable.

    Regards,
    Adem

    Comment


    • #3

      thanks for your answere

      This is what I have but the serial monitor is only print 0. I have set the report message on each form as in the picture below
      Click image for larger version

Name:	Screenshot_33.png
Views:	44
Size:	24.0 KB
ID:	74267

      Code:
      int currentForm;
      
      void setup()
      {
        Serial.begin(9600);
        Serial1.begin(9600);
        genie.Begin (Serial1);
      
        genie.AttachEventHandler(myGenieEventHandler);
      
        pinMode(RESETLINE, OUTPUT);
        digitalWrite(RESETLINE, 1);
        delay(100);
        digitalWrite(RESETLINE, 0);
      
        delay(3000);
      }
      
      void loop() 
      {
        genie.DoEvents();
        Serial.println(currentForm);
      }
      
      void myGenieEventHandler(void)
      {
        genieFrame Event;
        genie.DequeueEvent(&Event); //loops through each form, so if you add more forms, make sure to change the upper bound.
        for(int i = 0; i <= 3; i++)
        {
            //checks if the form has been changed
            if(genie.EventIs(&Event, GENIE_REPORT_EVENT, GENIE_OBJ_FORM, i))
            {
                currentForm = i; // the current form number will be stored in this variable, you will most likely have this variable initialised globally
             }
         } 
      }
      Last edited by [email protected]; 2 weeks ago.

      Comment


      • #4
        Hello again,

        I tried your code with my testing program and it was successful, the serial monitor was always printing out the current form, and the number changed when the form changed.

        So if there is no difference in Arduino code perhaps there is something different with our ViSi-Genie programs. Would you be able to send your project through File -> Zip Project? Also, can you confirm that the problem is that you can switch forms, however the current form number stays at 0?

        I am also going to send my testing program, feel free to have a look and perhaps you find out what the difference is without needing to send anything.

        Thanks,
        Adem
        Attached Files
        Last edited by ademdeojee; 2 weeks ago.

        Comment


        • #5
          it's working thanks man I forgot to chance the maximum form alvue

          Comment

          Working...
          X