Comments (9)
Hi,
Can you give me a simple code example that demonstrates your issue?
from configmanager.
Hi,
i only want to serial print the value of "inching delay"
So, i wrote the following additional Code to extract the inching_delay from the struct:
float pause = config.inching_delay;
In the Loop, i use the Serial.print(pause); to print it to the monitor as a test. But, there are only 0. He wrote the value in the memory. But there is no value on the print.
Thank you very much,
André
from configmanager.
Hi,
Can you show me your actual code? Without it will not be able to help you.
from configmanager.
Alright. I will so it in 4 - 6 hours, because, i'am in work and the code at home :-).
Thanks a lot..
from configmanager.
Hi,
here is my Code:
#include "ConfigManager.h"
const char *settingsHTML = (char *)"/settings.html";
const char *stylesCSS = (char *)"/styles.css";
const char *mainJS = (char *)"/main.js";
struct Config {
char device_name[32];
float inching_delay;
int8_t led;
bool enabled;
} config;
struct Metadata {
int8_t version;
} meta;
ConfigManager configManager;
//Übergabe der Variablen aus dem Config - Manager/////////////////
char* mac = config.device_name;
float delaytime = config.inching_delay;
int led = config.led;
//Millis///
long previousMillis = 0;
long interval = 2000;
void APCallback(WebServer *server) {
server->on("/styles.css", HTTPMethod::HTTP_GET, server{
configManager.streamFile(stylesCSS, mimeCSS);
});
DebugPrintln(F("AP Mode Enabled. You can call other functions that should run after a mode is enabled ... "));
}
void APICallback(WebServer *server) {
server->on("/disconnect", HTTPMethod::HTTP_GET, server{
configManager.clearWifiSettings(false);
});
server->on("/settings.html", HTTPMethod::HTTP_GET, server{
configManager.streamFile(settingsHTML, mimeHTML);
});
// NOTE: css/js can be embedded in a single page HTML
server->on("/styles.css", HTTPMethod::HTTP_GET, server{
configManager.streamFile(stylesCSS, mimeCSS);
});
server->on("/main.js", HTTPMethod::HTTP_GET, server{
configManager.streamFile(mainJS, mimeJS);
});
server->on("/reboot", HTTPMethod::HTTP_GET, server{
ESP.restart();
});
}
void setup() {
Serial.begin(115200);
DEBUG_MODE = true;
DebugPrintln(F(""));
meta.version = 3;
// Setup config manager
configManager.setAPName("Demo");
configManager.setAPFilename("/index.html");
// Settings variables
configManager.addParameter("device_name", config.device_name, 32);
configManager.addParameter("inching_delay", &config.inching_delay);
configManager.addParameter("led", &config.led);
configManager.addParameter("enabled", &config.enabled);
// Meta Settings
configManager.addParameter("version", &meta.version, get);
// Init Callbacks
configManager.setAPCallback(APCallback);
configManager.setAPICallback(APICallback);
configManager.begin(config);
}
void loop() {
configManager.loop(); // Um das der Webseitenaufbau der HTML - Datei sauber erfolgen kann, kein delay im Loop einbauen. Besser Millis !!.
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
Serial.print(" MAC :");
Serial.println(mac);
Serial.println("-------------------------------------");
Serial.print(" Pause :");
Serial.println(delaytime);
Serial.println("-------------------------------------");
Serial.print("Pausenzeit :");
Serial.println(led);
Serial.println("-------------------------------------");
}
// Add your loop code here
}
from configmanager.
So the issue is that delaytime
is set before the config is read by ConfigManager. Move float delaytime = config.inching_delay;
to just above the Serial.println
. To be clear float delaytime = config.inching_delay;
is taking the current value of config.inching_delay
and will not be updated as it in not a pointer. This is the source of your issue.
from configmanager.
Hi,
thank you for your answer !
I put the code directly above the Serial.prints in the loop. Now, the values from mac and led are correct. But the float is 0.00.
Whatever i wrote in the /settings.html in the browser. The value is 0.00 .
That's the only point i had with your tip.
Thanks a lot for spending your time.
from configmanager.
Hi,
so i tested the code. The problems are homemade and sitting in the front of the monitor #-/.
The code runs perfectly. Thank you very much for your support !
Best regards to South Africa from Löhne, Germany...
André
from configmanager.
Awesome, glad you got it sorted out.
Enjoy,
Nick
from configmanager.
Related Issues (20)
- Unable to save WiFi settings to EEPROM [esp32] HOT 3
- Saving char arrays in EEPROM HOT 2
- Delay restarting device to allow web server response
- ConfigManager::begin() changes value of int in struct HOT 22
- Metadata adding config values HOT 2
- reading and writing from struct config data HOT 2
- Compiler warning HOT 1
- CORS errors HOT 6
- How can I make it to auto reconnect? HOT 4
- not possible to save the value 0 via settings.html
- Issue using LittleFS HOT 1
- Compiling / version issue with ArduinoJson HOT 3
- settings endpoint will only return last saved value HOT 5
- image file (.jpg/.png) cannot be used in index.html HOT 3
- v3 tracking issue HOT 11
- Saving config with wrong type wipes EEPROM memory HOT 3
- ESP32 Wifi Sucks .. connects every two tries .. Workaround thoughts HOT 4
- One little problem with one parameter HOT 5
- Is it possible to send a Webpage from ESP32 ? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from configmanager.