PyPhoenixClockBackend  1.1.0
Binding for PhoenixClock library
Loading...
Searching...
No Matches
timer_binding.h File Reference
#include "PTimer.h"
#include <ctime>
#include <nanobind/nanobind.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/chrono.h>
+ Include dependency graph for timer_binding.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void make_timer_binding (nb::module_ &m)
 

Function Documentation

◆ make_timer_binding()

void make_timer_binding ( nb::module_ & m)
inline

Definition at line 18 of file timer_binding.h.

18 {
19 nb::module_ m_timer = m.def_submodule("timer", "Timer utilities");
20
21 nb::class_<PTimer>(m_timer, "PTimer")
22
23 // Attribute
24 .def_prop_rw("ellapsedTime",
25 [](PTimer &timer) { return timer.getEllapsedTime(); },
26 [](PTimer &timer, time_t value) { timer.setEllapsedTime(value); },
27 "Get or set the ellapsed time between timer triggers")
28
29 // Constructors
30 .def(nb::init<time_t>(),
31 nb::arg("ellapsedTime") = 1lu,
32 "Constructor with custom ellapsedTime")
33
34 .def(nb::init<const PTimer &>(),
35 nb::arg("other"),
36 "Copy constructor")
37
38 // Timer configuration methods
39 .def("setStartTime", [](PTimer &timer, time_t startTime) {
40 timer.setStartTime(startTime);
41 },
42 "Set the start time for the timer")
43
44 // Timer checking methods
45 .def("isTime", [](PTimer &timer, time_t currentTime) -> bool {
46 return timer.isTime(currentTime);
47 },
48 "Check if the elapsed time has passed since start time")
49
50 .def("isTimeWithEllapsed", [](PTimer &timer, time_t ellapsedTime, time_t currentTime) -> bool {
51 return timer.isTime(ellapsedTime, currentTime);
52 },
53 "Check if time has elapsed and return (bool, elapsed_time_ns) tuple"
54 );
55}

Referenced by NB_MODULE().

+ Here is the caller graph for this function: