Browse Source

somehow working, starting to refactor

tags/v1.0.0
Simon Schmidt 3 years ago
parent
commit
af40298378
2 changed files with 18 additions and 17 deletions
  1. 6
    9
      lib/treppe/treppe.cpp
  2. 12
    8
      lib/treppe/treppe.h

+ 6
- 9
lib/treppe/treppe.cpp View File

void Treppe::task() void Treppe::task()
{ {
//Serial.printf("LDR: %f\n", ((float)analogRead(A0))/1023.*3.68); //Serial.printf("LDR: %f\n", ((float)analogRead(A0))/1023.*3.68);
fsm_inputs.ldr_schwelle = true; // <=== LDR implementierung !!


if (finish)
{
direction = switch_direction;
state = switch_state;
}

fsm_inputs.ldr_schwelle = true;
fsm_inputs.sensor_oben = read_sensor(SENSOR_OBEN); fsm_inputs.sensor_oben = read_sensor(SENSOR_OBEN);
fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN); fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN);
fsm_inputs.anim_beendet = static_cast<bool>(finish); fsm_inputs.anim_beendet = static_cast<bool>(finish);
if(finish) // flanke nach finished reicht ?
finish = false;


FSMTreppe_Obj.setExternalInputs(&fsm_inputs); FSMTreppe_Obj.setExternalInputs(&fsm_inputs);
FSMTreppe_Obj.step(); FSMTreppe_Obj.step();
direction = fsm_outputs.laufrichtung; direction = fsm_outputs.laufrichtung;
state = fsm_outputs.dimmrichtung; state = fsm_outputs.dimmrichtung;


if(fsm_outputs.status > ST_INAKTIV_LDR) {
ledsequence();
}
// setTick(ticks_treppe); // setTick(ticks_treppe);
// setAnAus(1); // setAnAus(1);
// setDirection(0); // setDirection(0);
// setState(0); // setState(0);

ledsequence();
} }


uint16_t Treppe::setIdle(uint16_t _idle_brightness) uint16_t Treppe::setIdle(uint16_t _idle_brightness)

+ 12
- 8
lib/treppe/treppe.h View File



class Treppe { class Treppe {
private: private:

uint8_t stairs; uint8_t stairs;
uint16_t time_per_stair = 300; // dimmtime per stair [ms] uint16_t time_per_stair = 300; // dimmtime per stair [ms]
uint16_t idle_brightness = 100;
uint16_t active_brightness = 300;
uint16_t idle_brightness = 0;
uint16_t active_brightness = 500;


uint8_t direction = 0; uint8_t direction = 0;
uint8_t switch_direction = 0; uint8_t switch_direction = 0;
FSMTreppeModelClass::ExtU_FSMTreppe_T fsm_inputs; FSMTreppeModelClass::ExtU_FSMTreppe_T fsm_inputs;
FSMTreppeModelClass::ExtY_FSMTreppe_T fsm_outputs; FSMTreppeModelClass::ExtY_FSMTreppe_T fsm_outputs;
void print_state_on_change(); void print_state_on_change();

const uint8_t FSMTreppe_IN_animation_down = 1U;
const uint8_t FSMTreppe_IN_animation_up = 2U;
const uint8_t FSMTreppe_IN_idle = 3U;

enum fsm_status_t {
ST_INAKTIV_LDR =0,
ST_RUHEZUSTAND =1,
ST_AUFDIMMEN_HOCH =2,
ST_WARTEN_HOCH =3,
ST_ABDIMMEN_HOCH =4,
ST_AUFDIMMEN_RUNTER =5,
ST_WARTEN_RUNTER =6,
ST_ABDIMMEN_RUNTER =7
};


uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval); uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval);
void ledsequence(); void ledsequence();

Loading…
Cancel
Save