|
|
@@ -132,10 +132,8 @@ void Treppe::rampe() |
|
|
|
} |
|
|
|
|
|
|
|
void Treppe::setup(){ |
|
|
|
Serial.printf("differenz_pwm_pro_tick %f\n", differenz_pwm_pro_tick); |
|
|
|
|
|
|
|
|
|
|
|
pwmController.resetDevices(); |
|
|
|
|
|
|
|
// Deactive PCA9685 Phase Balancer due to LED Flickering |
|
|
|
// https://github.com/NachtRaveVL/PCA9685-Arduino/issues/15 |
|
|
|
// see also lib/PCA9685-Arduin/PCA9685.h:204 |
|
|
@@ -145,27 +143,57 @@ void Treppe::setup(){ |
|
|
|
pwmController.setAllChannelsPWM(idle_brightness); |
|
|
|
|
|
|
|
pinMode(A0, INPUT); |
|
|
|
pinMode(SENSOR1, INPUT); |
|
|
|
pinMode(SENSOR2, INPUT); |
|
|
|
pinMode(SENSOR_OBEN, INPUT); |
|
|
|
pinMode(SENSOR_UNTEN, INPUT); |
|
|
|
pinMode(OE, OUTPUT); |
|
|
|
digitalWrite(OE, 0); |
|
|
|
|
|
|
|
Serial.printf("differenz_pwm_pro_tick %f\n", differenz_pwm_pro_tick); |
|
|
|
Serial.println("Hello from Treppe"); |
|
|
|
Serial.print("Treppe: initial parameters: stairs="); |
|
|
|
Serial.println(stairs); |
|
|
|
} |
|
|
|
|
|
|
|
void Treppe::task(){ |
|
|
|
FSMTreppe_Obj.step(); |
|
|
|
void Treppe::print_state_on_change() { |
|
|
|
static FSMTreppeModelClass::ExtU_FSMTreppe_T last_in; |
|
|
|
static FSMTreppeModelClass::ExtY_FSMTreppe_T last_out; |
|
|
|
if( |
|
|
|
fsm_inputs.anim_finished != last_in.anim_finished || |
|
|
|
fsm_inputs.sensor_oben != last_in.sensor_oben || |
|
|
|
fsm_inputs.sensor_unten != last_in.sensor_unten || |
|
|
|
fsm_outputs.anim_active != last_out.anim_active |
|
|
|
) { |
|
|
|
last_in.anim_finished = fsm_inputs.anim_finished; |
|
|
|
last_in.sensor_oben = fsm_inputs.sensor_oben; |
|
|
|
last_in.sensor_unten = fsm_inputs.sensor_unten; |
|
|
|
last_out.anim_active = fsm_outputs.anim_active; |
|
|
|
|
|
|
|
Serial.printf("FSM inputs: s_u: %d, s_o: %d, an_fin: %d =>", |
|
|
|
fsm_inputs.sensor_oben, fsm_inputs.sensor_unten, fsm_inputs.anim_finished); |
|
|
|
Serial.print(" step => "); |
|
|
|
Serial.printf("FSM outputs: an_act: %d\n", fsm_outputs.anim_active); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void Treppe::task(){ |
|
|
|
if(finish){ |
|
|
|
direction = switch_direction; |
|
|
|
state = switch_state; |
|
|
|
} |
|
|
|
static uint8_t last_sensor_state[2] = {0,0}; |
|
|
|
uint8_t current_sensor_state[2] = {0,0}; |
|
|
|
current_sensor_state[0] = digitalRead(SENSOR1); |
|
|
|
current_sensor_state[1] = digitalRead(SENSOR2); |
|
|
|
|
|
|
|
current_sensor_state[0] = digitalRead(SENSOR_OBEN); |
|
|
|
current_sensor_state[1] = digitalRead(SENSOR_UNTEN); |
|
|
|
|
|
|
|
fsm_inputs.sensor_oben = read_sensor(SENSOR_OBEN); |
|
|
|
fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN); |
|
|
|
fsm_inputs.anim_finished = static_cast<bool>(finish); |
|
|
|
|
|
|
|
FSMTreppe_Obj.setExternalInputs(&fsm_inputs); |
|
|
|
FSMTreppe_Obj.step(); |
|
|
|
fsm_outputs = FSMTreppe_Obj.getExternalOutputs(); |
|
|
|
print_state_on_change(); |
|
|
|
|
|
|
|
if(current_sensor_state[0] && !last_sensor_state[0] && state == 0){ |
|
|
|
setTick(0); |
|
|
|
setAnAus(1); |