We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Using a counter within a running thread to change the display when there is no actions on the touch screen for OmegaDash module



  • In my Dash projects I want to have a main display screen for basic monitoring then use tabs to get to specific screens for controlling with the tab grouping the controls. However after I am finished making control changes, I want the Dash to automatically go back to the monitor display.
    So the goal was to have some count down timer start then trigger the screen change but only after there is no more control activity.
    The flow is to start the count down when I change tabs to make a control change. Then upon the completion of a count down, automatically change the display back. One issue is that every control change needs to reset the timer so upon the last change it runs its full cycle and triggers the change.
    I decided to use a Micropython thread as the countdown and a global variable as the start count. This way I can update the value every time I make a control change thus resetting the count down to start from the top. Then when I am done making changes it will naturally finish the count down and trigger the screen change.

    Notes about the code:
    I annotated the example it creates three tabs with text in them.
    When initially started it will display tab 3 and start a 30 second count down.
    If you change tabs before it reaches 0, the count will reset to 35
    When you let it count down, it will switch the display to tab 1 and if you change tabs after that, it will start the countdown for 35 seconds.
    Consider it a small example, the code isn't particularly clean but it is posted as an example.

    Here is the link to the git repository for the code: https://github.com/ccapaldi/DashTabCountdown


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.