|
|
|
|
|
|
|
|
#include "treppe.h" |
|
|
#include "treppe.h" |
|
|
|
|
|
// #define DEBUG_TIMING |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
- dimmt stufe (0 - 15, PCA9685 outputs) mit linearen ticks |
|
|
- dimmt stufe (0 - 15, PCA9685 outputs) mit linearen ticks |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Treppe::task() |
|
|
void Treppe::task() |
|
|
{ |
|
|
{ |
|
|
|
|
|
#ifdef DEBUG_TIMING |
|
|
uint32_t m=micros(); |
|
|
uint32_t m=micros(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
fsm_inputs.ldr_schwelle = check_ldr(); |
|
|
fsm_inputs.ldr_schwelle = check_ldr(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_TIMING |
|
|
Serial.print("1:"); |
|
|
Serial.print("1:"); |
|
|
Serial.println(micros()-m); |
|
|
Serial.println(micros()-m); |
|
|
m=micros(); |
|
|
m=micros(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
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 = anim_beendet; |
|
|
fsm_inputs.anim_beendet = anim_beendet; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_TIMING |
|
|
Serial.print("2:"); |
|
|
Serial.print("2:"); |
|
|
Serial.println(micros()-m); |
|
|
Serial.println(micros()-m); |
|
|
|
|
|
|
|
|
m=micros(); |
|
|
m=micros(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
FSMTreppe_Obj.setExternalInputs(&fsm_inputs); |
|
|
FSMTreppe_Obj.setExternalInputs(&fsm_inputs); |
|
|
FSMTreppe_Obj.step(); |
|
|
FSMTreppe_Obj.step(); |
|
|
fsm_outputs = FSMTreppe_Obj.getExternalOutputs(); |
|
|
fsm_outputs = FSMTreppe_Obj.getExternalOutputs(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_TIMING |
|
|
Serial.print("3:"); |
|
|
Serial.print("3:"); |
|
|
Serial.println(micros()-m); |
|
|
Serial.println(micros()-m); |
|
|
|
|
|
|
|
|
m=micros(); |
|
|
m=micros(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
print_state_on_change(); |
|
|
print_state_on_change(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_TIMING |
|
|
Serial.print("4:"); |
|
|
Serial.print("4:"); |
|
|
Serial.println(micros()-m); |
|
|
Serial.println(micros()-m); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m=micros(); |
|
|
m=micros(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if( fsm_outputs.status == ST_AUFDIMMEN_HOCH || |
|
|
if( fsm_outputs.status == ST_AUFDIMMEN_HOCH || |
|
|
fsm_outputs.status == ST_ABDIMMEN_HOCH || |
|
|
fsm_outputs.status == ST_ABDIMMEN_HOCH || |
|
|
fsm_outputs.status == ST_AUFDIMMEN_RUNTER || |
|
|
fsm_outputs.status == ST_AUFDIMMEN_RUNTER || |
|
|
|
|
|
|
|
|
else |
|
|
else |
|
|
anim_tick(); |
|
|
anim_tick(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_TIMING |
|
|
Serial.print("5:"); |
|
|
Serial.print("5:"); |
|
|
Serial.println(micros()-m); |
|
|
Serial.println(micros()-m); |
|
|
|
|
|
m=micros(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m=micros(); |
|
|
|
|
|
// else if (fsm_outputs.status == ST_DIMMEN_LDR) { |
|
|
// else if (fsm_outputs.status == ST_DIMMEN_LDR) { |
|
|
// if(anim_beendet) { |
|
|
// if(anim_beendet) { |
|
|
// berechne_dimmer(); |
|
|
// berechne_dimmer(); |
|
|
|
|
|
|
|
|
// } |
|
|
// } |
|
|
// anim_beendet = dimm_treppe(); |
|
|
// anim_beendet = dimm_treppe(); |
|
|
// } |
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_TIMING |
|
|
Serial.print("6:"); |
|
|
Serial.print("6:"); |
|
|
Serial.println(micros()-m); |
|
|
Serial.println(micros()-m); |
|
|
|
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Treppe::berechne_dimmer() |
|
|
void Treppe::berechne_dimmer() |