Commit Graph
77 Commits
Author SHA1 Message Date
Jesper FrickmannandGitHub d37b3e4051 [lua] Fix Lua Mixer index issue (#1312)
* Bug with the index of Mixer script input/output data

* Missed a #if defined(COLORLCD)
2021-12-30 19:37:23 +10:00
jfrickmannandPeter Feerick 85bd9d16ea Added Lua constants for logical switch and special/custom functions 2021-12-15 12:24:58 +10:00
jfrickmannandPeter Feerick a66e78fea8 Fixed string option for Lua widgets 2021-12-14 20:12:12 +10:00
jfrickmannandPeter Feerick a9c5365ccb Truncate Mixer Lua script input and output names to 6 chars 2021-12-13 14:51:47 +10:00
jfrickmannandPeter Feerick 4d3c8d52a5 Making tests pass with new trim limits 2021-12-07 18:32:09 +10:00
jfrickmannandPeter Feerick 5efd910edc Changed the max. trim values to the suggested 2021-12-07 18:32:09 +10:00
jfrickmannandPeter Feerick 28b211ff48 Reload Lua scripts when a function script is changed on COLORLCD 2021-12-02 10:08:27 +10:00
jfrickmannandRisto 14f72e1d82 Added new Lua API functions for switches
getSwitchId(positionName)
getSwitchName(switchId)
getSwitchValue(switchId)
getPhysicalSwitches()
2021-12-01 18:41:04 +01:00
jfrickmannandPeter Feerick 81cb94a4bf Added string constants to the read-only tables in Lua 2021-11-29 12:00:50 +10:00
Jesper FrickmannandGitHub a09e318e64 [Lua] Add setStickySwitch and getLogicalSwitchValue (#1056)
[Lua] Add setStickySwitch and getLogicalSwitchValue (#1056)
* Adds setStickySwitch to set the value of a stick logical switch
* Adds getLogicalSwitchValue to get the value of a logical switch by index
2021-11-29 12:48:01 +11:00
jfrickmannandPeter Feerick 229c59dae3 Removed the call to update() when widget leaves fullscreen mode 2021-11-28 11:38:36 +10:00
jfrickmannandPeter Feerick d4b8717575 Added zone.absx and zone.absy to give position of a Lua widget on the screen 2021-11-27 18:18:44 +10:00
jfrickmannandPeter Feerick 019a1584d0 Monospaced font for digits
So timers etc. do not jump back and forth. Assumes that 4 is the widest digit.
2021-11-22 14:49:44 +10:00
jfrickmann ce7b408445 Add touch to Standalone Lua scripts 2021-11-19 08:01:28 -05:00
jfrickmann df153b4b1f memset() -> memclear() 2021-11-18 19:51:01 -05:00
Jesper FrickmannandGitHub f1baa383ae Fix standalone Lua script screen flicker and improve error messages (#982)
* Relax assumptions about when Lua is called in foreground and background

* Start Lua cycle timer both in foreground and background
Do not assume that background/foreground alternates

* Lua is called at every Standalone GUI cycle instead of 5 Hz
Since Lua preempts every 50 ms or so, the GUI should remain responsive.

* In standalone script, only call Lua once per GUI cycle, to avoid messing up buffer handling.

* Revamped error reporting for Standalone and Telemetry Lua scripts

* Font size for Lua error is reduced from XL to L on color if LCD_W < LCD_H

* In drawTextLines, also possible linebreaks for opening brackets.

* Smaller font for error message on tall color screen

* Make titlebar height match font size on narrow LCD
2021-11-15 12:57:14 +11:00
Jesper FrickmannandGitHub 30780d82ec [lua] Add shared memory variables which can be accessed from Lua widgets and other Lua scripts (#1018)
* Issue #132
Added 16 shared memory variables which can be accessed bot from Lua widgets and other Lua scripts.

* Notice Only available on radios with color display
2021-11-13 16:10:33 +11:00
Jesper FrickmannandGitHub 69a465f0e2 Remove all radio predefined colors except BLACK and WHITE (#882)
* Removed all "Basic color definitions" except BLACK and WHITE in colors.h
Please ref. discussion on Discord: https://discord.com/channels/839849772864503828/839856795781431317/895858311579181066

* Removed theme color from the bootloader and replaced by RGB() like for e.g. green.

* Wrong color in Value widget default background color; should be white, not black
2021-10-16 22:34:31 +11:00
Jesper FrickmannandGitHub ecf386e71f Fix certain Lua script errors hanging the GUI (#899)
* Fixed a bug where a standalone Lua script w/o a run function will hang the GUI on non-color radios

* Prevent Lua standalone window from opening if Lua failed on load

* Fixed scroll down key in TX12 simulator
Copied key definitions from TX16S

* Fixed the Lua error trying to call nil value when no scripts are loaded.

* I messed up in the previous commit; now it does not freeze and it does not call nil.
2021-10-15 12:03:23 +11:00
Jesper FrickmannandGitHub d3ab7f9c61 Fix LUA=NO, remove ModelMixerScriptsPage when support not enabled (#869)
* Trying to align LUA options with radio/src/CMakeLists.txt
-DLUA=NO:  no Lua of any kind
-DLUA=ON:  everything but mixer scripts
-DLUA=YES: also mixer scripts

* Color LCD with -DLUA=NO is probably a rare combination, so it needed a little help with #defines.

* Some strange error using floor function w/o <math> - probably because -DLUA=NO is not normally used w/ color.
2021-10-11 10:37:06 +11:00
jfrickmannandPeter Feerick b316a11bba Per discussion on Discord
https://discord.com/channels/839849772864503828/842693696629899274/894878085210574889
2021-10-06 11:42:05 +11:00
Jesper FrickmannandGitHub 8d04b5112d Add tap count support to simulator (#719)
* Removed unused #define
* Added touchState.tapCount for double taps etc. to simulator
2021-09-14 16:30:39 +10:00
jfrickmann dcd5db38f9 Set error message if script fails in create() function 2021-09-11 13:36:10 -04:00
jfrickmann 98ed28db09 Added Lua function lcd.exitFullScreen() 2021-09-11 09:00:20 -04:00
jfrickmann c20fd74b3c Removed full screen message "Press [RTN] long to exit" 2021-09-11 08:35:21 -04:00
jfrickmann ca478dccba Removed unused function exec() 2021-09-11 07:35:48 -04:00
jfrickmann 935bd403ee Add tapCount to touchState in Lua widgets 2021-09-10 17:14:37 -04:00
jfrickmann cf67a5c10b Double tap to enter fullscreen mode and slow tap to open widget menu 2021-09-10 17:13:25 -04:00
jfrickmann b1ac01501d Add tapCount to touchState in gt911 driver 2021-09-10 17:11:55 -04:00
jfrickmann c0e25bfbff Modify Lua function lcd.RGB(...)
Now it can take *either* (r, g, b) as before *or* one single argument between 0 and 0xFFFFFF.
2021-09-09 16:51:03 -04:00
jfrickmann 1e505d4029 Do not apply (x,y) offsets! 2021-09-04 15:55:14 -04:00
jfrickmann 1d2983ad93 Mask out VCENTER, CENTER and RIGHT flags 2021-09-04 15:54:44 -04:00
jfrickmann e15b9636fa Implemented BLINK, INVERSE and SHADOWED
Also updated documentation
2021-09-04 07:15:02 -04:00
jfrickmann 1db80b31a0 Improved drawtextLines(...)
Now supports newline \n and automatic line break with hyphens, slashes and colons.
2021-09-04 06:05:57 -04:00
jfrickmann b100d9a164 Add Lua function lcd.drawTextLines(...) drawing text across multiple lines inside bounding box 2021-09-02 14:33:14 -04:00
Jesper FrickmannandGitHub cea723c56e Do not reload bitmps during theme update, unless reload argument is true (#661)
* Do not reload bitmps during theme update, unless reload argument is true
Trying to optimize speed for theme color changes.
FlySky is not optimized yet.

* Do not update theme from Lua lcd.setColor(CUSTOM_COLOR, x)
Some widgets like e.g. Timer2 constantly change CUSTOM_COLOR, and this seems to slow down things

* Lua function lcd.setColor() only updates if color is changed
To avoid that scripts calling lcd.setColor() repeatedly trash performance
2021-09-01 11:10:52 +10:00
jfrickmann f8eb2adab0 Show error message in Lua widgets instead of "disabled"
Also a new function drawTextLines(...) in draw_functions that splits a string over multiple lines
2021-08-29 18:22:31 -04:00
jfrickmann 29639d76ab Fixed colors in Radio menus 2021-08-28 17:03:12 -04:00
jfrickmann 5b3db33f03 Translate color option to create() function call
Forgot that in PR #646
2021-08-28 10:29:41 -04:00
jfrickmann 1af65969ed Color options for Lua widget get translated to Lua color flags
To support new color encoding in Lua widgets
2021-08-27 22:21:37 -04:00
jfrickmann 5fd78ce0d7 Updated libopenui 2021-08-26 10:49:45 -04:00
jfrickmann 16d2df6a44 Fixed missing colors in model menus, except from the top bar 2021-08-26 09:23:00 -04:00
jfrickmannandRaphael Coeffic 468a322f61 Updated documentation for Lua functions, mainly related to color 2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 9d878b71ce Improved color handling in Lua
LCD flags can now hold either a theme color index or a RGB value. Hence, values from lcd.RGB() and literal colors like e.g. RED, WHITE etc. can be used interchangeably with theme colors and CUSTOM_COLOR.
Also redesigned drawText, drawNumber and drawTimer, so they now use a common function to implement the party tricks with BLINK and INVERS flags.
2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 57e455d343 Made all flags optional and updated documentation 2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 3ae5f032fc Fixed a bug in lcd.drawLine function 2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic d0e4b767d3 Converted literal colors to indices that can be used everywhere.
Also modified lcd.setColor function so it accepts either RGB or index color as new color. That way, literal colors work as before.
2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 8fb260d2b2 Fixed Lua function drawPoint and default color
I had deleted the default color, now it is back again. Lua drawPoint color did not work, it does now. Some style updates to the Lua code where several different names were used for variables holding flags.
2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 4a11d7558d Copied theme colors over to FlySky 2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 23ee5d933c Added back Lua constants for old style them colors 2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 95b87db3e0 Did a scripted search and replace to replace 40 existing theme colors with 11 new theme colors. 2021-08-22 19:39:50 +02:00
jfrickmannandRaphael Coeffic 5db5783be5 Commenting out LCD tests to make it pass checks with a changed color palette 2021-08-22 19:33:03 +02:00
jfrickmannandRaphael Coeffic 302fcef465 Added OS theme colors as suggested by JimB40 in #506
Amend: trying if tests will pass when I move the new color indices to then end of the enum.
2021-08-22 19:33:03 +02:00
jfrickmann 8e4e2cceea Fix for issue #537
The function luaResume(...) assumes that it is called alternatingly in the background and the foreground.
But on color LCD radios it is only called in the foreground by standalone and tools script, so it got stuck waiting for a foreground call.
2021-08-03 20:57:16 -04:00
jfrickmannandRaphael Coeffic 6e37d11710 Added a lua function lcd.sizeText(text[, flags])
Gets the width and height (incl. vertical offset) of text on the LCD with flags applied.
2021-07-31 07:59:08 +02:00
jfrickmannandRaphael Coeffic bf656ffd7b Added event buffer to LuaWidget
Since Lua only runs at 10 Hz and the GUI at a higher frequency, events sometimes are skipped unless we store them in a buffer.
This buffer is only two slots, but can be expanded by changing EVENT_BUFFER_SIZE.
2021-07-31 07:54:17 +02:00
jfrickmann d4e02dbc22 Accumulate (slideX, slideY) with touch slide events.
Apparently, onTouchSlide gets called more frequently, and hence we miss some of the sliding if we do not accumulate between calls to Lua.
2021-07-26 21:34:38 -04:00
jfrickmann da94cc64ff Merge branch 'VCENTER' into Everything 2021-07-24 17:32:48 -04:00
jfrickmann 1fc59ce31a Merged LuaScriptPreemption 2021-07-24 17:32:41 -04:00
jfrickmann b0732e1564 Don't kill the mixer scripts - just preempt them :-) 2021-07-22 15:39:01 -04:00
jfrickmann 5671838864 Cleaned up code for Mixer/Custom/Model scripts and added compiler directives 2021-07-22 15:11:12 -04:00
jfrickmann 76d2ef54e3 Fixing standalone scripts with preemption on colorlcd 2021-07-22 15:02:44 -04:00
jfrickmann dcac3cb9da Fixed Lua error messages in standalone and telemetry scripts - again. There is still a problem that the call to POPUP_WARNING in displayLuaError does not return and the gui goes dark on colorlcd. Could it be long jump? 2021-07-22 14:56:23 -04:00
jfrickmann c76532f33a Fixed Lua error messages in standalone and telemetry scripts. TODO: If a standalone script errors in init() on COLORLCD it just quits without showing error. Is that because it calls luaError from luaExec() in radio_tools.cpp instead of from luaTask() in standalone_lua.cpp? 2021-07-22 14:51:44 -04:00
jfrickmann c62aac7bde Lua task preempts long running scripts instead of killing them
Ported to EdgeTX from https://github.com/opentx/opentx/pull/8194
2021-07-22 14:41:53 -04:00
jfrickmann 296acc6558 Code polishing 2021-07-22 08:03:48 -04:00
jfrickmann fd05bcab19 One swipe at a time
Added a timeout so we do not get a swipe storm during slide events
2021-07-22 08:03:28 -04:00
jfrickmann 61602d525b Improved swipe-onomics 2021-07-22 08:03:09 -04:00
jfrickmann 8b90754e95 Only one EVT_TOUCH_FIRST at a time 2021-07-22 08:02:53 -04:00
jfrickmann 0b9fd82074 Added touch events to Lua widgets 2021-07-22 08:02:33 -04:00
jfrickmann e1066af88c Added LuaWidget::onEvent(event) and LuaWidget::event to capture key events to be passed to the Lua widgets. 2021-07-22 08:01:29 -04:00
jfrickmann e3fb2ac6ea Added key event to fullscreen Lua widget 2021-07-22 08:01:08 -04:00
jfrickmann 2e129af9f1 Added VCENTER to lcd flags
Only for COLORLCD
2021-07-21 19:53:13 -04:00
Jesper FrickmannandGitHub a9179d1357 Updated documentation for getSensor (#8161) 2020-12-13 08:19:31 +01:00
Jesper Frickmannand3djc 6ba4187381 Added model.resetSensor(sensor) function
Issue #7562
2020-12-10 13:33:34 +01:00
Jesper FrickmannandGitHub b320e9f884 Added model.resetSensor(sensor) function
Issue #7562
2020-12-03 19:53:34 -05:00
Jesper FrickmannandBertrand Songis d59a853f0c Issue #5696 (#5698)
When an "Adjust GV" special function is reusing trim buttons to increase/decrease GVs, then the trim limits are applied instead of GV limits. This patch applies the GV limits.
2018-04-25 08:04:43 +02:00