Power on directly after boot?

Hello I have a small question sadly didn’t found anything in the search

Is it possible to ignite the sword directly after boot without buttons?
I would like to wall mount the saber with an external power source wich is trigger via a photocell sensor

And then power off after a specific time frame

Is this possible ?
Thanks

Short answer: yes

There are several ways to do this.
Probably the best would be to put a “script” in your config file, that would look something like:

#ifdef CONFIG_BOTTOM
struct Script : Looper, StateMachine {
  const char* name() override { return "script"; }
  void Loop() override {
     STATE_MACHINE_BEGIN();
     CommandParser::DoParse("on", nullptr);
     SLEEP(2 * 60 * 1000); // 2 minutes
     CommandParser::DoParse("off", nullptr);
     STATE_MACHINE_END();
  }
};
Script script;
#endif
1 Like

Thank you
I will try it out never thought about a script
So I don’t have to mess with the core scripts itself

If I could post 5 likes, I would.

3 Likes