6 #include "crsf_protocol.h"
9 LUA_FLAG_CONNECTED
= 0, //bit 0 and 1 are status flags, show up as the little icon in the lua top right corner
11 LUA_FLAG_MODEL_MATCH
, //bit 2,3,4 are warning flags, change the tittle bar every 0.5s
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
26 struct tagLuaDeviceProperties
{
30 uint8_t fieldCnt
; //number of field of params this device has
33 struct luaItem_selection
{
34 struct luaPropertiesCommon common
;
36 const char* options
; // selection options, separated by ';'
37 const char* const units
;
40 struct luaItem_command
{
41 struct luaPropertiesCommon common
;
42 uint8_t step
; // state
43 const char *info
; // status info to display
46 struct luaPropertiesInt8
{
62 struct luaPropertiesCommon common
;
63 struct luaPropertiesInt8 properties
;
64 const char* const units
;
67 struct luaPropertiesInt16
{
82 struct luaItem_int16
{
83 struct luaPropertiesCommon common
;
84 struct luaPropertiesInt16 properties
;
85 const char* const units
;
88 struct luaItem_string
{
89 const struct luaPropertiesCommon common
;
93 struct luaItem_folder
{
94 const struct luaPropertiesCommon common
;
97 struct tagLuaElrsParams
{
99 uint16_t pktsGood
; // Big-Endian
101 char msg
[1]; // null-terminated string
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
;