In my project i have 3 win button. First > Up , Second > Down , Third > RH request. Up and Down is work perfect but rh is not work. My rh button function is = when i click rh button, button always send "rh request" and if i click another button it should stop.
I write a code but my code doesnt work. It always sending rh request but when i click another button rh not stop. Sometimes it's stoping but lcd is freezing and reseting.
My Code:
How can i solve this problem.
Note: I have Pro licence so you can advice me magic event etc.
I write a code but my code doesnt work. It always sending rh request but when i click another button rh not stop. Sometimes it's stoping but lcd is freezing and reseting.
My Code:
#include <genieArduino.h>
Genie genie;
int rha=0;
#define RESETLINE 4
void setup()
{
Serial.begin(9600);
genie.Begin(Serial);
genie.AttachEventHandler(myGenieEventHandler);
pinMode(RESETLINE, OUTPUT);
digitalWrite(RESETLINE, 1);
delay(100);
digitalWrite(RESETLINE, 0);
delay (3500);
genie.WriteContrast(1);
genie.WriteStr(0, GENIE_VERSION);
}
////////////////////////////////////////////////////////////////////
void loop()
{
static long waitPeriod = millis();
genie.DoEvents();
if (millis() >= waitPeriod) {
waitPeriod = millis() + 50; }
}
/////////////////////////////////////////////////////////////////////
void myGenieEventHandler(void)
{
start:
genieFrame Event;
genie.DequeueEvent(&Event);
if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
{
if (Event.reportObject.index == 2) // index= 2 UP
{
Serial.println("UP");
}
if (Event.reportObject.index == 3) // index= 3 DOWN
{
Serial.println("DOWN");
}
if (Event.reportObject.index == 4) // index= 4 RH
{
rha=0
while (rha<1)
{
genie.DoEvents();
if (Event.reportObject.index == 2 || Event.reportObject.index == 3)
{
rha++;
goto start;
}
else
{
Serial.println("RH request");
}
}
}
}
}
Genie genie;
int rha=0;
#define RESETLINE 4
void setup()
{
Serial.begin(9600);
genie.Begin(Serial);
genie.AttachEventHandler(myGenieEventHandler);
pinMode(RESETLINE, OUTPUT);
digitalWrite(RESETLINE, 1);
delay(100);
digitalWrite(RESETLINE, 0);
delay (3500);
genie.WriteContrast(1);
genie.WriteStr(0, GENIE_VERSION);
}
////////////////////////////////////////////////////////////////////
void loop()
{
static long waitPeriod = millis();
genie.DoEvents();
if (millis() >= waitPeriod) {
waitPeriod = millis() + 50; }
}
/////////////////////////////////////////////////////////////////////
void myGenieEventHandler(void)
{
start:
genieFrame Event;
genie.DequeueEvent(&Event);
if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
{
if (Event.reportObject.index == 2) // index= 2 UP
{
Serial.println("UP");
}
if (Event.reportObject.index == 3) // index= 3 DOWN
{
Serial.println("DOWN");
}
if (Event.reportObject.index == 4) // index= 4 RH
{
rha=0
while (rha<1)
{
genie.DoEvents();
if (Event.reportObject.index == 2 || Event.reportObject.index == 3)
{
rha++;
goto start;
}
else
{
Serial.println("RH request");
}
}
}
}
}
How can i solve this problem.
Note: I have Pro licence so you can advice me magic event etc.
Comment