Announcement

Collapse
No announcement yet.

Change Form using button

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

  • Change Form using button

    Hi,
    I want to change form in the display using button. I write a code but it is not working. please help me

    Here I attached that code.

    Code:
    #include<genieArduino.h>
    #include<SoftwareSerial.h>
    Genie genie;
    #define RESETLINE 4
    
    
    
    void setup()
    {
      Serial.begin(200000);
      genie.Begin(Serial);
      genie.AttachEventHandler(myGenieEventHandler);
    
      pinMode(RESETLINE , OUTPUT);
      digitalWrite(RESETLINE,1);
      delay(100);
      digitalWrite(RESETLINE,0);
      delay(3500);
    
      genie.WriteContrast(10);
    
    
    }
    
    void loop()
    {
      static long waitperiod = millis();
    
      genie.DoEvents();
      {
        if(millis()>=waitperiod)
        genie.ReadObject(GENIE_OBJ_WINBUTTON,0x00);
        genie.ReadObject(GENIE_OBJ_WINBUTTON,0x01);
        genie.ReadObject(GENIE_OBJ_WINBUTTON,0x02);
        genie.ReadObject(GENIE_OBJ_WINBUTTON,0x03);
    
        waitperiod=millis()+50;
      }
    
    
    }
    
    void myGenieEventHandler(void)
    {
      genieFrame Event;
      genie.DequeueEvent(&Event);
    
     int button_val=genie.GetEventData(&Event);
    
      if(genie.EventIs(&Event,GENIE_REPORT_EVENT,GENIE_OBJ_WINBUTTON,0x00))
      {
    
        if(button_val==1)
        genie.WriteObject(GENIE_OBJ_FORM,1,0);
      }
      else if(genie.EventIs(&Event,GENIE_REPORT_EVENT,GENIE_OBJ_WINBUTTON,0x01))
      {
        if(button_val==1)
        genie.WriteObject(GENIE_OBJ_FORM,2,1);
      }
    
      else if(genie.EventIs(&Event,GENIE_REPORT_EVENT,GENIE_OBJ_WINBUTTON,0x02))
       {
       if(button_val==1)
       genie.WriteObject(GENIE_OBJ_FORM,0,1);
        }
    
      else if(genie.EventIs(&Event,GENIE_REPORT_EVENT,GENIE_OBJ_WINBUTTON,0x02))
      {
        if(button_val==1)
        genie.WriteObject(GENIE_OBJ_FORM,1,2);
      }
    
    }

    Thanking you,
    Hirak


  • #2
    Good day!

    When navigating to another form you only need to specify the form number.

    Please try using this code snippet to change forms:

    Code:
    genie.WriteObject(GENIE_OBJ_FORM, formNumber, 0); // change form number to desired form
    I hope this helps.

    Best Regards,
    Juniel Cruz

    Comment


    • #3
      Thanks Juniel, the code is working.

      how would i use dht11(humidity sensor)+arduino+ ulcd-70Dt to display the humidity level.
      if possible please help me by giving some guide code to display humidity level.

      Thanking you,
      Hirak

      Comment


      • #4
        Hi Hirak,

        Regarding your inquiries on DHT11 and Arduino, you can get more information on how to read from the sensor from the internet. A quick web search will point you towards: https://create.arduino.cc/projecthub...g-dht11-b0f365

        The link above discusses about reading the humidity and temperature from the sensor and printing the values to the Serial monitor. In your case, you simply have to change the process of printing to the Serial monitor into updating or writing to a ViSi Genie widget. Here's an application note that can help you out: https://docs.4dsystems.com.au/app-note/4D-AN-00018

        Regards,
        Juniel Cruz

        Comment


        • #5
          Hi Juniel,

          I write that code for sensing temperature from LM35 , and the value visible on LED DIGIT on visi-genie display. but the code does not work. Is anything wrong on that code?

          Code:
          #include<genieArduino.h>
          #include<SoftwareSerial.h>
          Genie genie;
          #define RESETLINE 4
          int SensorPin=A0;
          int tempC=0;
          int tempF=0;
          
          
          void setup()
          {
          
            Serial.begin(200000);
            genie.Begin(Serial);
            genie.AttachEventHandler(myGenieEventHandler);
            pinMode(RESETLINE , OUTPUT);
            digitalWrite(RESETLINE,1);
            delay(100);
            digitalWrite(RESETLINE,0);
            delay(3500);
          
            genie.WriteContrast(10);
          
          }
          
          void loop()
          {
          void myGenieEventHandler(void)
          {
            genieFrame Event;
            genie.DequeueEvent(&Event);
          
           tempC=((5*analogRead(SensorPin)*100)/1024)+2;
          
           tempF=(9/5)*tempC;
          
           genie.WriteObject(GENIE_OBJ_LED_DIGITS,0x00,tempC);
           genie.WriteObject(GENIE_OBJ_LED_DIGITS,0x01,tempF);
          
          
          }
          
          }

          Thankig you,

          Hirak Dash

          Comment


          • #6
            Hi Hirak,

            You seem to have the function void myGenieEventHandler(void) inside void loop() which causes a compile error.

            The function should be outside. You can checkout some examples within Arduino IDE by going to File -> Examples -> genieArduino

            I hope this helps.

            Regards,

            Juniel Cruz

            Comment

            Working...
            X