One Framework 0.1.0
RoboMaster嵌入式框架“一键”解决方案,为你的“创意”服务。
载入中...
搜索中...
未找到
NotifyHub.hpp
浏览该文件的文档.
1#ifndef OF_NOTIFYHUB_HPP
2#define OF_NOTIFYHUB_HPP
3
5
8#include <ems_parser.hpp>
9#include <optional>
10#include <span>
11
12namespace OF
13{
14 constexpr size_t MAX_KEY_LEN = 32;
15
17 {
18 std::span<const ems::Note> notes;
19 uint8_t volume;
20 bool once = false;
21 };
22
23 enum class LEDMode : uint8_t
24 {
25 Solid, // 常亮
26 Blink, // 闪烁
27 Breathing, // 呼吸
28 };
29
30 struct LEDStatus
31 {
33
35 uint8_t toggle_times;
37 bool once = false;
38 };
39
40 enum class CommandType: uint8_t { SET, REMOVE };
41
49
57
59 {
60 const device* led_pixel_dev;
61 const device* pwm_buzzer_dev;
62 };
63
64 class NotifyHub final : public HubBase<NotifyHub>
65 {
66 public:
67 static constexpr auto name = "NotifyHub";
68
69 void configure(const NotifyHubConfig& config);
70
71 void setup();
72
73 static void setBuzzerStatus(const FixedString<MAX_KEY_LEN>& key, const BuzzerStatus& status);
74 static void removeBuzzerStatus(const FixedString<MAX_KEY_LEN>& key);
75
76 static void setLEDStatus(const FixedString<MAX_KEY_LEN>& key, const LEDStatus& status);
77 static void removeLEDStatus(const FixedString<MAX_KEY_LEN>& key);
78
79 private:
80 const device* m_buzzer{nullptr};
81 const device* m_led_pixel{nullptr};
82
83 [[noreturn]] static void m_buzzer_thread_entry(void* p1, void* p2, void* p3);
84 [[noreturn]] static void m_led_thread_entry(void* p1, void* p2, void* p3);
85
86 k_thread m_buzzer_thread{};
87 k_thread m_led_thread{};
88 k_tid_t m_buzzer_tid{};
89 k_tid_t m_led_tid{};
90 };
91}
92
93#endif //OF_NOTIFYHUB_HPP
定义 FixedString.hpp:12
定义 NotifyHub.hpp:65
static void setBuzzerStatus(const FixedString< MAX_KEY_LEN > &key, const BuzzerStatus &status)
定义 NotifyHub.cpp:60
void setup()
定义 NotifyHub.cpp:45
void configure(const NotifyHubConfig &config)
定义 NotifyHub.cpp:39
static void removeLEDStatus(const FixedString< MAX_KEY_LEN > &key)
定义 NotifyHub.cpp:87
static constexpr auto name
定义 NotifyHub.hpp:67
static void setLEDStatus(const FixedString< MAX_KEY_LEN > &key, const LEDStatus &status)
定义 NotifyHub.cpp:78
static void removeBuzzerStatus(const FixedString< MAX_KEY_LEN > &key)
定义 NotifyHub.cpp:69
定义 Mecanum.hpp:6
CommandType
定义 NotifyHub.hpp:40
@ REMOVE
定义 NotifyHub.hpp:40
@ SET
定义 NotifyHub.hpp:40
constexpr size_t MAX_KEY_LEN
定义 NotifyHub.hpp:14
LEDMode
定义 NotifyHub.hpp:24
@ Breathing
定义 NotifyHub.hpp:27
@ Blink
定义 NotifyHub.hpp:26
@ Solid
定义 NotifyHub.hpp:25
定义 NotifyHub.hpp:43
BuzzerStatus status
定义 NotifyHub.hpp:47
CommandType type
定义 NotifyHub.hpp:44
FixedString< MAX_KEY_LEN > key
定义 NotifyHub.hpp:45
定义 NotifyHub.hpp:17
uint8_t volume
定义 NotifyHub.hpp:19
std::span< const ems::Note > notes
定义 NotifyHub.hpp:18
bool once
定义 NotifyHub.hpp:20
定义 NotifyHub.hpp:51
LEDStatus status
定义 NotifyHub.hpp:55
CommandType type
定义 NotifyHub.hpp:52
FixedString< MAX_KEY_LEN > key
定义 NotifyHub.hpp:53
定义 NotifyHub.hpp:31
LEDMode mode
定义 NotifyHub.hpp:34
uint8_t toggle_times
定义 NotifyHub.hpp:35
led_color color
定义 NotifyHub.hpp:32
bool once
定义 NotifyHub.hpp:37
uint16_t toggle_interval_ms
定义 NotifyHub.hpp:36
定义 NotifyHub.hpp:59
const device * led_pixel_dev
定义 NotifyHub.hpp:60
const device * pwm_buzzer_dev
定义 NotifyHub.hpp:61
定义 led_pixel.h:36