#pragma once #include #include #include "appevent_type.hpp" extern "C" { #include "uicontroler/tjc/tjc_base_type.h" #include "app_protocols/ble_through/ble_proto.h" } /** * * @注意 * 下面这个结构不易定义过大,否则容易造成栈溢出 */ // typedef struct { // } AppEvent; struct AcidStateChangeEvent { enum AcidStatChangeEventType subtype; // 添加 uint8_t addCh; float addChVal; // 使用 float useVal[4]; }; typedef struct AcidStateChangeEvent AcidStateChangeEvent_t; typedef enum AcidStatChangeEventType AcidStatChangeEventType_t; class AppEvent { public: AppEventType_t type; std::function onfnc = nullptr; const char* onfncmask = nullptr; private: uint8_t buf[30]; UIEvent* uieventpointer = nullptr; public: AppEvent() { static_assert(sizeof(buf) >= sizeof(AcidStateChangeEvent_t), "buf size must be larger than AcidStateChangeEvent_t"); memset(buf, 0, sizeof(buf)); } public: int getBufSize() { return sizeof(buf); } void setPageChangeTo(int32_t page) { *(int32_t*)buf = page; } int32_t getPageChangeTo() { return *(int32_t*)buf; } void setHeartInfo(uint8_t *heart_info) { memcpy(buf, heart_info, sizeof(zble_heart_t)); } uint8_t* getHeartInfo() { return (uint8_t *)buf; } void setStateDisplayInfo(const char* info) { strncpy((char*)buf, info, sizeof(buf)); } char* getStateDisplayInfo() { return (char*)buf; } UIEvent* getUIEvent() { return uieventpointer; } void setUIEvent(UIEvent* event) { uieventpointer = event; } AcidStateChangeEvent_t* getAcidStateChangeEvent() { return (AcidStateChangeEvent_t*)buf; } void setOnFnc(std::function fnc) { onfnc = fnc; } };