diff --git a/main/fancontrol.c b/main/fancontrol.c index 76f0548..06b6cdb 100644 --- a/main/fancontrol.c +++ b/main/fancontrol.c @@ -96,18 +96,37 @@ static void timerCallback(TimerHandle_t xTimer) { act_blind_set(1); if (gState.blind_position >= gSettings.blind_time) { act_motor_power_set(gState.set_power); - } - // Stop condition - if (gState.run_time >= gSettings.recup_time) { - // zmena smeru - gState.run_time = 0; - act_motor_direction_set(1 - gAct.dir); + // Stop condition + if (gState.real_direction == gAct.dir) { + if (gState.run_time >= gSettings.recup_time) { + // zmena smeru + gState.run_time = 0; + act_motor_direction_set(1 - gAct.dir); + } + } } + break; } if (gAct.dir == gState.real_direction && gState.ramp >= gSettings.ramp_time) { // Measure temperatures + int16_t t1 = 200; + int16_t t2 = 200; // TODO + + gState.t_actual_1 = t1; + gState.t_actual_2 = t2; + + switch (gState.real_direction) { + case MOTOR_DIR_IN: + gState.t_outdoor = t2; + gState.t_intake = t1; + break; + case MOTOR_DIR_OUT: + gState.t_indoor = t1; + gState.t_exhaust = t2; + break; + } } } diff --git a/main/fancontrol.h b/main/fancontrol.h index 8f71499..c3b6dc1 100644 --- a/main/fancontrol.h +++ b/main/fancontrol.h @@ -44,6 +44,14 @@ struct FanControlState { * rezim ventilace */ enum ventilation_mode vent_mode; + + uint16_t t_indoor; + uint16_t t_outdoor; + uint16_t t_intake; + uint16_t t_exhaust; + + uint16_t t_actual_1; + uint16_t t_actual_2; }; extern struct FanControlState gState;