17#ifndef CYBER_PYTHON_INTERNAL_PY_TIMER_H_
18#define CYBER_PYTHON_INTERNAL_PY_TIMER_H_
33 PyTimer() { timer_ = std::make_shared<Timer>(); }
35 PyTimer(uint32_t period,
void (*func)(),
bool oneshot) {
36 std::function<void()> bound_f = std::bind(func);
37 timer_ = std::make_shared<Timer>(period, bound_f, oneshot);
40 void start() { timer_->Start(); }
42 void stop() { timer_->Stop(); }
44 void set_option(uint32_t period,
void (*func)(),
bool oneshot) {
45 std::function<void()> bound_f = std::bind(func);
50 timer_->SetTimerOption(time_opt);
54 std::shared_ptr<Timer> timer_ =
nullptr;
PyTimer(uint32_t period, void(*func)(), bool oneshot)
void set_option(uint32_t period, void(*func)(), bool oneshot)
uint32_t period
The period of the timer, unit is ms max: 512 * 64 min: 1
bool oneshot
True: perform the callback only after the first timing cycle False: perform the callback every timed ...
std::function< void()> callback
The task that the timer needs to perform