Documentation: NexTimer.cpp Source File

| Documentation For Arduino users

- Main Page
- Related Pages
- Modules
- Classes
- Files
- Examples

- File List
- File Members

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
28 void NexTimer::detachTimer(void)
29 {
30 NexTouch::detachPop();
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
73 bool NexTimer::disable(void)
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
NexTimer::Get_cycle_tim
uint32_t Get_cycle_tim(uint32_t *number)
Get tim attribute of component.
Definition: NexTimer.cpp:86
NexTouch::detachPop
void detachPop(void)
Detach an callback function.
Definition: NexTouch.cpp:45
NexTimer::enable
bool enable(void)
contorl timer enable.
Definition: NexTimer.cpp:60
NexTouch::attachPop
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
NexTouchEventCb
void(* NexTouchEventCb)(void *ptr)
Type of callback funciton when an touch event occurs.
Definition: NexTouch.h:45
NexTimer::detachTimer
void detachTimer(void)
Detach an callback function.
Definition: NexTimer.cpp:28
NexTimer::NexTimer
NexTimer(uint8_t pid, uint8_t cid, const char *name)
Constructor.
Definition: NexTimer.cpp:18
NexTimer::getCycle
bool getCycle(uint32_t *number)
Get the value of timer cycle val.
Definition: NexTimer.cpp:33
NexTimer::Set_cycle_tim
bool Set_cycle_tim(uint32_t number)
Set tim attribute of component.
Definition: NexTimer.cpp:95
NexTimer.h
The definition of class NexTimer.
NexTimer::setCycle
bool setCycle(uint32_t number)
Set the value of timer cycle val.
Definition: NexTimer.cpp:42
NexTimer::attachTimer
void attachTimer(NexTouchEventCb timer, void *ptr=NULL)
Attach an callback function of timer respond event.
Definition: NexTimer.cpp:23
NexTouch
Father class of the components with touch events.
Definition: NexTouch.h:53
NexTimer::disable
bool disable(void)
contorl timer disable.
Definition: NexTimer.cpp:73