|
One Framework 0.1.0
RoboMaster嵌入式框架“一键”解决方案,为你的“创意”服务。
|
状态去重 Guard,只在状态真正改变时才发送通知 更多...
#include <NotifyGuard.hpp>
Public 成员函数 | |
| NotifyGuard (const FixedString< MAX_KEY_LEN > &key) | |
| bool | set (const StatusT &status) |
| 设置状态,只有与上次不同时才发送 | |
| void | reset () |
| 重置缓存,下次 set 将强制发送 | |
| const std::optional< StatusT > & | current () const |
| 获取当前缓存的状态(如果有) | |
状态去重 Guard,只在状态真正改变时才发送通知
| StatusT | LEDStatus 或 BuzzerStatus |
使用示例: NotifyGuard<LEDStatus> m_led_guard{"chassis"}; m_led_guard.set({c_warning, LEDMode::Breathing, 1, 300}); // 自动去重
|
inlineexplicit |
|
inline |
获取当前缓存的状态(如果有)
|
inline |
重置缓存,下次 set 将强制发送
|
inline |
设置状态,只有与上次不同时才发送
| status | 新状态 |