Documentation
For Arduino users
NexTimer.cpp
Go to the documentation of this file.
1 
16 #include "NexTimer.h"
17 
18 NexTimer::NexTimer(uint8_t pid, uint8_t cid, const char *name)
19  :NexTouch(pid, cid, name)
20 {
21 }
22 
23 void NexTimer::attachTimer(NexTouchEventCb timer, void *ptr)
24 {
25  NexTouch::attachPop(timer, ptr);
26 }
27 
29 {
31 }
32 
33 bool NexTimer::getCycle(uint32_t *number)
34 {
35  String cmd = String("get ");
36  cmd += getObjName();
37  cmd += ".tim";
38  sendCommand(cmd.c_str());
39  return recvRetNumber(number);
40 }
41 
42 bool NexTimer::setCycle(uint32_t number)
43 {
44  char buf[10] = {0};
45  String cmd;
46  if (number < 50)
47  {
48  number = 50;
49  }
50  utoa(number, buf, 10);
51  cmd += getObjName();
52  cmd += ".tim=";
53  cmd += buf;
54 
55  sendCommand(cmd.c_str());
56  return recvRetCommandFinished();
57 }
58 
59 
60 bool NexTimer::enable(void)
61 {
62  char buf[10] = {0};
63  String cmd;
64  utoa(1, buf, 10);
65  cmd += getObjName();
66  cmd += ".en=";
67  cmd += buf;
68 
69  sendCommand(cmd.c_str());
70  return recvRetCommandFinished();
71 }
72 
74 {
75  char buf[10] = {0};
76  String cmd;
77  utoa(0, buf, 10);
78  cmd += getObjName();
79  cmd += ".en=";
80  cmd += buf;
81 
82  sendCommand(cmd.c_str());
83  return recvRetCommandFinished();
84 }
85 
86 uint32_t NexTimer::Get_cycle_tim(uint32_t *number)
87 {
88  String cmd = String("get ");
89  cmd += getObjName();
90  cmd += ".tim";
91  sendCommand(cmd.c_str());
92  return recvRetNumber(number);
93 }
94 
95 bool NexTimer::Set_cycle_tim(uint32_t number)
96 {
97  char buf[10] = {0};
98  String cmd;
99  if (number < 8)
100  {
101  number = 8;
102  }
103  utoa(number, buf, 10);
104  cmd += getObjName();
105  cmd += ".tim=";
106  cmd += buf;
107  sendCommand(cmd.c_str());
108 
109  cmd = "";
110  cmd += "ref ";
111  cmd += getObjName();
112  sendCommand(cmd.c_str());
113  return recvRetCommandFinished();
114 }
115 
uint32_t Get_cycle_tim(uint32_t *number)
Get tim attribute of component.
Definition: NexTimer.cpp:86
void detachPop(void)
Detach an callback function.
Definition: NexTouch.cpp:45
bool enable(void)
contorl timer enable.
Definition: NexTimer.cpp:60
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
void(* NexTouchEventCb)(void *ptr)
Type of callback funciton when an touch event occurs.
Definition: NexTouch.h:45
void detachTimer(void)
Detach an callback function.
Definition: NexTimer.cpp:28
NexTimer(uint8_t pid, uint8_t cid, const char *name)
Constructor.
Definition: NexTimer.cpp:18
bool getCycle(uint32_t *number)
Get the value of timer cycle val.
Definition: NexTimer.cpp:33
bool Set_cycle_tim(uint32_t number)
Set tim attribute of component.
Definition: NexTimer.cpp:95
The definition of class NexTimer.
bool setCycle(uint32_t number)
Set the value of timer cycle val.
Definition: NexTimer.cpp:42
void attachTimer(NexTouchEventCb timer, void *ptr=NULL)
Attach an callback function of timer respond event.
Definition: NexTimer.cpp:23
Father class of the components with touch events.
Definition: NexTouch.h:53
bool disable(void)
contorl timer disable.
Definition: NexTimer.cpp:73