|
|
|
@ -22,6 +22,7 @@ static void invalidate_temps(); |
|
|
|
|
|
|
|
|
|
void settings_blind_time_set(uint16_t blind_time) |
|
|
|
|
{ |
|
|
|
|
// if the blind is surely at the end
|
|
|
|
|
bool nadoraz = (gState.blind_position >= gSettings.blind_time) || (gState.blind_position >= blind_time); |
|
|
|
|
|
|
|
|
|
gSettings.blind_time = blind_time; |
|
|
|
@ -76,6 +77,18 @@ void fancontrol_init() |
|
|
|
|
xTaskCreate(fanctltask, "fc", FCTL_TASK_STACK, NULL, FCTL_TASK_PRIO, NULL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const char * vent_mode_labels[] = { |
|
|
|
|
[VENT_MODE_OFF] = "OFF", |
|
|
|
|
[VENT_MODE_FREE] = "FREE", |
|
|
|
|
[VENT_MODE_OUT] = "OUT", |
|
|
|
|
[VENT_MODE_IN] = "IN", |
|
|
|
|
[VENT_MODE_RECUP] = "RECUP", |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const char * recup_mode_labels[] = { |
|
|
|
|
[RECUP_MODE_TIME] = "TIME", |
|
|
|
|
[RECUP_MODE_TEMP] = "TEMP", |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static void timerCallback() |
|
|
|
|
{ |
|
|
|
@ -128,7 +141,7 @@ static void timerCallback() |
|
|
|
|
if (gState.blind_position >= gSettings.blind_time) { |
|
|
|
|
act_motor_power_set(gState.set_power); |
|
|
|
|
} |
|
|
|
|
if (gState.t_aggr_cnt > UNIDIR_T_MEAS_PERIOD) { |
|
|
|
|
if (gState.ramp >= gSettings.ramp_time * 2) { |
|
|
|
|
end_temp_meas = true; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -138,7 +151,7 @@ static void timerCallback() |
|
|
|
|
if (gState.blind_position >= gSettings.blind_time) { |
|
|
|
|
act_motor_power_set(gState.set_power); |
|
|
|
|
} |
|
|
|
|
if (gState.t_aggr_cnt > UNIDIR_T_MEAS_PERIOD) { |
|
|
|
|
if (gState.ramp >= gSettings.ramp_time * 2) { |
|
|
|
|
end_temp_meas = true; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -163,7 +176,7 @@ static void timerCallback() |
|
|
|
|
const int16_t ideal_delta = gState.t_indoor - gState.t_outdoor; |
|
|
|
|
int16_t stop_delta = ((int32_t) ideal_delta |
|
|
|
|
* (int32_t) (100 - gSettings.recup_factor)) / 100; |
|
|
|
|
int16_t delta; |
|
|
|
|
int16_t delta = 0; |
|
|
|
|
bool allow_temp_switch = false; |
|
|
|
|
|
|
|
|
|
if (gState.real_direction == MOTOR_DIR_OUT) { |
|
|
|
@ -179,6 +192,8 @@ static void timerCallback() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ESP_LOGI(TAG, "Delta now %d, max %d, stop %d (RF %d%%), allow_switch %d Cx10", delta, ideal_delta, stop_delta, gSettings.recup_factor, allow_temp_switch); |
|
|
|
|
|
|
|
|
|
if (allow_temp_switch) { |
|
|
|
|
if (gSettings.summer_mode) { |
|
|
|
|
if (ideal_delta < 0) { |
|
|
|
@ -227,33 +242,6 @@ static void timerCallback() |
|
|
|
|
gState.instantaneous_vent_mode = gState.effective_vent_mode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (end_temp_meas) { |
|
|
|
|
if (gState.t_aggr_cnt > 0) { |
|
|
|
|
int16_t t1 = (int16_t) (gState.t1_aggr / (int32_t) gState.t_aggr_cnt); |
|
|
|
|
int16_t t2 = (int16_t) (gState.t2_aggr / (int32_t) gState.t_aggr_cnt); |
|
|
|
|
switch (gState.real_direction) { |
|
|
|
|
case MOTOR_DIR_IN: |
|
|
|
|
gState.t_outdoor = t2; |
|
|
|
|
gState.t_inflow = t1; |
|
|
|
|
gState.valid_t_outdoor = gState.valid_t_inflow = true; |
|
|
|
|
if (gState.effective_vent_mode == VENT_MODE_IN) { |
|
|
|
|
gState.valid_t_indoor = gState.valid_t_exhaust = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MOTOR_DIR_OUT: |
|
|
|
|
gState.t_indoor = t1; |
|
|
|
|
gState.t_exhaust = t2; |
|
|
|
|
gState.valid_t_indoor = gState.valid_t_exhaust = true; |
|
|
|
|
if (gState.effective_vent_mode == VENT_MODE_OUT) { |
|
|
|
|
gState.valid_t_outdoor = gState.valid_t_inflow = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
gState.t1_aggr = gState.t2_aggr = 0; |
|
|
|
|
gState.t_aggr_cnt = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Measure temperatures
|
|
|
|
|
int16_t t1 = act_temp1(); |
|
|
|
|
int16_t t2 = act_temp2(); |
|
|
|
@ -263,27 +251,33 @@ static void timerCallback() |
|
|
|
|
|
|
|
|
|
gState.valid_t_actual_in = gState.valid_t_actual_out = tempSensorsOk; |
|
|
|
|
|
|
|
|
|
if (gState.effective_vent_mode == VENT_MODE_IN |
|
|
|
|
|| gState.effective_vent_mode == VENT_MODE_OUT |
|
|
|
|
|| gState.effective_vent_mode == VENT_MODE_RECUP) { |
|
|
|
|
|
|
|
|
|
if (gAct.dir == gState.real_direction |
|
|
|
|
&& gState.ramp >= gSettings.ramp_time) { |
|
|
|
|
gState.t1_aggr += t1; |
|
|
|
|
gState.t2_aggr += t2; |
|
|
|
|
gState.t_aggr_cnt++; |
|
|
|
|
if (end_temp_meas) { |
|
|
|
|
switch (gState.real_direction) { |
|
|
|
|
case MOTOR_DIR_IN: |
|
|
|
|
gState.t_outdoor = gState.t_actual_out; |
|
|
|
|
gState.t_inflow = gState.t_actual_in; |
|
|
|
|
gState.valid_t_outdoor = gState.valid_t_inflow = true; |
|
|
|
|
if (gState.effective_vent_mode == VENT_MODE_IN) { |
|
|
|
|
gState.valid_t_indoor = gState.valid_t_exhaust = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MOTOR_DIR_OUT: |
|
|
|
|
gState.t_indoor = gState.t_actual_in; |
|
|
|
|
gState.t_exhaust = gState.t_actual_out; |
|
|
|
|
gState.valid_t_indoor = gState.valid_t_exhaust = true; |
|
|
|
|
if (gState.effective_vent_mode == VENT_MODE_OUT) { |
|
|
|
|
gState.valid_t_outdoor = gState.valid_t_inflow = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ESP_LOGI(TAG, |
|
|
|
|
"Mode %d (ef %d, inst %d), Dir %d (real %d), PW %d (ramp %d), Blind %d (ramp %d)", |
|
|
|
|
gState.set_vent_mode, gState.effective_vent_mode, gState.instantaneous_vent_mode, |
|
|
|
|
gAct.dir, gState.real_direction, |
|
|
|
|
gAct.power, gState.ramp, |
|
|
|
|
gAct.blind, gState.blind_position |
|
|
|
|
); |
|
|
|
|
ESP_LOGI(TAG, |
|
|
|
|
"Tin %d%s, Tout %d%s, T<- %d%s, T-> %d%s, T1 %d%s, T2 %d%s", |
|
|
|
|
"%s (ef %s, inst %s), rt %ds %d%%m, Tid %d%s, Tod %d%s, Tit %d%s, Teh %d%s, T1 %d%s, T2 %d%s Cx10", |
|
|
|
|
vent_mode_labels[gState.set_vent_mode], vent_mode_labels[gState.effective_vent_mode], vent_mode_labels[gState.instantaneous_vent_mode], |
|
|
|
|
gState.run_time, |
|
|
|
|
gAct.power, |
|
|
|
|
|
|
|
|
|
gState.t_indoor, |
|
|
|
|
gState.valid_t_indoor ? "" : "!", |
|
|
|
|
gState.t_outdoor, |
|
|
|
@ -308,7 +302,6 @@ void fan_set_vent_mode(enum ventilation_mode mode) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gState.set_vent_mode = mode; |
|
|
|
|
gState.t1_aggr = gState.t2_aggr = gState.t_aggr_cnt = 0; |
|
|
|
|
if (gState.set_power != 0 || mode == VENT_MODE_FREE) { |
|
|
|
|
gState.effective_vent_mode = mode; |
|
|
|
|
} else if (gState.set_power == 0) { |
|
|
|
|