checked virtual "EEPROM" -> works

This commit is contained in:
Dominik Bartsch 2021-07-16 21:40:51 +02:00
parent 9518c06fd9
commit 13db3da082
3 changed files with 22 additions and 1 deletions

View File

@ -303,6 +303,11 @@ void Treppe::setup()
pwmController.setPWMFrequency(100);
//pwmController.setAllChannelsPWM(idle_pwm);
pinMode(13, OUTPUT);
pinMode(0, OUTPUT);
digitalWrite(13, HIGH);
digitalWrite(0, HIGH);
pinMode(A0, INPUT);
pinMode(SENSOR_OBEN, INPUT);
pinMode(SENSOR_UNTEN, INPUT);

View File

@ -21,7 +21,7 @@ private:
uint16_t idle_pwm_max = 100;
uint16_t idle_pwm_ist = idle_pwm_max;
uint16_t idle_pwm_soll = 0;
uint16_t active_pwm = 700;
uint16_t active_pwm = 2000;
uint16_t ldr_schwelle = 2; // activation value for FSM [lx]
struct fsm_pending_inputs_t {

View File

@ -12,6 +12,7 @@ extern "C" {
#include "httpserver.h"
#include "ota.h"
#include "wifi_credentials.h"
#include <EEPROM.h>
// BOARD
#define ESP12_LED 2
@ -34,6 +35,11 @@ uint32_t _t=0;
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us")
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > (_l)) { SP_US(_str, _t); }
struct { // Struct for wifi-data, 40 Bytes each SSID and PW
char SSID[40] = "";
char PW[40] = "";
} wifi_data;
void timerCallback(void *pArg)
{
@ -57,6 +63,14 @@ void setup() {
Serial.println("Booting ....");
pinMode(ESP12_LED, OUTPUT);
EEPROM.begin(512); // init virtual "EEPROM" with size 512 Bytes
//strncpy(wifi_data.SSID, "donotconnect", 40);
//strncpy(wifi_data.PW, "unsafe lol", 40);
EEPROM.get(0, wifi_data);
//EEPROM.commit();
Wire.begin(); // Wire must be started first
Wire.setClock(1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
stairs.setup();
@ -87,6 +101,8 @@ void setup() {
os_timer_setfn(&timer1, timerCallback, &timer_flag);
os_timer_arm(&timer1, 20, true);
Serial.println("SSID: " + String(wifi_data.SSID) + " PW: " + String(wifi_data.PW));
}
uint32_t c = 0;