Coder Social home page Coder Social logo

Comments (9)

nrwiersma avatar nrwiersma commented on July 22, 2024

Hi,

Can you give me a simple code example that demonstrates your issue?

from configmanager.

Stargazer32584 avatar Stargazer32584 commented on July 22, 2024

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.

nrwiersma avatar nrwiersma commented on July 22, 2024

Hi,

Can you show me your actual code? Without it will not be able to help you.

from configmanager.

Stargazer32584 avatar Stargazer32584 commented on July 22, 2024

Alright. I will so it in 4 - 6 hours, because, i'am in work and the code at home :-).

Thanks a lot..

from configmanager.

Stargazer32584 avatar Stargazer32584 commented on July 22, 2024

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.

nrwiersma avatar nrwiersma commented on July 22, 2024

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.

Stargazer32584 avatar Stargazer32584 commented on July 22, 2024

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.

Stargazer32584 avatar Stargazer32584 commented on July 22, 2024

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.

nrwiersma avatar nrwiersma commented on July 22, 2024

Awesome, glad you got it sorted out.

Enjoy,
Nick

from configmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.