API
For Arduino developers
NexPicture.cpp
Go to the documentation of this file.
1 
16 #include "NexPicture.h"
17 
22 NexPicture::NexPicture(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
23  :NexTouch(pid, cid, name, pop, pop_ptr)
24 {
25 }
26 
35 bool NexPicture::getPic(uint32_t *number)
36 {
37  String cmd = String("get ");
38  cmd += getObjName();
39  cmd += ".pic";
40  sendCommand(cmd.c_str());
41  return recvRetNumber(number);
42 }
43 
52 bool NexPicture::setPic(uint32_t number)
53 {
54  char buf[10] = {0};
55  String cmd;
56 
57  utoa(number, buf, 10);
58  cmd += getObjName();
59  cmd += ".pic=";
60  cmd += buf;
61 
62  sendCommand(cmd.c_str());
63  return recvRetCommandFinished();
64 }
65 
72 void NexPicture::attachPop(NexTouchEventCb pop, void *ptr)
73 {
74  NexTouch::attachPop(pop, ptr);
75 }
76 
82 {
83  NexTouch::detachPop();
84 }
85 
void detachPop(void)
Unload picture pop callback function.
Definition: NexPicture.cpp:81
bool setPic(uint32_t number)
Set picture's number.
Definition: NexPicture.cpp:52
NexPicture(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop=NULL, void *pop_ptr=NULL)
Constructor,inherited NexTouch's constructor function.
Definition: NexPicture.cpp:22
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
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Register picture pop callback function.
Definition: NexPicture.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
bool getPic(uint32_t *number)
Get picture's number.
Definition: NexPicture.cpp:35
Root Class of Nextion Components.
Definition: NexTouch.h:57
API of NexPicture.