Browse Source

merge conflicts

tags/v1.0.0
Simon Schmidt 3 years ago
parent
commit
e47cae30a8
2 changed files with 21 additions and 1 deletions
  1. 17
    1
      lib/treppe/treppe.cpp
  2. 4
    0
      lib/treppe/treppe.h

+ 17
- 1
lib/treppe/treppe.cpp View File

@@ -281,6 +281,10 @@ void Treppe::setup() {
pwmController.setPWMFrequency(100);
// pwmController.setAllChannelsPWM(idle_pwm);

// WARNING: before getting Parameters of Flash, make sure plausible parameters
// are written in flash!
EEPROM.get(EEP_START_ADDR, parameters); // get Parameters of flash

pinMode(13, OUTPUT);
pinMode(0, OUTPUT);
digitalWrite(13, HIGH);
@@ -294,6 +298,11 @@ void Treppe::setup() {

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_pwm_max(const uint16_t value,
const vorgabe_typ_t vorgabe_typ) {
@@ -306,6 +315,7 @@ void Treppe::set_idle_pwm_max(const uint16_t value,
if (parameters.idle_pwm_max > parameters.active_pwm) {
parameters.idle_pwm_max = parameters.active_pwm;
}
saveParam();

Serial.printf("Treppe: parameters.idle_pwm_max=%d\n",
parameters.idle_pwm_max);
@@ -323,6 +333,7 @@ void Treppe::set_active_pwm(const uint16_t value,
if (parameters.active_pwm > 4095) {
parameters.idle_pwm_max = 4095;
}
saveParam();

Serial.printf("Treppe: parameters.active_pwm=%d\n", parameters.active_pwm);
}
@@ -331,6 +342,8 @@ void Treppe::set_time_ldr(const uint16_t value) {
parameters.time_ldr = value;
if (parameters.time_ldr > TIME_MS_MAX)
parameters.time_ldr = TIME_MS_MAX;
saveParam();

Serial.printf("Treppe: time_ldr=%d\n", parameters.time_ldr);
}

@@ -338,6 +351,8 @@ void Treppe::set_time_per_stair(const uint16_t value) {
parameters.time_per_stair = value;
if (parameters.time_per_stair > TIME_MS_MAX)
parameters.time_per_stair = TIME_MS_MAX;
saveParam();

Serial.printf("Treppe: time_per_stair=%d\n", parameters.time_per_stair);
}

@@ -349,6 +364,7 @@ void Treppe::set_ldr_schwelle(const uint16_t value,
} else if (vorgabe_typ == VORGABE_12BIT) {
// parameters.ldr_schwelle = value;
}
saveParam();

Serial.printf("Treppe: ldr_schwelle=%d\n", parameters.ldr_schwelle);
}
}

+ 4
- 0
lib/treppe/treppe.h View File

@@ -3,6 +3,7 @@

#include "FSMTreppe3/FSMTreppe3.h"
#include "PCA9685.h"
#include <EEPROM.h>

// #define LDRDEBUG // comment in to override LDR measurement
#define LDR_HYS 1 // Hysteresis for switching off FSM [lux]
@@ -16,6 +17,8 @@

enum vorgabe_typ_t { VORGABE_PROZENT = 0, VORGABE_12BIT = 1 };

#define EEP_START_ADDR 100 // define Start Address for "EEPROM" storage -> depends on size of "wifi_data"!

class Treppe {
private:
const uint8_t stufen;
@@ -95,6 +98,7 @@ public:
void task(); // call periodically

// Parameter section
void saveParam();
void set_idle_pwm_max(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
void set_active_pwm(const uint16_t value, const vorgabe_typ_t vorgabe_typ);

Loading…
Cancel
Save