zhangyisong 0e5d15c814 Refactor app to use static classes and event-driven callbacks
Restructure Led as a template on the DT spec, add a generic
signal/slot mechanism for host status, and cache Infrared sensor
samples via trigger callbacks. Add new init modules for LED, temp,
and watchdog, and build them into the main app.
2026-08-03 22:12:31 +08:00

34 lines
792 B
C++

#ifndef __THER_LED_HPP__
#define __THER_LED_HPP__
#include <etl/algorithm.h>
#include <etl/array.h>
#include <zephyr/drivers/led.h>
#include <zpp/ct_string.hpp>
#include <zpp/work_queue.hpp>
namespace ther {
template <led_dt_spec kSpec> class Led {
public:
static auto On() -> zpp::error { return led_on_dt(&kSpec); }
static auto Off() -> zpp::error { return led_off_dt(&kSpec); }
template <typename TRep, typename TPeriod>
static auto Flash(std::chrono::duration<TRep, TPeriod> period) {
s_work.submit(period);
}
private:
static auto Flash() -> void {
static bool flag = false;
if (flag) {
led_off_dt(&kSpec);
} else {
led_on_dt(&kSpec);
}
flag = !flag;
}
static inline zpp::periodic_work<> s_work{Flash};
};
} // namespace ther
#endif