diff --git a/shade_controller/config.h b/shade_controller/config.h index f1a9dbb..8218448 100644 --- a/shade_controller/config.h +++ b/shade_controller/config.h @@ -1,5 +1,10 @@ //Config stuff +//Uncomment to enable wifi manager +#define wifiManagerEnable + +// + /* Speed Settings in Steps/Second * You will have to play with these values to find a * reliable setup. I recomend putting a small extra load diff --git a/shade_controller/functions.h b/shade_controller/functions.h index 3b9bf4c..398fd51 100644 --- a/shade_controller/functions.h +++ b/shade_controller/functions.h @@ -91,7 +91,10 @@ void ledTurn(int _mode) { //We will conigure Blynk with this void blynkConfig (){ Blynk.config(auth,server,port); - Blynk.connectWiFi(ssid,pass); + + #if !(defined(wifiManagerEnabled)) + Blynk.connectWiFi(ssid,pass); + #endif } //This will connect or run blynk diff --git a/shade_controller/shade_controller.ino b/shade_controller/shade_controller.ino index 78069e7..466c3a7 100644 --- a/shade_controller/shade_controller.ino +++ b/shade_controller/shade_controller.ino @@ -15,6 +15,8 @@ //version 2.6.0 const int configVersion = 3; +int safeConfigVersion = 3; //The oldest version of config that can + //be updated from. #include "structs.h" @@ -37,6 +39,12 @@ long currentDistance = 0; #include #include "ota.h" +//wifiManager +#ifdef wifiManagerEnable + #include + #include +#endif + //FastLED Setup #include FASTLED_USING_NAMESPACE @@ -179,9 +187,13 @@ pwmStruct pwm = { void setup() { Serial.begin(74880); - Serial.println("dsadsadaas"); delay(50); + #ifdef wifiManagerEnable + // WiFiManager intialization. + WiFiManager wifi; + #endif + analogWrite(PWM_PIN,0); @@ -206,7 +218,13 @@ void setup() { cmdAdd("pos",pos); #endif - + #ifdef wifiManagerEnable + // Create AP, if necessary + wifi.autoConnect(myHostName); + + // Set WIFI module to STA mode + WiFi.mode( WIFI_STA ); + #endif diff --git a/shade_controller/structs.h b/shade_controller/structs.h index 5b99c1f..64a0deb 100644 --- a/shade_controller/structs.h +++ b/shade_controller/structs.h @@ -34,4 +34,4 @@ struct fastLED { int hue; int sat; int val; -} +};