You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
995 B
45 lines
995 B
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#include <functional>
|
|
|
|
#include "appevent_type.hpp"
|
|
extern "C" {
|
|
#include "uicontroler/tjc/tjc_base_type.h"
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @注意
|
|
* 下面这个结构不易定义过大,否则容易造成栈溢出
|
|
*/
|
|
|
|
// typedef struct {
|
|
// } AppEvent;
|
|
|
|
class AppEvent {
|
|
public:
|
|
AppEventType_t type;
|
|
std::function<void()> onfnc;
|
|
uint8_t buf[sizeof(UIEvent) + 10];
|
|
|
|
char* getBleName() { return (char*)buf; }
|
|
|
|
char* getStateDisplayInfo() { return (char*)buf; }
|
|
|
|
UIEvent* getUIEvent() { return (UIEvent*)buf; }
|
|
|
|
int32_t getPageChangeTo() { return *(int32_t*)buf; }
|
|
|
|
void setBleName(const char* name) { strcpy((char*)buf, name); }
|
|
|
|
void setStateDisplayInfo(const char* info) { strcpy((char*)buf, info); }
|
|
|
|
void setUIEvent(const UIEvent& event) { memcpy(buf, &event, sizeof(UIEvent)); }
|
|
|
|
void setPageChangeTo(int32_t page) { *(int32_t*)buf = page; }
|
|
|
|
void setOnFnc(std::function<void()> fnc) { onfnc = fnc; }
|
|
|
|
int getBufSize() { return sizeof(buf); }
|
|
};
|