From b356a66bd123a1378f64ff1cab06e59ad869231b Mon Sep 17 00:00:00 2001 From: uvok Date: Sun, 3 May 2026 19:53:05 +0200 Subject: Add way to send text --- include/badge/ble.h | 54 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'include/badge') 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 +#include +#include 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 -- cgit v1.2.3