Skip to content

Add posibility to run multiple JS scripts, background scripts, run script on start, task manager #1093

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Tawank
Copy link
Contributor

@Tawank Tawank commented Apr 15, 2025

Because of recent changes in loopOptions, which now include an infinite loop and no longer return to the main menu on every render, running JS scripts via serial commands doesn't work while idling in the main menu.
You now need to manually select any option in the menu to run a script.

To fix this, I'm planning to introduce a task manager to handle multiple tasks. Scripts are already running as RTOS tasks so it should be possible.

I'll provide API to run JS scripts from any core or task, so launching scripts from the serial interface or WebUI will work again.

Before we do this we need to remove any state from js functions, so we need to remove sprites and gifs vectors, and store them as pointers in duktape context, so there can be multiple duktape context(scripts).

Proposed Changes

  • Added functions to JS: runtime.toBackground(), runtime.toForeground() and runtime.isForeground() to make possible to run scripts in background.
  • Added JS script on startup function.
  • Added task manager for JS scripts.

Types of Changes

Bugfix, New Feature

User-Facing Change

 - Added `runtime.toBackground()`, `runtime.toForeground()` and `runtime.isForeground()` to make possible to run scripts in background.
 - Added JS script on startup function.
 - Added task manager for JS scripts.

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

Successfully merging this pull request may close these issues.

1 participant