API
For Arduino developers
NexCrop.cpp
Go to the documentation of this file.
1 
16 #include "NexCrop.h"
17 
22 NexCrop::NexCrop(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
23  :NexTouch(pid, cid, name, pop, pop_ptr)
24 {
25 }
26 
27 /*
28  * Get the number of picture.
29  *
30  * @param number - an output parameter to save the number of picture.
31  *
32  * @retval true - success.
33  * @retval false - failed.
34  */
35 bool NexCrop::getPic(uint32_t *number)
36 {
37  String cmd = String("get ");
38  cmd += getObjName();
39  cmd += ".picc";
40  sendCommand(cmd.c_str());
41  return recvRetNumber(number);
42 }
43 
44 /*
45  * Set the number of picture.
46  *
47  * @param number - the number of picture.
48  *
49  * @retval true - success.
50  * @retval false - failed.
51  */
52 bool NexCrop::setPic(uint32_t number)
53 {
54  char buf[10] = {0};
55  String cmd;
56 
57  utoa(number, buf, 10);
58  cmd += getObjName();
59  cmd += ".picc=";
60  cmd += buf;
61 
62  sendCommand(cmd.c_str());
63  return recvRetCommandFinished();
64 }
65 
72 void NexCrop::attachPop(NexTouchEventCb pop, void *ptr)
73 {
74  NexTouch::attachPop(pop, ptr);
75 }
76 
82 {
83  NexTouch::detachPop();
84 }
85 
NexCrop(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop=NULL, void *pop_ptr=NULL)
Constructor,inherited NexTouch's constructor function.
Definition: NexCrop.cpp:22
void detachPop(void)
Unload crop pop callback function.
Definition: NexCrop.cpp:81
static void sendCommand(const char *cmd)
Send command to Nextion.
Definition: NexTouch.cpp:256
const char * getObjName(void)
Get component name.
Definition: NexTouch.cpp:107
API of NexCrop.
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Register crop pop callback function.
Definition: NexCrop.cpp:72
static bool recvRetNumber(uint32_t *number, uint32_t timeout=500)
Receive uint32_t data.
Definition: NexTouch.cpp:351
static bool recvRetCommandFinished(uint32_t timeout=100)
Command is executed successfully.
Definition: NexTouch.cpp:219
Root Class of Nextion Components.
Definition: NexTouch.h:57