NexTimer.cpp
Go to the documentation of this file.
#include "NexTimer.h"
NexTimer::NexTimer(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
void NexTimer::attachTimer(NexTouchEventCb timer, void *ptr)
{
NexTouch::attachPop(timer, ptr);
}
void NexTimer::detachTimer(void)
{
NexTouch::detachPop();
}
bool NexTimer::getCycle(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".tim";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexTimer::setCycle(uint32_t number)
{
char buf[10] = {0};
String cmd;
if (number < 50)
{
number = 50;
}
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".tim=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
bool NexTimer::enable(void)
{
char buf[10] = {0};
String cmd;
utoa(1, buf, 10);
cmd += getObjName();
cmd += ".en=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
bool NexTimer::disable(void)
{
char buf[10] = {0};
String cmd;
utoa(0, buf, 10);
cmd += getObjName();
cmd += ".en=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
uint32_t NexTimer::Get_cycle_tim(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".tim";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexTimer::Set_cycle_tim(uint32_t number)
{
char buf[10] = {0};
String cmd;
if (number < 8)
{
number = 8;
}
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".tim=";
cmd += buf;
sendCommand(cmd.c_str());
cmd = "";
cmd += "ref ";
cmd += getObjName();
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
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