Compare commits

..

No commits in common. "1d55f3638728d470e3ead6a82a9fe22f8be78e94" and "764cf45b80b8a78c705d1a330ecc9d85b4b2e276" have entirely different histories.

5 changed files with 9 additions and 101 deletions

View file

@ -29,7 +29,7 @@ long_line_column=72
[files]
current_page=0
FILE_NAME_0=493;Sh;0;EUTF-8;0;1;0;.%2Fcangrow.sh;0;2
FILE_NAME_0=0;Sh;0;EUTF-8;0;1;0;.%2Fcangrow.sh;0;2
FILE_NAME_1=0;Arduino;0;EUTF-8;0;1;0;.%2FCanGrow.ino;0;2
FILE_NAME_2=0;C++;0;EUTF-8;0;1;0;.%2Finclude%2FCanGrow.h;0;2
FILE_NAME_3=0;C++;0;EUTF-8;0;1;0;.%2Finclude%2FCanGrow_Core.h;0;2
@ -43,7 +43,7 @@ FILE_NAME_8=0;C++;0;EUTF-8;0;1;0;.%2Finclude%2FCanGrow_Version.h;0;2
C++FT_00_LB=_Compile
C++FT_00_CM=cd .. ; ./cangrow.sh build
C++FT_00_WD=
filetypes=C++;Arduino;Sh;
filetypes=C++;Arduino;
ArduinoFT_00_LB=_Build
ArduinoFT_00_CM=./cangrow.sh build
ArduinoFT_00_WD=
@ -53,12 +53,6 @@ ArduinoFT_01_WD=
C++FT_01_LB=_Build & Upload
C++FT_01_CM=cd .. ; ./cangrow.sh upload
C++FT_01_WD=
ShFT_00_LB=Build
ShFT_00_CM=./cangrow.sh build
ShFT_00_WD=
ShFT_01_LB=Build & Upload
ShFT_01_CM=./cangrow.sh upload
ShFT_01_WD=
[VTE]
last_dir=/home/marcus/Dokumente/git/hl.la10cy.net-website

View file

@ -26,7 +26,7 @@
* THE SOFTWARE.
*
*/
/*
* Libraries include
@ -125,14 +125,6 @@ void setup() {
LFS_init();
if(existFile(CANGROW_CFG)) {
readFile(CANGROW_CFG);
Serial.printf(":: config.GrowName: %s \n", config.GrowName);
Serial.printf(":: load config.json \n");
loadConfig(config);
Serial.printf(":: config.GrowName: %s \n", config.GrowName);
Serial.print(":: config.DoG: ");
Serial.println(config.DoG);
} else {
writeFile(CANGROW_CFG, "{}");
}
@ -166,16 +158,6 @@ void setup() {
*/
}
bool alrdySaved = false;
void loop() {
if((digitalRead(PinWIPE) != PinWIPE_default) && (alrdySaved == false)) {
Serial.println(":: [LOOP] PinWIPE is triggered, saving config.json");
saveConfig(config);
alrdySaved = true;
} else if( (digitalRead(PinWIPE) != PinWIPE_default) && (alrdySaved == true) ) {
alrdySaved = true;
} else {
alrdySaved = false;
}
}

View file

@ -4,8 +4,8 @@
test -z $TTY && TTY="/dev/ttyUSB0"
test -z $IP && IP="192.168.4.20"
test -z $VER && VER="0.2-dev"
#test -z $BOARD && BOARD="esp8266:esp8266:d1_mini_clone"
test -z $BOARD && BOARD="esp32:esp32:d1_mini32"
test -z $BOARD && BOARD="esp8266:esp8266:d1_mini_clone"
#test -z $BOARD && BOARD="esp32:esp32:d1_mini32"
BUILD="$(git rev-parse --short HEAD)-$(echo $BOARD | cut -d : -f1)-$(date '+%Y%m%d%H%M%S')"

View file

@ -29,9 +29,4 @@
#include "CanGrow_Version.h"
struct Config {
char GrowName[64];
int DoG;
};
Config config;
#define CANGROW_CFG "/config.json"

View file

@ -27,8 +27,6 @@
*
*/
#define CANGROW_CFG "/config.json"
// LittleFS auto format
#define FORMAT_LITTLEFS_IF_FAILED true
@ -98,11 +96,8 @@ void readFile(const char *path) {
}
Serial.printf(":: [LittleFS] file content: %s\n", path);
Serial.println("----");
while (file.available()) { Serial.write(file.read()); }
Serial.println("\n----");
file.close();
file.close();
}
void writeFile(const char *path, const char *message) {
@ -124,7 +119,7 @@ void writeFile(const char *path, const char *message) {
} else {
Serial.printf(":: [LittleFS] writing file FAILED: %s\n", path);
}
//delay(2000); // Make sure the CREATE and LASTWRITE times are different
delay(2000); // Make sure the CREATE and LASTWRITE times are different
file.close();
}
@ -147,64 +142,6 @@ void deleteFile(const char *path) {
}
}
// https://arduinojson.org/v7/example/config/
void loadConfig(Config& config) {
#ifdef ESP8266
File file = LittleFS.open(CANGROW_CFG, "r");
#endif
#ifdef ESP32
fs::FS &fs = LittleFS;
File file = fs.open(CANGROW_CFG);
#endif
JsonDocument doc;
// Deserialize the JSON document
DeserializationError error = deserializeJson(doc, file);
if (error)
Serial.printf(":: [LittleFS] FAILED to load config: %s\n", CANGROW_CFG);
// Copy values from the JsonDocument to the Config
strlcpy(config.GrowName,
doc["GrowName"] | "CanGrow",
sizeof(config.GrowName));
config.DoG = doc["DoG"] | 3;
// Close the file (Curiously, File's destructor doesn't close the file)
file.close();
}
void saveConfig(Config& config) {
#ifdef ESP8266
File file = LittleFS.open(CANGROW_CFG, "w");
#endif
#ifdef ESP32
fs::FS &fs = LittleFS;
File file = fs.open(CANGROW_CFG, FILE_WRITE);
#endif
if (!file) {
Serial.printf(":: [LittleFS] FAILED to open configfile for writing: %s\n", CANGROW_CFG);
return;
} else {
Serial.printf(":: [LittleFS] opened for writing %s\n", CANGROW_CFG);
}
JsonDocument doc;
doc["GrowName"] = config.GrowName;
doc["DoG"] = config.DoG + 1 ;
// Serialize JSON to file
if (serializeJson(doc, file) == 0) {
Serial.printf(":: [LittleFS] FAILED to write configfile: %s\n", CANGROW_CFG);
} else {
Serial.printf(":: [LittleFS] successfully written %s\n", CANGROW_CFG);
}
file.close();
}
///*
//* ESP8266 functions