Skip to content

Commit 1b8b1d8

Browse files
author
shennongmin
committed
Update doc.
Signed-off-by: shennongmin <[email protected]>
1 parent 763a2e3 commit 1b8b1d8

File tree

145 files changed

+2208
-1289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+2208
-1289
lines changed

NexButton.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
class NexButton: public NexTouch
2828
{
2929
public: /* methods */
30+
31+
/**
32+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
33+
*/
3034
NexButton(uint8_t pid, uint8_t cid, const char *name);
3135

3236
uint16_t getText(char *buffer, uint16_t len);

NexConfig.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@
1515
#ifndef __NEXCONFIG_H__
1616
#define __NEXCONFIG_H__
1717

18-
/* enable debug serial */
18+
/**
19+
* Define DEBUG_SERIAL_ENABLE to enable debug serial.
20+
* Comment it to disable debug serial.
21+
*/
1922
#define DEBUG_SERIAL_ENABLE
2023

21-
/* define serial for debug */
24+
/**
25+
* Define dbSerial for the output of debug messages.
26+
*/
2227
#define dbSerial Serial
2328

24-
/* define serial for communicate with Nextion screen */
29+
/**
30+
* Define nexSerial for communicate with Nextion touch panel.
31+
*/
2532
#define nexSerial Serial2
2633

34+
2735
#ifdef DEBUG_SERIAL_ENABLE
2836
#define dbSerialPrint(a) dbSerial.print(a)
2937
#define dbSerialPrintln(a) dbSerial.println(a)

NexCrop.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
class NexCrop: public NexTouch
2828
{
2929
public: /* methods */
30+
31+
/**
32+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
33+
*/
3034
NexCrop(uint8_t pid, uint8_t cid, const char *name);
3135

3236
bool getPic(uint32_t *number);

NexGauge.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class NexGauge: public NexObject
2828
{
2929
public: /* methods */
30+
/**
31+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
32+
*/
3033
NexGauge(uint8_t pid, uint8_t cid, const char *name);
3134

3235
bool getValue(uint32_t *number);

NexHardware.cpp

+17-51
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,24 @@ bool recvRetCommandFinished(uint32_t timeout)
217217
}
218218

219219

220+
bool nexInit(void)
221+
{
222+
bool ret1 = false;
223+
bool ret2 = false;
224+
225+
dbSerialBegin(9600);
226+
nexSerial.begin(9600);
227+
sendCommand("");
228+
sendCommand("bkcmd=1");
229+
ret1 = recvRetCommandFinished();
230+
sendCommand("page 0");
231+
ret2 = recvRetCommandFinished();
232+
return ret1 && ret2;
233+
}
220234

221-
/**
222-
* Watting for Nextion's touch event.
223-
*
224-
* @param list - index to Nextion Components list.
225-
*
226-
*/
227-
static void mainEventLoop(NexTouch **list)
235+
void nexLoop(NexTouch **nex_listen_list)
228236
{
229-
static uint8_t __buffer[16];
237+
static uint8_t __buffer[10];
230238

231239
uint16_t i;
232240
uint8_t c;
@@ -249,53 +257,11 @@ static void mainEventLoop(NexTouch **list)
249257

250258
if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
251259
{
252-
NexTouch::iterate(list, __buffer[1], __buffer[2], (int32_t)__buffer[3]);
260+
NexTouch::iterate(nex_listen_list, __buffer[1], __buffer[2], (int32_t)__buffer[3]);
253261
}
254262

255263
}
256264
}
257265
}
258266
}
259267

260-
/**
261-
* @addtogroup Nextion
262-
* @{
263-
*/
264-
265-
266-
/**
267-
* Init Nextion's baudrate,page id.
268-
*
269-
* @retval true - success.
270-
* @retval false - failed.
271-
*/
272-
bool nexInit(void)
273-
{
274-
bool ret1 = false;
275-
bool ret2 = false;
276-
277-
dbSerialBegin(9600);
278-
nexSerial.begin(9600);
279-
sendCommand("");
280-
sendCommand("bkcmd=1");
281-
ret1 = recvRetCommandFinished();
282-
sendCommand("page 0");
283-
ret2 = recvRetCommandFinished();
284-
return ret1 && ret2;
285-
}
286-
287-
/**
288-
* Call mainEventLoop,watting for Nextion's touch event.
289-
*
290-
* @param nex_listen_list - index to Nextion Components list.
291-
*
292-
*/
293-
void nexLoop(NexTouch **nex_listen_list)
294-
{
295-
mainEventLoop(nex_listen_list);
296-
}
297-
298-
/**
299-
* @}
300-
*/
301-

NexHardware.h

+29-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,38 @@
1818
#include "NexConfig.h"
1919
#include "NexTouch.h"
2020

21+
/**
22+
* @addtogroup Nextion
23+
* @{
24+
*/
25+
26+
/**
27+
* Init Nextion.
28+
*
29+
* @return true if success, false for failure.
30+
*/
31+
bool nexInit(void);
32+
33+
/**
34+
* Listen touch event and calling callbacks attached before.
35+
*
36+
* Supports push and pop at present.
37+
*
38+
* @param nex_listen_list - index to Nextion Components list.
39+
* @return none.
40+
*
41+
* @warning This function must be called repeatedly to response touch events
42+
* from Nextion touch panel. Actually, you should place it in your loop function.
43+
*/
44+
void nexLoop(NexTouch **nex_listen_list);
45+
46+
/**
47+
* @}
48+
*/
49+
2150
bool recvRetNumber(uint32_t *number, uint32_t timeout = 100);
2251
uint16_t recvRetString(char *buffer, uint16_t len, uint32_t timeout = 100);
2352
void sendCommand(const char* cmd);
2453
bool recvRetCommandFinished(uint32_t timeout = 100);
2554

26-
bool nexInit(void);
27-
void nexLoop(NexTouch **nex_listen_list);
28-
2955
#endif /* #ifndef __NEXHARDWARE_H__ */

NexHotspot.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class NexHotspot: public NexTouch
2828
{
2929
public: /* methods */
30+
/**
31+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
32+
*/
3033
NexHotspot(uint8_t pid, uint8_t cid, const char *name);
3134
};
3235

NexPage.h

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
class NexPage: public NexTouch
3030
{
3131
public: /* methods */
32+
/**
33+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
34+
*/
3235
NexPage(uint8_t pid, uint8_t cid, const char *name);
3336
bool show(void);
3437
};

NexPicture.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class NexPicture: public NexTouch
2828
{
2929
public: /* methods */
30+
/**
31+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
32+
*/
3033
NexPicture(uint8_t pid, uint8_t cid, const char *name);
3134

3235
bool getPic(uint32_t *number);

NexProgressBar.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class NexProgressBar: public NexObject
2828
{
2929
public: /* methods */
30+
/**
31+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
32+
*/
3033
NexProgressBar(uint8_t pid, uint8_t cid, const char *name);
3134

3235
bool getValue(uint32_t *number);

NexSlider.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class NexSlider: public NexTouch
2828
{
2929
public: /* methods */
30+
/**
31+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
32+
*/
3033
NexSlider(uint8_t pid, uint8_t cid, const char *name);
3134

3235
bool getValue(uint32_t *number);

NexText.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class NexText: public NexTouch
2828
{
2929
public: /* methods */
30+
/**
31+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
32+
*/
3033
NexText(uint8_t pid, uint8_t cid, const char *name);
3134

3235
uint16_t getText(char *buffer, uint16_t len);

NexTouch.cpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,52 @@
1515
#include "NexTouch.h"
1616

1717

18-
/**
19-
* Constructor of Nextouch.
20-
*
21-
* @param pid - pid
22-
* @param cid - cid
23-
* @param name - name
24-
*
25-
*/
2618
NexTouch::NexTouch(uint8_t pid, uint8_t cid, const char *name)
2719
:NexObject(pid, cid, name)
2820
{
29-
this->cbPush = NULL;
30-
this->cbPop = NULL;
21+
this->__cb_push = NULL;
22+
this->__cb_pop = NULL;
3123
this->__cbpop_ptr = NULL;
3224
this->__cbpush_ptr = NULL;
3325
}
3426

3527
void NexTouch::attachPush(NexTouchEventCb push, void *ptr)
3628
{
37-
this->cbPush = push;
29+
this->__cb_push = push;
3830
this->__cbpush_ptr = ptr;
3931
}
4032

4133
void NexTouch::detachPush(void)
4234
{
43-
this->cbPush = NULL;
35+
this->__cb_push = NULL;
4436
this->__cbpush_ptr = NULL;
4537
}
4638

4739
void NexTouch::attachPop(NexTouchEventCb pop, void *ptr)
4840
{
49-
this->cbPop = pop;
41+
this->__cb_pop = pop;
5042
this->__cbpop_ptr = ptr;
5143
}
5244

5345
void NexTouch::detachPop(void)
5446
{
55-
this->cbPop = NULL;
47+
this->__cb_pop = NULL;
5648
this->__cbpop_ptr = NULL;
5749
}
5850

5951
void NexTouch::push(void)
6052
{
61-
if (cbPush)
53+
if (__cb_push)
6254
{
63-
cbPush(__cbpush_ptr);
55+
__cb_push(__cbpush_ptr);
6456
}
6557
}
6658

6759
void NexTouch::pop(void)
6860
{
69-
if (cbPop)
61+
if (__cb_pop)
7062
{
71-
cbPop(__cbpop_ptr);
63+
__cb_pop(__cbpop_ptr);
7264
}
7365
}
7466

0 commit comments

Comments
 (0)