Skip to content

JavaScript PWM won't re-initialize #4203

@Himura2la

Description

@Himura2la

Describe the bug.

The PWM feature in outputs something only on first run after boot. If you exit a script and run again, there will be no PWM output signal.

Reproduction

  1. Switch on or reboot
  2. Run gpio.js from examples, or the following script:
    const eventLoop = require("@flipperdevices/fz-sdk/event_loop");
    const gpio = require("@flipperdevices/fz-sdk/gpio");
    let led2 = gpio.get("pa7"); // same as `gpio.get(2)`
    print("Commencing PWM (PA7)");
    eventLoop.subscribe(eventLoop.timer("periodic", 10), function (_, _item, led2, state) {
        led2.pwmWrite(1000, state);
        return [led2, (state + 1) % 101];
    }, led2, 0);
    eventLoop.run();
  3. Exit the script (Ctrl+C in fz-sdk or back button if started on flipper)
  4. Run it once again
  5. Notice the silence on PA7 pin

Anything else?

@portasynthinca3
still an issue in the current release version

Metadata

Metadata

Labels

BugJSJS Runtime, loader and API

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions