makerplane / pyEfis

Electronic Flight Information System in Python
GNU General Public License v2.0
58 stars 31 forks source link

Add Timeout to Menu Buttons to Hide #104

Closed makerplane-jnicol closed 3 months ago

makerplane-jnicol commented 3 years ago

Add a feature to show the menu buttons on screen touch and then timeout to hide them after 10 seconds.

e100 commented 3 months ago

With the old menu you could make a hide/show button that was always visible, it would just need some timer event to automatically hide, user would press show to make it return and reset the timer. But unless someone has a compelling reason to keep the old menu I think we should eventually remove it.

Looking at the new touchscreen buttons I think we could do this with little effort:

  1. Add a configurable timer that sets the FIX Key MENUHIDE to True when the timeout is reached
  2. Whenever MENUHIDE is set to False the timer is reset
  3. Add button: hide and button:show actions so we can hide/show buttons
  4. Add option to set PREVIOUS_CONDITION = result of previous condition, allows the next condition to work as an 'else' or 'else if'

The above would allow one to control when buttons show and hide. Think of the EMS button, it can be setup to turn red if some value is annunciating. That button could be setup to still show up red and be clickable even when MENUHIDE = True but when not annunciating and MENUHIDE = True it would be hidden.

EMS configuration to work like that:

type: simple
text: ""
dbkey: TSBTN{id}12
condition_keys:
  - CHT11
  - CHT12
  - CHT13
  - CHT14
  - EGT11
  - EGT12
  - EGT13
  - EGT14
  - MENUHIDE
conditions:
  - when: "[ SCREEN eq 'EMS' ] and not MENUHIDE"
    actions:
      - button: show
      - set text: PFD
      - set bg color: lightgray
    continue: true
  - when: "[ SCREEN ne 'EMS' ] and not MENUHIDE"
    actions:
      - button: show
      - set text: EMS
      - set bg color: lightgray
    continue: true
  - when: "SCREEN ne 'EMS' and [ CHT11.annunciate or CHT12.annunciate or CHT13.annunciate or CHT14.annunciate or EGT11.annunciate or EGT12.annunciate or EGT13.annunciate or EGT14.annunciate ]"
    actions:
      - button: show
      - set bg color: red
    continue: true
  - when: "MENUHIDE and not PREVIOUS_CONDITION"
    actions:
      - button: hide
  - when: "CLICKED eq true and SCREEN ne 'EMS'"
    actions:
      - show screen: EMS
  - when: "CLICKED eq true and SCREEN eq 'EMS'"
    actions:
      - show screen: PFD

So that would take care of hiding and prevention of hiding under user defined conditions. How do we unhide all the buttons? With no additional code changes one could pick a button that does not hide and becomes a 'show' button when others are hidden. Modified Units button to do that:

type: simple
text: "Units"
dbkey: TSBTN{id}14
conditions:
  - when: "MENUHIDE"
    actions:
      - set text: "Show\nMenu"
    continue: true
  - when: "CLICKED eq true and MENUHIDE"
    actions:
      - set text: Units
      - set value: MENUHIDE,False
  - when: "CLICKED eq true and not MENUHIDE"
    actions:
      - Set Instrument Units: "OAT,OILT1,Temperature,Pressure,Altitude:Toggle"

We could also setup the menu encoder option to set MENUHIDE to False when the user turns the encoder to make the buttons show up.

What do you think?