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.
57 lines
1.2 KiB
57 lines
1.2 KiB
#pragma once
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include <functional>
|
|
|
|
#include "config_index_enum.hpp"
|
|
namespace iflytop {
|
|
using namespace std;
|
|
typedef enum {
|
|
kAppEvent_RunModeChangeEvent,
|
|
kAppEvent_RemoterConnectStateChangeEvent,
|
|
kAppEvent_StateDisplayInfo,
|
|
kAppEvent_ConfigChangeEvent,
|
|
kAppEvent_BleConnectEvent,
|
|
} AppEventType_t;
|
|
|
|
/**
|
|
*
|
|
* @brief
|
|
*
|
|
*
|
|
* @注意
|
|
* 下面这个结构不易定义过大,否则容易造成栈溢出
|
|
*/
|
|
typedef struct {
|
|
AppEventType_t type;
|
|
union event {
|
|
uint32_t placeholder;
|
|
config_index_t configIndex;
|
|
char bleName[20];
|
|
char stateDisplayInfo[30];
|
|
} d;
|
|
|
|
} AppEvent_t;
|
|
|
|
static inline AppEvent_t createAppEvent(AppEventType_t type) {
|
|
AppEvent_t event;
|
|
event.type = type;
|
|
return event;
|
|
}
|
|
|
|
static inline AppEvent_t createConfigChangeEvent(config_index_t index) {
|
|
AppEvent_t event;
|
|
event.type = kAppEvent_ConfigChangeEvent;
|
|
event.d.configIndex = index;
|
|
return event;
|
|
}
|
|
|
|
static inline AppEvent_t createStateDisplayInfoEvent(const char* info) {
|
|
AppEvent_t event;
|
|
event.type = kAppEvent_StateDisplayInfo;
|
|
strncpy(event.d.stateDisplayInfo, info, sizeof(event.d.stateDisplayInfo));
|
|
return event;
|
|
}
|
|
} // namespace iflytop
|