EEP implementation
This commit is contained in:
parent
42a927e383
commit
31c268487c
@ -303,6 +303,8 @@ void Treppe::setup()
|
|||||||
pwmController.setPWMFrequency(100);
|
pwmController.setPWMFrequency(100);
|
||||||
//pwmController.setAllChannelsPWM(idle_pwm);
|
//pwmController.setAllChannelsPWM(idle_pwm);
|
||||||
|
|
||||||
|
EEPROM.get(EEP_START_ADDR, parameters); // get Parameters of flash
|
||||||
|
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
pinMode(0, OUTPUT);
|
pinMode(0, OUTPUT);
|
||||||
digitalWrite(13, HIGH);
|
digitalWrite(13, HIGH);
|
||||||
@ -317,13 +319,17 @@ void Treppe::setup()
|
|||||||
Serial.printf("Treppe: stufen=%d\n", stufen);
|
Serial.printf("Treppe: stufen=%d\n", stufen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Treppe::saveParam(){
|
||||||
|
EEPROM.put(EEP_START_ADDR, parameters); // copy Parameters so "EEPROM"-section in RAM
|
||||||
|
EEPROM.commit(); // write "EEPROM"-section to flash
|
||||||
|
}
|
||||||
|
|
||||||
void Treppe::set_idle_prozent(const int prozent)
|
void Treppe::set_idle_prozent(const int prozent)
|
||||||
{
|
{
|
||||||
// future use: parameters.idle_max_pwm
|
// future use: parameters.idle_max_pwm
|
||||||
uint16_t new_pwm = parameters.active_pwm * prozent / 100;
|
uint16_t new_pwm = parameters.active_pwm * prozent / 100;
|
||||||
set_idle_pwm_max(new_pwm);
|
set_idle_pwm_max(new_pwm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::set_idle_pwm_max(const uint16_t new_pwm)
|
void Treppe::set_idle_pwm_max(const uint16_t new_pwm)
|
||||||
{
|
{
|
||||||
// future use: parameters.idle_max_pwm
|
// future use: parameters.idle_max_pwm
|
||||||
@ -335,15 +341,18 @@ void Treppe::set_idle_pwm_max(const uint16_t new_pwm)
|
|||||||
|
|
||||||
Serial.printf("Treppe: idle_pwm_soll=%d\n", idle_pwm_soll);
|
Serial.printf("Treppe: idle_pwm_soll=%d\n", idle_pwm_soll);
|
||||||
fsm_pend.ldr_changed = true;
|
fsm_pend.ldr_changed = true;
|
||||||
|
//saveParam(); //uncomment if idle_pwm_max is used
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::set_active_pwm(uint16_t _active_pwm)
|
void Treppe::set_active_pwm(uint16_t _active_pwm)
|
||||||
{
|
{
|
||||||
parameters.active_pwm = _active_pwm;
|
parameters.active_pwm = _active_pwm;
|
||||||
Serial.printf("Treppe: active_pwm=%d\n", parameters.active_pwm);
|
Serial.printf("Treppe: active_pwm=%d\n", parameters.active_pwm);
|
||||||
|
saveParam();
|
||||||
}
|
}
|
||||||
void Treppe::set_time_per_stair(uint16_t _time_per_stair)
|
void Treppe::set_time_per_stair(uint16_t _time_per_stair)
|
||||||
{
|
{
|
||||||
parameters.time_per_stair = _time_per_stair;
|
parameters.time_per_stair = _time_per_stair;
|
||||||
Serial.printf("Treppe: time_per_stair=%d\n", parameters.time_per_stair);
|
Serial.printf("Treppe: time_per_stair=%d\n", parameters.time_per_stair);
|
||||||
|
saveParam();
|
||||||
}
|
}
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "FSMTreppe3/FSMTreppe3.h"
|
#include "FSMTreppe3/FSMTreppe3.h"
|
||||||
#include "PCA9685.h"
|
#include "PCA9685.h"
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
// #define LDRDEBUG // comment in to override LDR measurement
|
// #define LDRDEBUG // comment in to override LDR measurement
|
||||||
#define LDR_HYS 1 // Hysteresis for switching off FSM [lux]
|
#define LDR_HYS 1 // Hysteresis for switching off FSM [lux]
|
||||||
@ -13,6 +14,8 @@
|
|||||||
|
|
||||||
#define INT_TIME 20 // interrupt intervall [ms]
|
#define INT_TIME 20 // interrupt intervall [ms]
|
||||||
|
|
||||||
|
#define EEP_START_ADDR 100 // define Start Address for "EEPROM" storage -> depends on size of "wifi_data"!
|
||||||
|
|
||||||
class Treppe {
|
class Treppe {
|
||||||
private:
|
private:
|
||||||
const uint8_t stufen;
|
const uint8_t stufen;
|
||||||
@ -104,6 +107,7 @@ public:
|
|||||||
void task(); // call periodically
|
void task(); // call periodically
|
||||||
|
|
||||||
// Parameter section
|
// Parameter section
|
||||||
|
void saveParam();
|
||||||
void set_idle_prozent(int prozent);
|
void set_idle_prozent(int prozent);
|
||||||
void set_idle_pwm_max(const uint16_t new_pwm);
|
void set_idle_pwm_max(const uint16_t new_pwm);
|
||||||
void set_active_pwm(uint16_t _active_pwm);
|
void set_active_pwm(uint16_t _active_pwm);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user