begin to seperate stuff for esp32 and esp8266 in their own header files

This commit is contained in:
Marcus 2024-10-17 22:59:51 +02:00
parent f130700cf0
commit 36b2da7802
4 changed files with 83 additions and 34 deletions

View file

@ -60,6 +60,18 @@
#include "LittleFS.h" #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 * CanGrow includes
*/ */
@ -79,16 +91,10 @@ void setup() {
// Write a line before doing serious output, because before there is some garbage in serial // Write a line before doing serious output, because before there is some garbage in serial
// whats get the cursor somewhere over the place // whats get the cursor somewhere over the place
Serial.println("420"); Serial.println("420");
Serial.print(".:: CanGrow firmware v"); Serial.printf(".:: CanGrow firmware v%s build %s starting ::.\n", CanGrowVer, CanGrowBuild);
Serial.print(CanGrowVer);
Serial.print(" build "); Serial.printf("II To format LittleFS, pull GPIO %s (PinWIPE) to LOW - NOW! (2 seconds left) ::", PinWIPE);
Serial.print(CanGrowBuild); Serial.println("");
Serial.println(" starting ::.");
Serial.print(":: To format LittleFS, pull ");
Serial.print(PinWIPE);
Serial.println("(PinWIPE) to LOW - NOW! (2 seconds left) ::");
// blink with the onboard LED on D4 (PinWIPE) // blink with the onboard LED on D4 (PinWIPE)
for(byte i = 0; i <= 6 ; i++) { for(byte i = 0; i <= 6 ; i++) {
@ -100,25 +106,13 @@ void setup() {
delay(333); delay(333);
} }
#ifdef ESP8266 // set PinWIPE back to its default
// set back to HIGH because thats the default on esp8266 digitalWrite(PinWIPE, PinWIPE_default);
digitalWrite(PinWIPE, HIGH);
#endif
#ifdef ESP32
// set back to HIGH because thats the default esp32
digitalWrite(PinWIPE, LOW);
#endif
// read status from PinWIPE to WIPE // read status from PinWIPE to WIPE
// when PinWIPE is set to LOW, format LittleFS // when PinWIPE is set to LOW, format LittleFS
if(digitalRead(PinWIPE) != PinWIPE_default) {
#ifdef ESP8266
if(digitalRead(PinWIPE) == LOW) {
#endif
#ifdef ESP32
if(digitalRead(PinWIPE) == HIGH) {
#endif
LFS_format(); LFS_format();
Panic(); Panic();
} }

View file

@ -30,12 +30,3 @@
#include "CanGrow_Version.h" #include "CanGrow_Version.h"
#define CANGROW_CFG "/config.json" #define CANGROW_CFG "/config.json"
#ifdef ESP8266
const uint8_t PinWIPE = D4;
#endif
#ifdef ESP32
const uint8_t PinWIPE = 2;
#endif

View file

@ -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

View file

@ -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