Browse Source

checked virtual "EEPROM" -> works

tags/v1.0.0
Dominik Bartsch 2 years ago
parent
commit
13db3da082
3 changed files with 22 additions and 1 deletions
  1. 5
    0
      lib/treppe/treppe.cpp
  2. 1
    1
      lib/treppe/treppe.h
  3. 16
    0
      src/main.cpp

+ 5
- 0
lib/treppe/treppe.cpp View File

pwmController.setPWMFrequency(100); pwmController.setPWMFrequency(100);
//pwmController.setAllChannelsPWM(idle_pwm); //pwmController.setAllChannelsPWM(idle_pwm);


pinMode(13, OUTPUT);
pinMode(0, OUTPUT);
digitalWrite(13, HIGH);
digitalWrite(0, HIGH);

pinMode(A0, INPUT); pinMode(A0, INPUT);
pinMode(SENSOR_OBEN, INPUT); pinMode(SENSOR_OBEN, INPUT);
pinMode(SENSOR_UNTEN, INPUT); pinMode(SENSOR_UNTEN, INPUT);

+ 1
- 1
lib/treppe/treppe.h View File

uint16_t idle_pwm_max = 100; uint16_t idle_pwm_max = 100;
uint16_t idle_pwm_ist = idle_pwm_max; uint16_t idle_pwm_ist = idle_pwm_max;
uint16_t idle_pwm_soll = 0; 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] uint16_t ldr_schwelle = 2; // activation value for FSM [lx]
struct fsm_pending_inputs_t { struct fsm_pending_inputs_t {

+ 16
- 0
src/main.cpp View File

#include "httpserver.h" #include "httpserver.h"
#include "ota.h" #include "ota.h"
#include "wifi_credentials.h" #include "wifi_credentials.h"
#include <EEPROM.h>


// BOARD // BOARD
#define ESP12_LED 2 #define ESP12_LED 2
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us") #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); } #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) void timerCallback(void *pArg)
{ {
Serial.println("Booting ...."); Serial.println("Booting ....");
pinMode(ESP12_LED, OUTPUT); 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.begin(); // Wire must be started first
Wire.setClock(1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz Wire.setClock(1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
stairs.setup(); stairs.setup();


os_timer_setfn(&timer1, timerCallback, &timer_flag); os_timer_setfn(&timer1, timerCallback, &timer_flag);
os_timer_arm(&timer1, 20, true); os_timer_arm(&timer1, 20, true);

Serial.println("SSID: " + String(wifi_data.SSID) + " PW: " + String(wifi_data.PW));
} }


uint32_t c = 0; uint32_t c = 0;

Loading…
Cancel
Save