HI,there
I made a simple code to turn on/off LED
#include "NexButton.h"
#include "NexText.h"
NexButton b0 = NexButton(0, 1, "b0");
NexButton b1 = NexButton(0, 6, "b1");
char buffer[10] = {0};
NexTouch *nex_Listen_List[] =
{
&b0,
&b1,
NULL
};
/**
- Button to return the response.
- @param ptr - the parameter was transmitted to pop event function pointer.
*/
void aa(void *ptr)
{
NexButton *btn = (NexButton *)ptr;
memset(buffer, 0, sizeof(buffer));
btn->getText(buffer, sizeof(buffer));
if (strcmp(buffer,"ON"))
{
digitalWrite(13, HIGH);
strcpy(buffer, "ON");
}
btn->setText(buffer);
}
/**
- Button to return the response.
- @param ptr - the parameter was transmitted to pop event function pointer.
*/
void bb(void *ptr)
{
NexButton *btn = (NexButton *)ptr;
memset(buffer, 0, sizeof(buffer));
btn->getText(buffer, sizeof(buffer));
if (strcmp(buffer,"off"))
{
digitalWrite(13, LOW);
strcpy(buffer, "off");
}
btn->setText(buffer);
}
void setup(void)
{
nexInit();
b0.attachPop(aa, &b0);
b1.attachPop(bb, &b1);
//setting port OUTPUT
pinMode(13, OUTPUT);
//initializing port
digitalWrite(13, LOW);
}
void loop(void)
{
nexLoop(nex_Listen_List);
}
and I made a hmi file when I press b0 ,
aa function will turn on LED and start to count down,
when I press b1 LED will turn off and count down over.
but I am curious ,
Could "click" function can instead of touch screen to off the LED
because my project can't turn off LED
though "click" had "touch" b1 button
I am sorry for my bad English
hope you guys know what I said
btw my nextion is 7''