Compare commits
	
		
			10 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | a7109fd572 | ||
|   | f3092627a4 | ||
|   | f5c82af200 | ||
|   | ad56414edf | ||
|   | 75c048202e | ||
|   | e67668693b | ||
|   | 93fe8c2818 | ||
|   | e186b0568d | ||
|   | 10196ea4e5 | ||
|   | f85a6f7c3c | 
							
								
								
									
										46
									
								
								usermods/powerap/powerap.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								usermods/powerap/powerap.h
									
									
									
									
									
										Normal 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; } | ||||
|  | ||||
| }; | ||||
| @@ -198,6 +198,10 @@ | ||||
|   #include "../usermods/pwm_outputs/usermod_pwm_outputs.h" | ||||
| #endif | ||||
|  | ||||
| #ifdef USERMOD_POWER_AP | ||||
|   #include "../usermods/powerap/powerap.h" | ||||
| #endif | ||||
|  | ||||
| #ifdef USERMOD_HTTP_PULL_LIGHT_CONTROL | ||||
|   #include "../usermods/usermod_v2_HttpPullLightControl/usermod_v2_HttpPullLightControl.h" | ||||
| #endif | ||||
| @@ -419,6 +423,10 @@ void registerUsermods() | ||||
|   UsermodManager::add(new ShtUsermod()); | ||||
|   #endif | ||||
|  | ||||
|   #ifdef USERMOD_POWER_AP | ||||
|   usermods.add(new PowerAPUsermod()); | ||||
|   #endif | ||||
|    | ||||
|   #ifdef USERMOD_ANIMARTRIX | ||||
|   UsermodManager::add(new AnimartrixUsermod("Animartrix", false)); | ||||
|   #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user