Compare commits

...

10 Commits

Author SHA1 Message Date
Blaz Kristan
a7109fd572 Merge branch '0_15' into power-ap 2024-09-23 19:22:31 +02:00
Blaz Kristan
f3092627a4 Merge branch '0_15' into power-ap 2024-06-30 10:51:35 +02:00
Blaz Kristan
f5c82af200 Merge branch '0_15' into power-ap 2024-04-26 20:45:52 +02:00
Blaz Kristan
ad56414edf Merge branch '0_15' into power-ap 2024-04-09 16:38:53 +02:00
Blaz Kristan
75c048202e Merge branch 'main' into power-ap 2023-07-15 22:01:48 +02:00
Blaz Kristan
e67668693b Merge branch 'main' into power-ap 2023-03-28 09:29:39 +02:00
Blaz Kristan
93fe8c2818 Minor adjustment. 2022-12-10 19:58:34 +01:00
Blaz Kristan
e186b0568d Bugfix. 2022-12-10 01:44:16 +01:00
Blaz Kristan
10196ea4e5 remove comment 2022-12-03 21:22:48 +01:00
Blaz Kristan
f85a6f7c3c Force AP mode on power bounce
-  requires 3 power cycles
2022-12-03 12:35:48 +01:00
2 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
#pragma once
#include "wled.h"
class PowerAPUsermod : public Usermod {
private:
unsigned long lastTime = 0;
String fname = F("/boot.dat");
public:
void setup() {
if (WLED_FS.exists(fname)) {
File fl = WLED_FS.open(fname,"r+");
if (!fl) DEBUG_PRINTLN(F("--- File read failed ---"));
char data = fl.read();
if (data == '0') {
DEBUG_PRINTLN(F("--- 2nd boot ---"));
fl.seek(0);
fl.write('1');
} else if (data == '1') {
DEBUG_PRINTLN(F("--- 3rd boot ---"));
apBehavior = AP_BEHAVIOR_ALWAYS;
WLED::instance().initAP(true);
}
fl.close();
} else {
DEBUG_PRINTLN(F("--- 1st boot ---"));
File fl = WLED_FS.open(fname,"w");
fl.write((uint8_t*)"0 ", 2); // write('0'); does not work somehow
fl.close();
}
}
void loop() {
if (millis() < 10000 && millis() - lastTime > 5000) {
lastTime = millis();
if (WLED_FS.exists(fname)) {
DEBUG_PRINTLN(F("--- Removing boot file ---"));
WLED_FS.remove(fname);
}
}
}
uint16_t getId() { return USERMOD_ID_UNSPECIFIED; }
};

View File

@@ -198,6 +198,10 @@
#include "../usermods/pwm_outputs/usermod_pwm_outputs.h" #include "../usermods/pwm_outputs/usermod_pwm_outputs.h"
#endif #endif
#ifdef USERMOD_POWER_AP
#include "../usermods/powerap/powerap.h"
#endif
#ifdef USERMOD_HTTP_PULL_LIGHT_CONTROL #ifdef USERMOD_HTTP_PULL_LIGHT_CONTROL
#include "../usermods/usermod_v2_HttpPullLightControl/usermod_v2_HttpPullLightControl.h" #include "../usermods/usermod_v2_HttpPullLightControl/usermod_v2_HttpPullLightControl.h"
#endif #endif
@@ -419,6 +423,10 @@ void registerUsermods()
UsermodManager::add(new ShtUsermod()); UsermodManager::add(new ShtUsermod());
#endif #endif
#ifdef USERMOD_POWER_AP
usermods.add(new PowerAPUsermod());
#endif
#ifdef USERMOD_ANIMARTRIX #ifdef USERMOD_ANIMARTRIX
UsermodManager::add(new AnimartrixUsermod("Animartrix", false)); UsermodManager::add(new AnimartrixUsermod("Animartrix", false));
#endif #endif