mirror of
https://github.com/itead/ITEADLIB_Arduino_Nextion.git
synced 2026-03-24 10:56:54 +01:00
add note to all files
This commit is contained in:
@@ -1,46 +1,61 @@
|
||||
#include "NexButton.h"
|
||||
|
||||
NexButton b0 = NexButton(0, 1, "b0");
|
||||
char buffer[100] = {0};
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&b0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void b0PopCallback(void *ptr)
|
||||
{
|
||||
uint16_t len;
|
||||
uint16_t number;
|
||||
NexButton *btn = (NexButton *)ptr;
|
||||
|
||||
dbSerial.println("b0PopCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
btn->getText(buffer, sizeof(buffer));
|
||||
|
||||
number = atoi(buffer);
|
||||
number += 1;
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
itoa(number, buffer, 10);
|
||||
|
||||
btn->setText(buffer);
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
b0.attachPop(b0PopCallback, &b0);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexButton.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexButton.h"
|
||||
|
||||
NexButton b0 = NexButton(0, 1, "b0");
|
||||
char buffer[100] = {0};
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&b0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void b0PopCallback(void *ptr)
|
||||
{
|
||||
uint16_t len;
|
||||
uint16_t number;
|
||||
NexButton *btn = (NexButton *)ptr;
|
||||
|
||||
dbSerial.println("b0PopCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
btn->getText(buffer, sizeof(buffer));
|
||||
|
||||
number = atoi(buffer);
|
||||
number += 1;
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
itoa(number, buffer, 10);
|
||||
|
||||
btn->setText(buffer);
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
b0.attachPop(b0PopCallback, &b0);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
@@ -1,56 +1,71 @@
|
||||
#include "NexHotspot.h"
|
||||
|
||||
NexHotspot hot0 = NexHotspot(0, 1, "hot0");
|
||||
NexHotspot hot1 = NexHotspot(0, 2, "hot1");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&hot0,
|
||||
&hot1,
|
||||
NULL
|
||||
};
|
||||
|
||||
void hot0PushCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot0PushCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void hot1PushCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot1PushCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void hot0PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot0PopCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void hot1PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot1PopCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
hot0.attachPush(hot0PushCallback, &hot0);
|
||||
hot0.attachPop(hot0PopCallback, &hot0);
|
||||
hot1.attachPush(hot1PushCallback, &hot1);
|
||||
hot1.attachPop(hot1PopCallback, &hot1);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexHotspot.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexHotspot.h"
|
||||
|
||||
NexHotspot hot0 = NexHotspot(0, 1, "hot0");
|
||||
NexHotspot hot1 = NexHotspot(0, 2, "hot1");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&hot0,
|
||||
&hot1,
|
||||
NULL
|
||||
};
|
||||
|
||||
void hot0PushCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot0PushCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void hot1PushCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot1PushCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void hot0PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot0PopCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void hot1PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("hot1PopCallback");
|
||||
dbSerial.print("ptr=");
|
||||
dbSerial.println((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
hot0.attachPush(hot0PushCallback, &hot0);
|
||||
hot0.attachPop(hot0PopCallback, &hot0);
|
||||
hot1.attachPush(hot1PushCallback, &hot1);
|
||||
hot1.attachPop(hot1PopCallback, &hot1);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
@@ -1,59 +1,74 @@
|
||||
#include "NexPage.h"
|
||||
|
||||
NexPage page0 = NexPage(0, 0, "page0");
|
||||
NexPage page1 = NexPage(1, 0, "page1");
|
||||
NexPage page2 = NexPage(2, 0, "page2");
|
||||
NexPage page3 = NexPage(3, 0, "page3");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&page0,
|
||||
&page1,
|
||||
&page2,
|
||||
&page3,
|
||||
NULL
|
||||
};
|
||||
|
||||
void page0PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page0PopCallback");
|
||||
page1.show();
|
||||
}
|
||||
|
||||
void page1PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page1PopCallback");
|
||||
page2.show();
|
||||
}
|
||||
|
||||
void page2PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page2PopCallback");
|
||||
page3.show();
|
||||
}
|
||||
|
||||
void page3PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page3PopCallback");
|
||||
page0.show();
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
dbSerial.println("setup begin");
|
||||
|
||||
page0.attachPop(page0PopCallback);
|
||||
page1.attachPop(page1PopCallback);
|
||||
page2.attachPop(page2PopCallback);
|
||||
page3.attachPop(page3PopCallback);
|
||||
|
||||
dbSerial.println("setup end");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexPage.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexPage.h"
|
||||
|
||||
NexPage page0 = NexPage(0, 0, "page0");
|
||||
NexPage page1 = NexPage(1, 0, "page1");
|
||||
NexPage page2 = NexPage(2, 0, "page2");
|
||||
NexPage page3 = NexPage(3, 0, "page3");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&page0,
|
||||
&page1,
|
||||
&page2,
|
||||
&page3,
|
||||
NULL
|
||||
};
|
||||
|
||||
void page0PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page0PopCallback");
|
||||
page1.show();
|
||||
}
|
||||
|
||||
void page1PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page1PopCallback");
|
||||
page2.show();
|
||||
}
|
||||
|
||||
void page2PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page2PopCallback");
|
||||
page3.show();
|
||||
}
|
||||
|
||||
void page3PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("page3PopCallback");
|
||||
page0.show();
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
dbSerial.println("setup begin");
|
||||
|
||||
page0.attachPop(page0PopCallback);
|
||||
page1.attachPop(page1PopCallback);
|
||||
page2.attachPop(page2PopCallback);
|
||||
page3.attachPop(page3PopCallback);
|
||||
|
||||
dbSerial.println("setup end");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
@@ -1,44 +1,59 @@
|
||||
#include "NexPicture.h"
|
||||
|
||||
NexPicture p0 = NexPicture(0, 1, "p0");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&p0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void p0PopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("p0PopCallback");
|
||||
|
||||
p0.getPic(&number);
|
||||
|
||||
if (number == 1)
|
||||
{
|
||||
number = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1;
|
||||
}
|
||||
|
||||
p0.setPic(number);
|
||||
}
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
p0.attachPop(p0PopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexPicture.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexPicture.h"
|
||||
|
||||
NexPicture p0 = NexPicture(0, 1, "p0");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&p0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void p0PopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("p0PopCallback");
|
||||
|
||||
p0.getPic(&number);
|
||||
|
||||
if (number == 1)
|
||||
{
|
||||
number = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1;
|
||||
}
|
||||
|
||||
p0.setPic(number);
|
||||
}
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
p0.attachPop(p0PopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,61 +1,76 @@
|
||||
#include "NexPointer.h"
|
||||
#include "NexButton.h"
|
||||
|
||||
NexPointer pointer = NexPointer(0, 1, "pointer");
|
||||
NexButton btn_up = NexButton(0, 2, "btn_up");
|
||||
NexButton btn_down = NexButton(0, 3, "btn_down");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&btn_up,
|
||||
&btn_down,
|
||||
NULL
|
||||
};
|
||||
|
||||
void buttonUpPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonUpPopCallback");
|
||||
|
||||
pointer.getValue(&number);
|
||||
|
||||
number += 5;
|
||||
if (number >= 360)
|
||||
{
|
||||
number = 0;
|
||||
}
|
||||
|
||||
pointer.setValue(number);
|
||||
}
|
||||
void buttonDownPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonDownPopCallback");
|
||||
|
||||
pointer.getValue(&number);
|
||||
|
||||
if (number >= 5)
|
||||
{
|
||||
number -= 5;
|
||||
}
|
||||
|
||||
pointer.setValue(number);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
btn_up.attachPop(buttonUpPopCallback);
|
||||
btn_down.attachPop(buttonDownPopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexPointer.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexPointer.h"
|
||||
#include "NexButton.h"
|
||||
|
||||
NexPointer pointer = NexPointer(0, 1, "pointer");
|
||||
NexButton btn_up = NexButton(0, 2, "btn_up");
|
||||
NexButton btn_down = NexButton(0, 3, "btn_down");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&btn_up,
|
||||
&btn_down,
|
||||
NULL
|
||||
};
|
||||
|
||||
void buttonUpPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonUpPopCallback");
|
||||
|
||||
pointer.getValue(&number);
|
||||
|
||||
number += 5;
|
||||
if (number >= 360)
|
||||
{
|
||||
number = 0;
|
||||
}
|
||||
|
||||
pointer.setValue(number);
|
||||
}
|
||||
void buttonDownPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonDownPopCallback");
|
||||
|
||||
pointer.getValue(&number);
|
||||
|
||||
if (number >= 5)
|
||||
{
|
||||
number -= 5;
|
||||
}
|
||||
|
||||
pointer.setValue(number);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
btn_up.attachPop(buttonUpPopCallback);
|
||||
btn_down.attachPop(buttonDownPopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,63 +1,78 @@
|
||||
#include "NexProgressBar.h"
|
||||
#include "NexButton.h"
|
||||
|
||||
NexProgressBar j0 = NexProgressBar(0, 3, "j0");
|
||||
NexButton btn_up = NexButton(0, 1, "btn_up");
|
||||
NexButton btn_down = NexButton(0, 2, "btn_down");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&btn_up,
|
||||
&btn_down,
|
||||
NULL
|
||||
};
|
||||
|
||||
void buttonUpPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonUpPopCallback");
|
||||
|
||||
j0.getValue(&number);
|
||||
|
||||
number += 5;
|
||||
if (number >= 100)
|
||||
{
|
||||
number = 100;
|
||||
}
|
||||
|
||||
j0.setValue(number);
|
||||
}
|
||||
void buttonDownPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonDownPopCallback");
|
||||
|
||||
j0.getValue(&number);
|
||||
|
||||
if (number >= 5)
|
||||
{
|
||||
number -= 5;
|
||||
}
|
||||
|
||||
j0.setValue(number);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
uint32_t brightness = 0;
|
||||
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
btn_up.attachPop(buttonUpPopCallback);
|
||||
btn_down.attachPop(buttonDownPopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexProgressBar.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexProgressBar.h"
|
||||
#include "NexButton.h"
|
||||
|
||||
NexProgressBar j0 = NexProgressBar(0, 3, "j0");
|
||||
NexButton btn_up = NexButton(0, 1, "btn_up");
|
||||
NexButton btn_down = NexButton(0, 2, "btn_down");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&btn_up,
|
||||
&btn_down,
|
||||
NULL
|
||||
};
|
||||
|
||||
void buttonUpPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonUpPopCallback");
|
||||
|
||||
j0.getValue(&number);
|
||||
|
||||
number += 5;
|
||||
if (number >= 100)
|
||||
{
|
||||
number = 100;
|
||||
}
|
||||
|
||||
j0.setValue(number);
|
||||
}
|
||||
void buttonDownPopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("buttonDownPopCallback");
|
||||
|
||||
j0.getValue(&number);
|
||||
|
||||
if (number >= 5)
|
||||
{
|
||||
number -= 5;
|
||||
}
|
||||
|
||||
j0.setValue(number);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
uint32_t brightness = 0;
|
||||
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
btn_up.attachPop(buttonUpPopCallback);
|
||||
btn_down.attachPop(buttonDownPopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,53 @@
|
||||
#include "NexSlice.h"
|
||||
|
||||
NexSlice q0 = NexSlice(0, 1, "q0");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&q0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void q0PopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("q0PopCallback");
|
||||
|
||||
q0.getPic(&number);
|
||||
|
||||
number += 1;
|
||||
number %= 2;
|
||||
|
||||
q0.setPic(number);
|
||||
}
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
q0.attachPop(q0PopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexSlice.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexSlice.h"
|
||||
|
||||
NexSlice q0 = NexSlice(0, 1, "q0");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&q0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void q0PopCallback(void *ptr)
|
||||
{
|
||||
uint32_t number = 0;
|
||||
dbSerial.println("q0PopCallback");
|
||||
|
||||
q0.getPic(&number);
|
||||
|
||||
number += 1;
|
||||
number %= 2;
|
||||
|
||||
q0.setPic(number);
|
||||
}
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
q0.attachPop(q0PopCallback);
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,78 +1,93 @@
|
||||
#include "NexButton.h"
|
||||
#include "NexText.h"
|
||||
|
||||
void t0PopCallback(void *ptr);
|
||||
void b0PopCallback(void *ptr);
|
||||
void b1PopCallback(void *ptr);
|
||||
|
||||
NexText t0 = NexText(0, 1, "t0", t0PopCallback);
|
||||
NexButton b0 = NexButton(0, 2, "b0", b0PopCallback);
|
||||
NexButton b1 = NexButton(0, 3, "b1", b1PopCallback);
|
||||
|
||||
char buffer[100] = {0};
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&t0,
|
||||
&b0,
|
||||
&b1,
|
||||
NULL
|
||||
};
|
||||
|
||||
void t0PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("t0PopCallback");
|
||||
t0.setText("50");
|
||||
}
|
||||
|
||||
void b0PopCallback(void *ptr)
|
||||
{
|
||||
uint16_t len;
|
||||
uint16_t number;
|
||||
|
||||
dbSerial.println("b0PopCallback");
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
t0.getText(buffer, sizeof(buffer));
|
||||
|
||||
number = atoi(buffer);
|
||||
number += 1;
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
itoa(number, buffer, 10);
|
||||
|
||||
t0.setText(buffer);
|
||||
}
|
||||
|
||||
void b1PopCallback(void *ptr)
|
||||
{
|
||||
uint16_t len;
|
||||
uint16_t number;
|
||||
|
||||
dbSerial.println("b1PopCallback");
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
t0.getText(buffer, sizeof(buffer));
|
||||
|
||||
number = atoi(buffer);
|
||||
number -= 1;
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
itoa(number, buffer, 10);
|
||||
|
||||
t0.setText(buffer);
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example NexTouch.cpp
|
||||
*
|
||||
* @par Show how to use API of class NexText.
|
||||
*
|
||||
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
|
||||
* @date 2015/7/10
|
||||
* @copyright
|
||||
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "NexButton.h"
|
||||
#include "NexText.h"
|
||||
|
||||
void t0PopCallback(void *ptr);
|
||||
void b0PopCallback(void *ptr);
|
||||
void b1PopCallback(void *ptr);
|
||||
|
||||
NexText t0 = NexText(0, 1, "t0", t0PopCallback);
|
||||
NexButton b0 = NexButton(0, 2, "b0", b0PopCallback);
|
||||
NexButton b1 = NexButton(0, 3, "b1", b1PopCallback);
|
||||
|
||||
char buffer[100] = {0};
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
{
|
||||
&t0,
|
||||
&b0,
|
||||
&b1,
|
||||
NULL
|
||||
};
|
||||
|
||||
void t0PopCallback(void *ptr)
|
||||
{
|
||||
dbSerial.println("t0PopCallback");
|
||||
t0.setText("50");
|
||||
}
|
||||
|
||||
void b0PopCallback(void *ptr)
|
||||
{
|
||||
uint16_t len;
|
||||
uint16_t number;
|
||||
|
||||
dbSerial.println("b0PopCallback");
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
t0.getText(buffer, sizeof(buffer));
|
||||
|
||||
number = atoi(buffer);
|
||||
number += 1;
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
itoa(number, buffer, 10);
|
||||
|
||||
t0.setText(buffer);
|
||||
}
|
||||
|
||||
void b1PopCallback(void *ptr)
|
||||
{
|
||||
uint16_t len;
|
||||
uint16_t number;
|
||||
|
||||
dbSerial.println("b1PopCallback");
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
t0.getText(buffer, sizeof(buffer));
|
||||
|
||||
number = atoi(buffer);
|
||||
number -= 1;
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
itoa(number, buffer, 10);
|
||||
|
||||
t0.setText(buffer);
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
dbSerial.begin(9600);
|
||||
nexInit();
|
||||
dbSerial.println("setup done");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerial.println("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user