diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 4243987..e51a287 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -60,6 +60,18 @@ #include "LittleFS.h" +/* + * CanGrow platform specific includes + */ + +#ifdef ESP8266 +#include "include/CanGrow_ESP8266.h" +#endif + +#ifdef ESP32 +#include "include/CanGrow_ESP32.h" +#endif + /* * CanGrow includes */ @@ -79,16 +91,10 @@ void setup() { // Write a line before doing serious output, because before there is some garbage in serial // whats get the cursor somewhere over the place Serial.println("420"); - Serial.print(".:: CanGrow firmware v"); - Serial.print(CanGrowVer); - Serial.print(" build "); - Serial.print(CanGrowBuild); - Serial.println(" starting ::."); - - - Serial.print(":: To format LittleFS, pull "); - Serial.print(PinWIPE); - Serial.println("(PinWIPE) to LOW - NOW! (2 seconds left) ::"); + Serial.printf(".:: CanGrow firmware v%s build %s starting ::.\n", CanGrowVer, CanGrowBuild); + + Serial.printf("II To format LittleFS, pull GPIO %s (PinWIPE) to LOW - NOW! (2 seconds left) ::", PinWIPE); + Serial.println(""); // blink with the onboard LED on D4 (PinWIPE) for(byte i = 0; i <= 6 ; i++) { @@ -100,25 +106,13 @@ void setup() { delay(333); } - #ifdef ESP8266 - // set back to HIGH because thats the default on esp8266 - digitalWrite(PinWIPE, HIGH); - #endif - #ifdef ESP32 - // set back to HIGH because thats the default esp32 - digitalWrite(PinWIPE, LOW); - #endif + // set PinWIPE back to its default + digitalWrite(PinWIPE, PinWIPE_default); // read status from PinWIPE to WIPE // when PinWIPE is set to LOW, format LittleFS - - #ifdef ESP8266 - if(digitalRead(PinWIPE) == LOW) { - #endif - #ifdef ESP32 - if(digitalRead(PinWIPE) == HIGH) { - #endif + if(digitalRead(PinWIPE) != PinWIPE_default) { LFS_format(); Panic(); } diff --git a/Arduino/CanGrow/include/CanGrow.h b/Arduino/CanGrow/include/CanGrow.h index 862ad0b..2702118 100644 --- a/Arduino/CanGrow/include/CanGrow.h +++ b/Arduino/CanGrow/include/CanGrow.h @@ -30,12 +30,3 @@ #include "CanGrow_Version.h" #define CANGROW_CFG "/config.json" - - -#ifdef ESP8266 -const uint8_t PinWIPE = D4; -#endif - -#ifdef ESP32 -const uint8_t PinWIPE = 2; -#endif diff --git a/Arduino/CanGrow/include/CanGrow_ESP32.h b/Arduino/CanGrow/include/CanGrow_ESP32.h new file mode 100644 index 0000000..d9fbdb1 --- /dev/null +++ b/Arduino/CanGrow/include/CanGrow_ESP32.h @@ -0,0 +1,32 @@ +/* + * + * include/CanGrow_ESP32.h - ESP32 specific header file + * + * + * MIT License + * + * Copyright (c) 2024 DeltaLima + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + + +#define PinWIPE 2 +#define PinWIPE_default LOW diff --git a/Arduino/CanGrow/include/CanGrow_ESP8266.h b/Arduino/CanGrow/include/CanGrow_ESP8266.h new file mode 100644 index 0000000..260df47 --- /dev/null +++ b/Arduino/CanGrow/include/CanGrow_ESP8266.h @@ -0,0 +1,32 @@ +/* + * + * include/CanGrow_ESP8266.h - ESP8266 specific header file + * + * + * MIT License + * + * Copyright (c) 2024 DeltaLima + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + + +#define PinWIPE 2 +#define PinWIPE_default HIGH