diff options
| author | uvok | 2026-05-03 19:53:05 +0200 |
|---|---|---|
| committer | uvok | 2026-05-03 19:53:05 +0200 |
| commit | b356a66bd123a1378f64ff1cab06e59ad869231b (patch) | |
| tree | 580998d01ca34d822414b5a48398bdf860a27d31 /include/badge | |
| parent | 3f808628dd27552bc50609baad1073e5c0b59b87 (diff) | |
Add way to send text
Diffstat (limited to 'include/badge')
| -rw-r--r-- | include/badge/ble.h | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/include/badge/ble.h b/include/badge/ble.h index 27b4749..1373d30 100644 --- a/include/badge/ble.h +++ b/include/badge/ble.h @@ -1,7 +1,8 @@ #pragma once #include "indicator.h" -#include <stdint.h> +#include <cstdint> +#include <string> namespace de::uvok::badge { @@ -9,21 +10,58 @@ namespace de::uvok::badge { None, Template, - Indicator + Indicator, + TextAsQrCode }; - typedef struct + struct BlePollResult { BleActionType action_type; union { uint8_t new_template; DisplayIndicator new_indicator; }; - } ble_poll_result_t; + std::string new_text; - void ble_init(void); - void ble_advertise(void); - bool ble_is_active(void); - ble_poll_result_t ble_poll(void); + static BlePollResult MakeTemplate(uint8_t val) + { + BlePollResult p{}; + p.action_type = BleActionType::Template; + p.new_template = val; + return p; + } + + static BlePollResult MakeText(const std::string &val) + { + BlePollResult p{}; + p.action_type = BleActionType::TextAsQrCode; + p.new_text = val; + return p; + } + + static BlePollResult MakeEmpty() + { + BlePollResult p{}; + return p; + } + + static BlePollResult MakeIndicator(DisplayIndicator ind) + { + BlePollResult p{}; + p.action_type = BleActionType::Indicator; + p.new_indicator = ind; + return p; + } + + private: + BlePollResult() : action_type(BleActionType::None), new_indicator(DisplayIndicator::None) + { + } + }; + + void ble_init(); + void ble_advertise(); + bool ble_is_active(); + BlePollResult ble_poll(); void ble_set_image(uint8_t image); } // namespace de::uvok::badge |
