makes GPIO_PIN_RST optional for the sx1276
[ExpressLRS.git] / src / lib / LUA / lua.h
blobc66b00a581810b88066dafd54524bd19ad60f9d5
1 #pragma once
3 #ifdef TARGET_TX
5 #include "targets.h"
6 #include "crsf_protocol.h"
8 enum lua_Flags{
9 LUA_FLAG_CONNECTED = 0, //bit 0 and 1 are status flags, show up as the little icon in the lua top right corner
10 LUA_FLAG_STATUS1,
11 LUA_FLAG_MODEL_MATCH, //bit 2,3,4 are warning flags, change the tittle bar every 0.5s
12 LUA_FLAG_WARNING2,
13 LUA_FLAG_WARNING1,
14 LUA_FLAG_CRITICAL_WARNING1, //bit 5,6,7 are critical warning flag, block the lua screen until user confirm to suppress the warning.
15 LUA_FLAG_CRITICAL_WARNING2,
16 LUA_FLAG_CRITICAL_WARNING3
19 struct luaPropertiesCommon {
20 const char* const name; // display name
21 const crsf_value_type_e type;
22 uint8_t id; // Sequential id assigned by enumeration
23 uint8_t parent; // id of parent folder
24 } PACKED;
26 struct tagLuaDeviceProperties {
27 uint32_t serialNo;
28 uint32_t hardwareVer;
29 uint32_t softwareVer;
30 uint8_t fieldCnt; //number of field of params this device has
31 }PACKED;
33 struct luaItem_selection {
34 struct luaPropertiesCommon common;
35 uint8_t value;
36 const char* options; // selection options, separated by ';'
37 const char* const units;
38 } PACKED;
40 struct luaItem_command {
41 struct luaPropertiesCommon common;
42 uint8_t step; // state
43 const char *info; // status info to display
44 } PACKED;
46 struct luaPropertiesInt8 {
47 union {
48 struct {
49 int8_t value;
50 const int8_t min;
51 const int8_t max;
52 } s;
53 struct {
54 uint8_t value;
55 const uint8_t min;
56 const uint8_t max;
57 } u;
59 } PACKED;
61 struct luaItem_int8 {
62 struct luaPropertiesCommon common;
63 struct luaPropertiesInt8 properties;
64 const char* const units;
65 } PACKED;
67 struct luaPropertiesInt16 {
68 union {
69 struct {
70 int16_t value;
71 const int16_t min;
72 const int16_t max;
73 } s;
74 struct {
75 uint16_t value;
76 const uint16_t min;
77 const uint16_t max;
78 } u;
80 }PACKED;
82 struct luaItem_int16 {
83 struct luaPropertiesCommon common;
84 struct luaPropertiesInt16 properties;
85 const char* const units;
86 } PACKED;
88 struct luaItem_string {
89 const struct luaPropertiesCommon common;
90 const char* value;
91 } PACKED;
93 struct luaItem_folder {
94 const struct luaPropertiesCommon common;
95 } PACKED;
97 struct tagLuaElrsParams {
98 uint8_t pktsBad;
99 uint16_t pktsGood; // Big-Endian
100 uint8_t flags;
101 char msg[1]; // null-terminated string
102 } PACKED;
104 extern void sendLuaCommandResponse(struct luaItem_command *cmd, uint8_t step, const char *message);
106 extern void suppressCurrentLuaWarning(void);
107 extern void setLuaWarningFlag(lua_Flags flag, bool value);
108 extern uint8_t getLuaWarningFlags(void);
109 extern void ICACHE_RAM_ATTR luaParamUpdateReq();
110 extern bool luaHandleUpdateParameter();
112 void registerLUAPopulateParams(void (*populate)());
114 typedef void (*luaCallback)(uint8_t id, uint8_t arg);
115 void registerLUAParameter(void *definition, luaCallback callback = 0, uint8_t parent = 0);
117 void sendLuaDevicePacket(void);
118 inline void setLuaTextSelectionValue(struct luaItem_selection *luaStruct, uint8_t newvalue) {
119 luaStruct->value = newvalue;
121 inline void setLuaUint8Value(struct luaItem_int8 *luaStruct, uint8_t newvalue) {
122 luaStruct->properties.u.value = newvalue;
124 inline void setLuaInt8Value(struct luaItem_int8 *luaStruct, int8_t newvalue) {
125 luaStruct->properties.s.value = newvalue;
127 inline void setLuaUint16Value(struct luaItem_int16 *luaStruct, uint16_t newvalue) {
128 luaStruct->properties.u.value = (newvalue >> 8) | (newvalue << 8);
130 inline void setLuaInt16Value(struct luaItem_int16 *luaStruct, int16_t newvalue) {
131 luaStruct->properties.s.value = (newvalue >> 8) | (newvalue << 8);
133 inline void setLuaStringValue(struct luaItem_string *luaStruct, const char *newvalue) {
134 luaStruct->value = newvalue;
136 #endif