<commit_before>/**
 * WiFiManagerParameter child class example
 */
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include <Arduino.h>
#include <EEPROM.h>

#define SETUP_PIN 0

class IPAddressParameter : public WiFiManagerParameter {
public:
    IPAddressParameter(const char *id, const char *placeholder, IPAddress address)
        : WiFiManagerParameter("") {
        init(id, placeholder, address.toString().c_str(), 16, "", WFM_LABEL_BEFORE);
    }

    bool getValue(IPAddress &ip) {
        return ip.fromString(WiFiManagerParameter::getValue());
    }
};

class IntParameter : public WiFiManagerParameter {
public:
    IntParameter(const char *id, const char *placeholder, long value, const uint8_t length = 10)
        : WiFiManagerParameter("") {
        init(id, placeholder, String(value).c_str(), length, "", WFM_LABEL_BEFORE);
    }

    long getValue() {
        return String(WiFiManagerParameter::getValue()).toInt();
    }
};

class FloatParameter : public WiFiManagerParameter {
public:
    FloatParameter(const char *id, const char *placeholder, float value, const uint8_t length = 10)
        : WiFiManagerParameter("") {
        init(id, placeholder, String(value).c_str(), length, "", WFM_LABEL_BEFORE);
    }

    float getValue() {
        return String(WiFiManagerParameter::getValue()).toFloat();
    }
};

struct Settings {
    float f;
    int i;
    char s[20];
    uint32_t ip;
} sett;


void setup() {
    WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP    
    pinMode(SETUP_PIN, INPUT_PULLUP);
    Serial.begin(115200); 

    //Delay to push SETUP button
    Serial.println("Press setup button");
    for (int sec = 3; sec > 0; sec--) {
        Serial.print(sec);
        Serial.print("..");
        delay(1000);
    }

    EEPROM.begin( 512 );
    EEPROM.get(0, sett);
    Serial.println("Settings loaded");
    
    if (digitalRead(SETUP_PIN) == LOW) {  
        // Button pressed 
        Serial.println("SETUP");

        WiFiManager wm;
        
        sett.s[19] = '\0';   //add null terminator at the end cause overflow
        WiFiManagerParameter param_str( "str", "param_string",  sett.s, 20);
        FloatParameter param_float( "float", "param_float",  sett.f);
        IntParameter param_int( "int", "param_int",  sett.i);

        IPAddress ip(sett.ip);
        IPAddressParameter param_ip("ip", "param_ip", ip);
<commit_msg>add flash warning<commit_after>/**
 * WiFiManagerParameter child class example
 */
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include <Arduino.h>
#include <EEPROM.h>

#define SETUP_PIN 0

class IPAddressParameter : public WiFiManagerParameter {
public:
    IPAddressParameter(const char *id, const char *placeholder, IPAddress address)
        : WiFiManagerParameter("") {
        init(id, placeholder, address.toString().c_str(), 16, "", WFM_LABEL_BEFORE);
    }

    bool getValue(IPAddress &ip) {
        return ip.fromString(WiFiManagerParameter::getValue());
    }
};

class IntParameter : public WiFiManagerParameter {
public:
    IntParameter(const char *id, const char *placeholder, long value, const uint8_t length = 10)
        : WiFiManagerParameter("") {
        init(id, placeholder, String(value).c_str(), length, "", WFM_LABEL_BEFORE);
    }

    long getValue() {
        return String(WiFiManagerParameter::getValue()).toInt();
    }
};

class FloatParameter : public WiFiManagerParameter {
public:
    FloatParameter(const char *id, const char *placeholder, float value, const uint8_t length = 10)
        : WiFiManagerParameter("") {
        init(id, placeholder, String(value).c_str(), length, "", WFM_LABEL_BEFORE);
    }

    float getValue() {
        return String(WiFiManagerParameter::getValue()).toFloat();
    }
};

struct Settings {
    float f;
    int i;
    char s[20];
    uint32_t ip;
} sett;


void setup() {
    WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP    
    pinMode(SETUP_PIN, INPUT_PULLUP);
    Serial.begin(115200); 

    //Delay to push SETUP button
    Serial.println("Press setup button");
    for (int sec = 3; sec > 0; sec--) {
        Serial.print(sec);
        Serial.print("..");
        delay(1000);
    }

    // warning for example only, this will initialize empty memory into your vars
    // always init flash memory or add some checksum bits
    EEPROM.begin( 512 );
    EEPROM.get(0, sett);
    Serial.println("Settings loaded");
    
    if (digitalRead(SETUP_PIN) == LOW) {  
        // Button pressed 
        Serial.println("SETUP");

        WiFiManager wm;
        
        sett.s[19] = '\0';   //add null terminator at the end cause overflow
        WiFiManagerParameter param_str( "str", "param_string",  sett.s, 20);
        FloatParameter param_float( "float", "param_float",  sett.f);
        IntParameter param_int( "int", "param_int",  sett.i);

        IPAddress ip(sett.ip);
        IPAddressParameter param_ip("ip", "param_ip", ip);

{'fraction_non_alphanumeric': 0.1302859444220701, 'fraction_numerical': 0.01369311316955296, 'mean_word_length': 3.071311475409836, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2003838', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1521, 'n_words': 385}