@@ -74,6 +74,8 @@
|
||||
#define RADIO_VERSION FLAVOUR
|
||||
#endif
|
||||
|
||||
#define VERSION_OSNAME "EdgeTX"
|
||||
|
||||
#define FIND_FIELD_DESC 0x01
|
||||
|
||||
#define KEY_EVENTS(xxx, yyy) \
|
||||
@@ -93,15 +95,17 @@ Return OpenTX version
|
||||
|
||||
@retval string OpenTX version (ie "2.1.5")
|
||||
|
||||
@retval multiple (available since 2.1.7) returns 5 values:
|
||||
@retval multiple values (available since 2.1.7):
|
||||
* (string) OpenTX version (ie "2.1.5")
|
||||
* (string) radio type: `x12s`, `x10`, `x9e`, `x9d+`, `x9d` or `x7`.
|
||||
If running in simulator the "-simu" is added
|
||||
* (number) major version (ie 2 if version 2.1.5)
|
||||
* (number) minor version (ie 1 if version 2.1.5)
|
||||
* (number) revision number (ie 5 if version 2.1.5)
|
||||
Since EdgeTX 2.4.0, sixth value added
|
||||
* (string) OS name (i.e. EdgeTX or nil if OpenTX)
|
||||
|
||||
@status current Introduced in 2.0.0, expanded in 2.1.7, radio type strings changed in 2.2.0
|
||||
@status current Introduced in 2.0.0, expanded in 2.1.7, radio type strings changed in 2.2.0, os name added in EdgeTX 2.4.0
|
||||
|
||||
### Example
|
||||
|
||||
@@ -109,12 +113,13 @@ This example also runs in OpenTX versions where the function returned only one v
|
||||
|
||||
```lua
|
||||
local function run(event)
|
||||
local ver, radio, maj, minor, rev = getVersion()
|
||||
local ver, radio, maj, minor, rev, osname = getVersion()
|
||||
print("version: "..ver)
|
||||
if radio then print ("radio: "..radio) end
|
||||
if maj then print ("maj: "..maj) end
|
||||
if minor then print ("minor: "..minor) end
|
||||
if rev then print ("rev: "..rev) end
|
||||
if osname then print ("osname: "..osname) end
|
||||
return 1
|
||||
end
|
||||
|
||||
@@ -122,11 +127,12 @@ return { run=run }
|
||||
```
|
||||
Output of the above script in simulator:
|
||||
```
|
||||
version: 2.1.7
|
||||
radio: taranis-simu
|
||||
version: 2.4.0
|
||||
radio: tx16s-simu
|
||||
maj: 2
|
||||
minor: 1
|
||||
rev: 7
|
||||
minor: 4
|
||||
rev: 0
|
||||
osname: EdgeTX
|
||||
```
|
||||
*/
|
||||
static int luaGetVersion(lua_State * L)
|
||||
@@ -136,7 +142,8 @@ static int luaGetVersion(lua_State * L)
|
||||
lua_pushnumber(L, VERSION_MAJOR);
|
||||
lua_pushnumber(L, VERSION_MINOR);
|
||||
lua_pushnumber(L, VERSION_REVISION);
|
||||
return 5;
|
||||
lua_pushstring(L, VERSION_OSNAME);
|
||||
return 6;
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
|
||||
@@ -198,6 +198,7 @@ class LuaWidget: public Widget
|
||||
int luaWidgetDataRef;
|
||||
char * errorMessage;
|
||||
uint32_t lastRefresh = 0;
|
||||
bool refreshed = false;
|
||||
|
||||
void checkEvents() override;
|
||||
void setErrorMessage(const char * funcName);
|
||||
@@ -270,9 +271,16 @@ void LuaWidget::checkEvents()
|
||||
{
|
||||
Widget::checkEvents();
|
||||
|
||||
// paint has not been called
|
||||
if (!refreshed) {
|
||||
background();
|
||||
refreshed = true;
|
||||
}
|
||||
|
||||
uint32_t now = RTOS_GET_MS();
|
||||
if (now - lastRefresh >= LUA_WIDGET_REFRESH) {
|
||||
lastRefresh = now;
|
||||
refreshed = false;
|
||||
invalidate();
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
@@ -343,12 +351,16 @@ void LuaWidget::refresh(BitmapBuffer* dc)
|
||||
// Remove LCD
|
||||
luaLcdAllowed = false;
|
||||
luaLcdBuffer = nullptr;
|
||||
|
||||
// mark as refreshed
|
||||
refreshed = true;
|
||||
}
|
||||
|
||||
void LuaWidget::background()
|
||||
{
|
||||
if (lsWidgets == 0 || errorMessage) return;
|
||||
|
||||
TRACE("LuaWidget::background()");
|
||||
luaSetInstructionsLimit(lsWidgets, WIDGET_SCRIPTS_MAX_INSTRUCTIONS);
|
||||
LuaWidgetFactory * factory = (LuaWidgetFactory *)this->factory;
|
||||
if (factory->backgroundFunction) {
|
||||
|
||||
Reference in New Issue
Block a user