diff --git a/Makefile b/Makefile index 2569989b..67081a37 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ SRC_ROOT := src TELEMETRY := $(SRC_ROOT)/SCRIPTS/TELEMETRY WIDGETS := $(SRC_ROOT)/WIDGETS +TOOLS := $(SRC_ROOT)/SCRIPTS/TOOLS SRC := $(wildcard $(WIDGETS)/*.lua) SRC += $(wildcard $(WIDGETS)/iNav/*.lua) @@ -11,6 +12,7 @@ SRC += $(wildcard $(TELEMETRY)/iNav/*.lua) SRC += $(wildcard $(TELEMETRY)/iNav/*/*.wav) SRC += $(wildcard $(TELEMETRY)/iNav/pics/*.*) SRC += $(wildcard $(TELEMETRY)/iNav/cfg/*.*) +SRC += $(wildcard $(TOOLS)/*.lua) DIST := dist VERSION := $(shell grep VERSION $(TELEMETRY)/iNav.lua | head -n 1 | cut -d\" -f 2) diff --git a/assets/buttons_0.png b/assets/buttons_0.png new file mode 100644 index 00000000..f0e504f8 Binary files /dev/null and b/assets/buttons_0.png differ diff --git a/assets/buttons_1.png b/assets/buttons_1.png new file mode 100644 index 00000000..50e30cf9 Binary files /dev/null and b/assets/buttons_1.png differ diff --git a/docs/Configuration-Settings.md b/docs/Configuration-Settings.md index 4c5fde71..2151759b 100644 --- a/docs/Configuration-Settings.md +++ b/docs/Configuration-Settings.md @@ -1,31 +1,51 @@ -## Taranis -Press the `Menu` button (`Shift` on X-Lite) to display the configuration options menu: +## Configuration Menu + +### Legacy Radios (Taranis etc.) + +**Long press** the `Menu` button to display the configuration options menu: * Use the dial or +/- buttons to cycle through the menu or select the desired setting * Press Enter/dial to select and deselect a menu option * Press `Exit` or `RTN` to deselect a menu option or escape the configuration menu -## Horus/Jumper T16 +### "Horus" (Horus, Jumper T16, RM TX16S, Nirvana) - "Colour" / large screen radios * Must be unarmed to access the config menu when running as a widget * Use the following (mode 2) stick controls to navigate the config menu: ![sample](https://raw.githubusercontent.com/iNavFlight/LuaTelemetry/master/assets/iNavConfigHorus.png "Horus config menu") -## Other radios +### Other radios + +The following applies generically to all non-Colour (B&W) / small screen radios: + +In particular, there are a number of recent smaller ('budget') radios, often with few discrete buttons and a small screen. The paucity of discrete buttons and non-standardisation of their function makes finding a common button press somewhat problematic. + +The INAV Lua Telemetry widget uses a **long button press** as defined by the firmware button event `EVT_VIRTUAL_MENU_LONG` ("Virtual Menu Button, Long Press"). `EVT_VIRTUAL_MENU_LONG` is a feature implemented by the firmware developers to make it easy for Lua scripts to access a menu button across diverse hardware designs. -There are a number of recent smaller ('budget') radios, often with few buttons and a small screen. The paucity of buttons and non-standardisation of their function makes finding a common button press somewhat problematic. +The physical button mapped to the virtual button depends on the radio, but is often the `MDL` (Model) button, so a **long press on `MDL` / Model** will display the configuration menu the non-colour radios. -By default, the INAV Lua Telemetry widget uses a **long** button press as defined by the firmware button event `EVT_VIRTUAL_MENU_LONG` ("Virtual Menu Button, Long Press"). `EVT_VIRTUAL_MENU_LONG` is a feature implemented by the firmware developers to make it easy for Lua scripts to access a menu button across diverse hardware designs. +In order to facilitate identifying the MDL / Model button on radios where the vendor documentation is unclear, a Button Test Tool is provided. -The physical button mapped to the virtual button depends on the radio, but is often the `MDL` button, so a long press on `MDL` _might_ reveal the configuration menu on most recent radios. +### Button Test Tool -* There is a test Lua script described in [Discussion #106](https://github.com/iNavFlight/OpenTX-Telemetry-Widget/discussions/106) that can be used in both the Companion / Simulator and on the physical radio to verify the buttons available to Lua (not all buttons are available to Lua which is part of the problem). You may have to experiment (easiest in Companion) to find the `EVT_VIRTUAL_MENU_LONG` button for your radio, in particular for some of more wacky designs (here's looking at you iFlight). +* There is a "Button Test" Lua script `INAVButtons.lua` available from the TX Tools menu (or `SCRIPTS/TOOLS` that can be used in both the Companion / Simulator and on the physical radio to verify the buttons available to Lua (not all buttons are available to Lua which is part of the problem). You may have to experiment (easiest in Companion) to find the `EVT_VIRTUAL_MENU_LONG` button for your radio, in particular for some of more wacky designs (here's looking at you iFlight). * If the button event `EVT_VIRTUAL_MENU_LONG` is not available for your transmitter, then you will not be able to access the configuration menu. -* If the button event `EVT_VIRTUAL_MENU_LONG` is available on the Companion but not on the physical radio (or vice-versa), then consider raising an issue with the firmware developer or radio vendor. Due to the (lack of) availability of hardware to the developers, this project can only support radios were the behaviour in the Companion and on the radio is consistent. +* If the button event `EVT_VIRTUAL_MENU_LONG` is available on the Companion but not on the physical radio (or vice-versa), then consider raising an issue with the firmware developer or radio vendor. Due to the (lack of) availability of all hardware to the maintainer, this project can only support radios where the behaviour in the Companion and on the radio is consistent. +* The test tool is closed by a **long press** on the `RTN` button. -Note also that on some of the smaller B&W radios (Boxer, Zorro, TX12), it is also possible to access the configuration menu via a log press on the roller. The firmware will intercept this press and offer a "Reset Telemetry" menu, which can be dismissed with `RTN`; the configuration menu will then be displayed. On these radios, the configuration options are accessed via the roller. +#### INAVButtons initial screen + +![button0](../assets/buttons_0.png) + +#### INAVButtons Usage + +![button1](../assets/buttons_1.png) + +Note also that on some of the smaller B&W radios (Boxer, Zorro, TX12) with a roller: +* The configuration menu is accessed via the `EVT_VIRTUAL_MENU_LONG` button press (not by the roller, which was intercepted by the OS) +* The configuration options are accessed via the roller. ### Configuration menu options @@ -69,13 +89,13 @@ Note also that on some of the smaller B&W radios (Boxer, Zorro, TX12), it is als * **GPS** - GPS coordinates as decimal or degrees/minutes format (default: Decimal) * **Playback Log** - Playback telemetry log files (latest 5 logs from the last 2 weeks) **[[help](../Configuration-Settings/#playback-telemetry-log-files)]** -## Suggested Battery Settings -### Voltage and Current Calibration +### Suggested Battery Settings +#### Voltage and Current Calibration 1. Using a multimeter, calibrate the voltage with the "Voltage Scale" in INAV configurator 1. If you have a current sensor, make sure you [calibrate it](https://www.youtube.com/watch?v=AWjblvHgjjI) -### In INAV Configurator +#### In INAV Configurator * Voltage source to use for alarms and telemetry: **Raw** * Number of cells: **0** (0=auto, set if you always use the same cell count) @@ -92,7 +112,7 @@ Note also that on some of the smaller B&W radios (Boxer, Zorro, TX12), it is als * `set smartport_fuel_unit = percent` * `set report_cell_voltage = OFF` (if set to `ON` Lua Telemetry can't show total battery voltage) -### In Lua Telemetry +#### In Lua Telemetry * Cell Low: **3.5V** (match "Warning cell voltage" in INAV) * Cell Critical: **3.4V** (match "Minimum cell voltage" in INAV) @@ -108,8 +128,7 @@ Note also that on some of the smaller B&W radios (Boxer, Zorro, TX12), it is als Log file playback allows you to playback the latest 5 telemetry log files from up to the last 2 weeks on the currently selected model. You must be _unarmed_ for this to work and if you arm while playing back a log file, the playback will be terminated. -Note also that replay only supports OpenTX file naming semantics; `-YYYY-MM-DD.csv`. If you wish to replay logs on EdgeTX, you will need to rename the log file appropriately. - +Note also that replay only supports OpenTX file naming semantics; `-YYYY-MM-DD.csv`. If you wish to replay logs on EdgeTX, you will need to rename the log file appropriately (i.e. remove the time component). ### Setup diff --git a/docs/Tips-And-Common-Problems.md b/docs/Tips-And-Common-Problems.md index 79f56dc8..e0ceef8c 100644 --- a/docs/Tips-And-Common-Problems.md +++ b/docs/Tips-And-Common-Problems.md @@ -1,3 +1,20 @@ +## Reporting Issues on Github + +Please submit issues and PRs in English only. Issues / PRs in other languages may be closed without further investigation, unfortunately. + +Please include: + +* The TX type (e.g. Radiomaster TX16S, Horus, Zorro etc.) +* The type and version of radio firmware (e.g. EdgeTX 2.8.0, OpenTX 2.3.15 etc). +* The flight controller and INAV version (e.g. MATEKF405, INAV 6.1.0) +* Details of other active Lua widgets + +Try running the script in the EdgeTX / OpenTX Companion. This will force debug mode and may display additional information, in particular module line numbers. Please including this information in any Github issue. + +Please also check that the problem can actually be reproduced in the firmware "Companion" application. If it cannot, it is may be that the maintainer cannot investigate the problem. You might also consider raising a firmware issue if "Companion" and real hardware exhibit different behaviours. + +For issues concerning discovery or display of sensor information, **please provide an EdgeTX / OpenTX telemetry log (CSV Telemetry log)**. + ## Common Taranis Errors * Script syntax error @@ -5,7 +22,7 @@ * Script panic not enough memory * Script syntax error not enough memory -#### Solution +### Solution * Be sure you're following the [Install/Setup Lua Telemetry on Transmitter](../Getting-Started/#installsetup-lua-telemetry-on-transmitter) instructions * If you're still getting the above errors, it's probably due to a lack of memory available on your transmitter (very common on Taranis). You can free up memory by removing other Lua Scripts from other screens, deleting unused models or turning off OpenTX firmware build options. Be sure to reboot your controller to free up memory after making a change. @@ -17,7 +34,7 @@ * **disabled** error on widget * refresh(): ?:0: attempt to compare number with nil -#### Solution +### Solution * Upgrade to the [latest release](../Upgrade) which may fix these issues * If it doesn't raise a Github issue. @@ -35,20 +52,3 @@ * If you change a telemetry sensor's unit (for example m to ft), power cycle the transmitter to see changes * If config option `Battery View` is set to `Total` but average cell voltage is displayed, send INAV CLI command: `set report_cell_voltage = OFF` * When GPS accuracy (HDOP) is displayed as a decimal, the range is 0.8 - 5.3 and it's rounded to the nearest 0.5 HDOP. This is due to HDOP being sent as a single integer from 0 to 9, not as the actual HDOP decimal value (not applicable to Crossfire) - -## Reporting Issues on Github - -Submit issues and PRs in English only. Issues / PRs in other languages may be closed without further investigation. - -Please include: - -* The TX type (e.g. Radiomaster TX16S, Horus, Zorro etc.) -* The type and version of radio firmware (e.g. EdgeTX 2.8.0, OpenTX 2.3.15 etc). -* The flight controller and INAV version (e.g. MATEKF405, INAV 6.1.0) -* Details of Other active Lua widgets - -Try running the script in the EdgeTX / OpenTX Companion. This will force debug mode and display additional information, in particular module line numbers. Please including this information in any Github issue. - -Please also check that the problem can actually be reproduced in the firmware "Companion" application. If it cannot, it is probable that the maintainer cannot investigate the problem. You should consider raising a firmware issue if "Companion" and real hardware exhibit different behaviours. - -For issues concerning discovery or display of sensor information, **please provide an EdgeTX / OpenTX telemetry log for TXs that provide such a facility**. diff --git a/src/SCRIPTS/TELEMETRY/iNav.lua b/src/SCRIPTS/TELEMETRY/iNav.lua index b6f67cce..f6e72692 100644 --- a/src/SCRIPTS/TELEMETRY/iNav.lua +++ b/src/SCRIPTS/TELEMETRY/iNav.lua @@ -523,7 +523,7 @@ function inav.run(event) elseif event == EVT_ENTER_BREAK and not HORUS then -- Cycle through views config[25].v = config[25].v >= (config[28].v == 0 and 2 or 3) and 0 or config[25].v + 1 - elseif event == MENU or (not HORUS and event == EVT_ROT_LONG) then + elseif event == MENU or event == EVT_VIRTUAL_MENU_LONG then -- Config menu data.configStatus = data.configLast elseif event == EVT_EXIT_BREAK and data.doLogs then diff --git a/src/SCRIPTS/TELEMETRY/iNav/data.lua b/src/SCRIPTS/TELEMETRY/iNav/data.lua index 86c8a838..0742bb28 100644 --- a/src/SCRIPTS/TELEMETRY/iNav/data.lua +++ b/src/SCRIPTS/TELEMETRY/iNav/data.lua @@ -10,18 +10,10 @@ local function getTelemetryUnit(n) return (field and field.unit <= 10) and field.unit or 0 end -local tx = string.sub(r, 0, 2) -if HORUS or string.sub(r, 0, 3) == "x9e" or string.sub(r, 0, 4) == "x9li" or string.sub(r, 0, 6) == "x9d+20" then - tx = "x7" -end local MENU if HORUS then MENU = EVT_SYS_FIRST -elseif tx == "xl" then - MENU = EVT_SHIFT_BREAK -elseif tx == 'x7' then - MENU = EVT_MENU_BREAK else MENU = EVT_VIRTUAL_MENU_LONG end diff --git a/src/SCRIPTS/TOOLS/INAVButtons.lua b/src/SCRIPTS/TOOLS/INAVButtons.lua new file mode 100644 index 00000000..17bd75e3 --- /dev/null +++ b/src/SCRIPTS/TOOLS/INAVButtons.lua @@ -0,0 +1,111 @@ + +local last_event = 0 +local ecount = 0 +local sz +local nl +local lh +local lastl = 0 +local lines = {} +local verbose = false + +-- Change `ALWAYS = true` in order to see non-virtual events +local ALWAYS = false + +local function report(event) + local txt="" + local matched = true + if event == EVT_EXIT_BREAK then txt = "EVT_EXIT_BREAK" + elseif event == EVT_MENU_BREAK then txt = "EVT_MENU_BREAK" + elseif event == EVT_PAGE_BREAK then txt = "EVT_PAGE_BREAK" + elseif event == EVT_PAGE_LONG then txt = "EVT_PAGE_LONG" + elseif event == EVT_ENTER_BREAK then txt = "EVT_ENTER_BREAK" + elseif event == EVT_ENTER_LONG then txt = "EVT_ENTER_LONG" + elseif event == EVT_PLUS_BREAK then txt = "EVT_PLUS_BREAK" + elseif event == EVT_MINUS_BREAK then txt = "EVT_MINUS_BREAK" + elseif event == EVT_PLUS_FIRST then txt = "EVT_PLUS_FIRST" + elseif event == EVT_MINUS_FIRST then txt = "EVT_MINUS_FIRST" + elseif event == EVT_PLUS_REPT then txt = "EVT_PLUS_REPT" + elseif event == EVT_MINUS_REPT then txt = "EVT_MINUS_REPT" + elseif event == EVT_ROT_BREAK then txt = "EVT_ROT_BREAK" + elseif event == EVT_ROT_LONG then txt = "EVT_ROT_LONG" + elseif event == EVT_ROT_LEFT then txt = "EVT_ROT_LEFT" + elseif event == EVT_ROT_RIGHT then txt = "EVT_ROT_RIGHT" + elseif event == EVT_VIRTUAL_NEXT_PAGE then txt = "EVT_VIRTUAL_NEXT_PAGE" + elseif event == EVT_VIRTUAL_PREV_PAGE then txt = "EVT_VIRTUAL_PREV_PAGE" + elseif event == EVT_VIRTUAL_ENTER then txt = "EVT_VIRTUAL_ENTER" + elseif event == EVT_VIRTUAL_ENTER_LONG then txt = "EVT_VIRTUAL_ENTER_LONG" + elseif event == EVT_VIRTUAL_MENU then txt = "EVT_VIRTUAL_MENU" + elseif event == EVT_VIRTUAL_MENU_LONG then txt = "EVT_VIRTUAL_MENU_LONG" + elseif event == EVT_VIRTUAL_NEXT then txt = "EVT_VIRTUAL_NEXT" + elseif event == EVT_VIRTUAL_NEXT_REPT then txt = "EVT_VIRTUAL_NEXT_REPT" + elseif event == EVT_VIRTUAL_PREV then txt = "EVT_VIRTUAL_PREV" + elseif event == EVT_VIRTUAL_PREV_REPT then txt = "EVT_VIRTUAL_PREV_REPT" + elseif event == EVT_VIRTUAL_INC then txt = "EVT_VIRTUAL_INC" + elseif event == EVT_VIRTUAL_INC_REPT then txt = "EVT_VIRTUAL_INC_REPT" + elseif event == EVT_VIRTUAL_DEC then txt = "EVT_VIRTUAL_DEC" + elseif event == EVT_VIRTUAL_DEC_REPT then txt = "EVT_VIRTUAL_DEC_REPT" + else + txt = "Event: "..event + matched = false + end + return txt,matched +end + +function run (event, touchState) + lcd.clear() + if verbose then + print("evt "..event.." last "..last_event.." lastl="..lastl.." nl="..nl) + end + + if (event == 0 or event == 0xdd00) and last_event == 0 then + lcd.drawText(3, 2, "Button Test", MIDSIZE) + lcd.drawText(3, 24, "Long RTN to exit") + lcd.drawText(3, 48, "Ready for button presses...", SMLSIZE) + else + if event ~= 0 then + last_event = event + local str,ok = report(last_event) + if ok or always then + if lastl < nl then + lines[lastl] = str + lastl = lastl + 1 + else + for j = 0, nl-2, 1 do + lines[j] = lines[j+1] + end + lines[nl -1] = str + end + end + end + for j = 0, lastl-1, 1 do + lcd.drawText(2, j*lh, lines[j], sz) + end + end + ecount = ecount + 1 + return 0 +end + +local function init() + if LCD_W >= 480 or LCD_H >= 480 then + local v, r, m, i, e, osname = getVersion() + sz = 0 + if osname ~= nil and osname == "EdgeTX" and (m > 2 or i > 4) then + local w + w,lh = lcd.sizeText("EVT", sz) + else + lh = 21 --regardless + end + else + sz = SMLSIZE + lh = 8 + end + nl = math.floor(LCD_H / lh) + if verbose then + print("H="..LCD_H.." lh = "..lh.." nl = "..nl) + end +end + +return { + run = run, + init = init +}