Skip to content

Application manager

Overview

Application manager, passed in through the life cycle function (on_boot) during device startup. Applications can obtain or save their own configuration information through the application manager. In addition, they can also actively exit the application, etc.

app_mgr = None
async def on_boot(apm):
    global app_mgr
    app_mgr = apm

app_mgr.state

  • Description: This property indicates the current life cycle state of the application.
  • Value range "0" (SHUTDOWN), "1" (STARTED), "2" (ACTIVE), "3" (PAUSED), "4" (STOPPED).
  • Default: "0" (SHUTDOWN).

app_mgr.enter_root_page()

  • background knowledge:
    • When the user presses the ESC button on the Dock device, the expectation is to return to the previous interface; the bottom layer of the Vobot Dock system will also listen to this button and decide whether to exit the current application;
    • If you are currently on the top-level page of your application (or your application has only a single level of UI), the user can exit your application by pressing a button;
    • However, if you are currently in a subpage of your application, you should let the underlying system know this state so that the user does not exit the application after pressing the key.
  • describe:
    • Notify the system that the current application has stayed on the top page, and the user will exit the application by pressing the ESC key.
    • When the ESC key is pressed, the system provides an operation to exit the application without internal processing of the application.
    • Since the system cannot directly know whether the operation of exiting the application can be performed, the application can prompt the system whether the operation of exiting the application can be performed currently through app_mgr.enter_root_page() and app_mgr.leave_root_page().

app_mgr.leave_root_page()

  • Description: Notify the system that the current application is in a subpage. At this time, if the user presses the ESC button, the system will not exit the App.

app_mgr.custom_dialog(title, content, confirm=None, cancel=None, cb=None, subtitle, qr=None, style=None)

  • Description: Display dialog box
  • Parameters:
    • title:
      • Dialog title
    • content:
      • Dialog text
    • confirm:
      • When the input value is of type str, it will modify the prompt text of the corresponding button.
    • cancel:
      • When the input value is of type str, it will modify the prompt text of the corresponding button.
    • cb:
      • Dialog event callback
      • Parameters (def cb(res)):
        • res passes the response content of the key press:
          • lv.KEY.ENTER: Encoder press operation
          • lv.key.ESC: Operation of pressing the ESC key
    • subtitle (optional):
      • Dialog subtitle
    • qr (optional):
      • If there is no text content corresponding to the QR code, the QR code will not be displayed.
    • style (optional):
      • The color style of the dialog box subtitle font. The options are:
      • app_mgr.DIALOG.INFO (default)
      • app_mgr.DIALOG.WARNING
      • app_mgr.DIALOG.ERROR
  • return value:
    • Returns the dialog object (LVGL widget).

app_mgr.config(cfg=None)

  • Description: Obtain/modify the configuration related to the current application. If no parameters are passed when calling the function, the configuration information is obtained. Otherwise, the cfg is saved to the disk.
  • Parameters:
    • cfg:
      • configuration information will be saved.

Usage example

# Get the current application status
state = app_mgr.state

# Save application configuration information
app_mgr.config({"test":123})

# Get application configuration information
cfg = app_mgr.config()

# Generate a simple dialog box
app_mgr.custom_dialog(title="Title", content="Content", cancel="Back")

# Actively exit the current application
await app_mgr.exit()

Precautions

  • There is a mechanism to exit the App in the system, but the application will only respond to the user's ESC key operation when it is on the top page and there is no dialog box.
  • If you want to actively exit the application, you should ensure that the application calls app_mgr.exit() in the ACTIVE state.
  • Before actively exiting the application app_mgr.exit(), make sure that all UI screens of the current application are cleared.