Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cpn): generic simulator #5692

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open

Conversation

elecpower
Copy link
Collaborator

@elecpower elecpower commented Dec 1, 2024

Summary of changes:

  • convert all radios to use the generic simulator ui ie no custom graphics
  • option for buttons to be split left and right (default), all left or all right of lcd
  • user selectable radio 'case' colour per profile (default: black)
  • optional radio buttons for scroll up and down for those with mouse without scroll wheel. Keyboard shortcuts still available.
  • Surface radios move all trims from around sticks to centre

Benefits:

  • faster support for new radios in Companion
  • less dev effort
  • reduced the executable file size and compilation time of companion and simulator

Radio profile new Radio Case Colour setting
Screenshot from 2024-12-19 16-02-05

Simulator new settings
Screenshot from 2024-12-19 16-03-06

Surface radio with trims in centre, keys default positions and scroll keys
Screenshot from 2024-12-17 17-30-39

TX16S with keys RHS and no scroll keys and change of case colour
Screenshot from 2024-12-17 17-32-33

TX16S with keys LHS, scroll keys and change of case colour
Screenshot from 2024-12-17 17-33-58

GX12
Screenshot from 2024-12-17 17-51-35

@elecpower elecpower marked this pull request as draft December 1, 2024 23:23
@elecpower elecpower added companion Related to the companion software simulator labels Dec 1, 2024
@philmoz
Copy link
Collaborator

philmoz commented Dec 1, 2024

Should we consider adding buttons for the left/right roller movements to the generic UI?

There are keyboard mappings; but these aren't obvious, so navigation can be challenging if your mouse does not have a scroll wheel.

@elecpower
Copy link
Collaborator Author

Should we consider adding buttons for the left/right roller movements to the generic UI?

There are keyboard mappings; but these aren't obvious, so navigation can be challenging if your mouse does not have a scroll wheel.

I do not see why not and there could even be a Simulator setting option as to whether they display or not.

@elecpower
Copy link
Collaborator Author

Also planning to move trims from around joysticks for surface radios to centre where extra trims now go

@EdgeTX EdgeTX locked and limited conversation to collaborators Dec 4, 2024
@EdgeTX EdgeTX unlocked this conversation Dec 4, 2024
@philmoz
Copy link
Collaborator

philmoz commented Dec 5, 2024

Currently the simulator UI for B&W radios with OLED screens switches the LCD colors so the simulator is white text on a black background (to match the physical display).

The generic UI should probably have some method to handle this as well.

@pfeerick pfeerick changed the title chore(cpn) generic simulator chore(cpn): generic simulator Dec 6, 2024
@elecpower elecpower force-pushed the elecpower/cpn-generic-simulator branch 2 times, most recently from 1af28aa to 3858b30 Compare December 13, 2024 05:32
@elecpower elecpower marked this pull request as ready for review December 15, 2024 20:44
@elecpower elecpower force-pushed the elecpower/cpn-generic-simulator branch from 0ace67e to 99b157d Compare December 16, 2024 19:36
@elecpower
Copy link
Collaborator Author

fyi I've updated the sample images in the description.

Radio 'case' colour should I make it per radio profile rather than same for all? I'm leaning towards per radio profile as not much more effort.

@pfeerick
Copy link
Member

pfeerick commented Dec 19, 2024

This is looking great! :)

Radio 'case' colour should I make it per radio profile rather than same for all? I'm leaning towards per radio profile as not much more effort.

Per profile would be nice, as if you have more than one radio and they are different colours you have the option of making the background colour match...

@elecpower
Copy link
Collaborator Author

Radio case colour changed to per radio profile

@elecpower
Copy link
Collaborator Author

elecpower commented Dec 20, 2024

I have tried to make them intuitive but there are a couple of odd ones. Mac users please advise if not on standard keyboard especially Macbook.

Latest mappings
KEY_SYS S
KEY_MODEL M
KEY_PAGEUP PageUp
KEY_PAGEDN PageDown
KEY_UP Up arrow
KEY_DOWN Down arrow
KEY_LEFT Left arrow
KEY_RIGHT Right arrow
KEY_MINUS - (Minus)
KEY_PLUS + (Plus)
KEY_TELE T
KEY_MENU = (Equal)
KEY_SHIFT Insert
KEY_EXIT Esc or Backspace
KEY_ENTER Enter or Return
KEY_SCROLL_UP , (comma)
KEY_SCROLL_DOWN . (period)

@pfeerick
Copy link
Member

pfeerick commented Dec 22, 2024

Just FYI, on Windows and Linux:

KEY_SCROLL_UP < (Less than)
KEY_SCROLL_DOWN > (Greater than)

really is < and > so you need to use shift key. ;)

Any chance of getting Backspace back as another shortcut for KEY_EXIT... saves reaching all the way over for ESC 🤣

Cursor keys on windows (left/right/up/down) appear to run afoul of UI element focus... i.e. with T-Lite I need to click the LCD display, and then the right arrow only works once... it seems like up only works every second press, and down only the first time. Clicking on the LCD between each key press works perfectly though 🤔

Other than that, and some work being needed for the NV14/EL18/PL18 (the "switchable hats" thing) which IMO can be resurrected in a separate PR so this can go in sooner than later, this is looking great. Switching to Linux to continue there. Ok, Linux is working fine/just the same... buttons and profile settings seem good, and just the input focus being lost when using the shortcuts.

@elecpower
Copy link
Collaborator Author

elecpower commented Dec 22, 2024

really is < and > so you need to use shift key

@philmoz has asked for unshifted to ',' and '.'

Any chance of getting Backspace back as another shortcut for KEY_EXIT... saves reaching all the way over for ESC

Yes

Cursor keys on windows (left/right/up/down) appear to run afoul of UI element focus

I don't think it is focus but they need another mouse or key event. But this is not required for other keys. Pressing a button with arrows assigned doesn't suffer from the same issue as far as I've found. The two methods do not follow the exact code path so its running in debug mode time.

Thanks for testing.

@pfeerick
Copy link
Member

unshifted to ',' and '.'

Excellent... To be honest, it was annoying, but consistent. The unshifted minus and shifted plus is more annoying. 🤪

re: focus... I am seeing the focus rectangle on the button when the shortcut is pressed, hence why I think the keyboard focus is being lost, but yeah, debug should reveal all.

@elecpower
Copy link
Collaborator Author

The unshifted minus and shifted plus is more annoying

Not if you use the keypad

@philmoz
Copy link
Collaborator

philmoz commented Dec 22, 2024

MacOS:

  • TX16S - all keyboard shortcuts working
  • T15 - missing rotary encoder buttons and keyboard shortcuts
  • TLITE - arrows keys starting to work

On the TLITE the Up arrow works on every second press. The Down arrow works if I click on the LCD display; but only once. I have to keep clicking on the LCD display section between each press of the down arrow.

@elecpower
Copy link
Collaborator Author

elecpower commented Dec 22, 2024

The keypress is being lost/consumed by another object but strangely the keyrelease is being received. So that object is likely only intercepting keypress and not putting back on the event stack if it doesn't use it.

The mouse click resets the arrow keys or as @pfeerick and yourself state is refocuses the key events back to the radio widget.

So far all the other special keys don't suffer from this issue.

@philmoz
Copy link
Collaborator

philmoz commented Dec 22, 2024

GX12 also needs rotary encoder buttons and shortcuts.

@elecpower
Copy link
Collaborator Author

elecpower commented Dec 23, 2024

@pfeerick @philmoz you are on the right track as this post indicates
https://forum.qt.io/topic/153217/key-press-arrow-keys-cause-loss-of-focus

So now to find the focus stealer.

@pfeerick
Copy link
Member

pfeerick commented Dec 23, 2024 via email

@elecpower elecpower force-pushed the elecpower/cpn-generic-simulator branch from 76e0a63 to 267baca Compare December 23, 2024 03:14
@elecpower
Copy link
Collaborator Author

elecpower commented Dec 23, 2024

I may have fixed the focus issue but more testing. There is still the issue of focus lost if the user clicks off the widget or OS switches focus to another window. Not sure I can do anything to fix.

Also discovered I can crash a colour radio sim eg TX16S. Not sure if only affects sim or worse firmware. Steps to reproduce:

  • start sim

  • with main window active ie post start up warnings

  • click or press enter to display sub menu

  • click or press enter to select Manage Models

  • with the active model displayed click or press enter

  • with the action menu active click exit or press esc

  • Segmentation fault - file lv_group.c line 287

    line 285 void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
    line 286 {
    line 287 group->focus_cb = focus_cb;
    line 288 {

@philmoz
Copy link
Collaborator

philmoz commented Dec 23, 2024

Also discovered I can crash a colour radio sim eg TX16S. Not sure if only affects sim or worse firmware. Steps to reproduce:

May need to rebase to get the fix from 5725.

@elecpower
Copy link
Collaborator Author

Also discovered I can crash a colour radio sim eg TX16S. Not sure if only affects sim or worse firmware. Steps to reproduce:

May need to rebase to get the fix from 5725.

Thanks @philmoz will rebase and recompile TX16S libsim and retest

@elecpower
Copy link
Collaborator Author

I'm not happy with the tool tips visuals but we have a PoC.

@elecpower
Copy link
Collaborator Author

@philmoz rebased and compiled TX16S libsim and it crashes with seg fault in simfatfs.cpp line 352.
Debug log last file processed before crash

30ms: f_stat(/utils/edgetx/vscode/radios/v211/tx16s/sdcard/WIDGETS/SoarETX) = OK
30ms: f_stat(/utils/edgetx/vscode/radios/v211/tx16s/sdcard/WIDGETS/SoarETX/main.lua) = OK
30ms: luaLoadFile(/WIDGETS/SoarETX/main.lua)
30ms: not found
30ms: f_stat(/utils/edgetx/vscode/radios/v211/tx16s/sdcard/WIDGETS/SoarETX/main.luac) = error 2 (No such file or directory)
30ms: f_stat(/utils/edgetx/vscode/radios/v211/tx16s/sdcard/WIDGETS/SoarETX/main.lua) = OK
30ms: luaLoadScriptFileToState(/WIDGETS/SoarETX/main.lua, T): loading /WIDGETS/SoarETX/main.lua
30ms: f_open(/utils/edgetx/vscode/radios/v211/tx16s/sdcard/WIDGETS/SoarETX/main.lua, 1) = 0x7feda4102940 (FIL 0x7fedae0473e8)
30ms: f_close(0x7feda4102940) (FIL:0x7fedae0473e8)
30ms: not found
40ms: f_open(/utils/edgetx/vscode/radios/v211/tx16s/sdcard/WIDGETS/SoarETX/main.luac, a) = 0x7feda4102940 (FIL 0x7fedae0475f0)

Suspect it is one of the recent lua and/or sd card fixes.
I did download the latest SD card, sounds and themes into a clean directory and retested with same result.

@elecpower
Copy link
Collaborator Author

Retested buttons and keys and appears to be working consistently on T-Lite and TX16S (before rebasing)

@philmoz
Copy link
Collaborator

philmoz commented Dec 23, 2024

@philmoz rebased and compiled TX16S libsim and it crashes with seg fault in simfatfs.cpp line 352. Debug log last file processed before crash

Needs PR #5732 - just waiting for it to be merged.

@elecpower
Copy link
Collaborator Author

Thanks. Saw PR after I noted here but didn't have time to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
companion Related to the companion software simulator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants