nah aio logic sucks
This commit is contained in:
52
src/aio.c
52
src/aio.c
@@ -11,10 +11,10 @@ static constexpr uint8_t max_curve_points = 7;
|
||||
|
||||
static struct aio_params_t params = {
|
||||
.fans = {
|
||||
.setpoint = 38.5f,
|
||||
.setpoint = 40.0f,
|
||||
.min_duty = 20,
|
||||
.max_duty = 100,
|
||||
.fan_stop = true,
|
||||
.max_duty = 80,
|
||||
.fan_stop = false,
|
||||
.ctrl = {
|
||||
.Ki = 0.1f,
|
||||
.Kd = 10.0f
|
||||
@@ -233,42 +233,18 @@ void aio_update(struct aio_t *aio) {
|
||||
SET_FANS_DUTY(aio->handle, fan_duty);
|
||||
|
||||
/* pump logic */
|
||||
switch (aio->pump_mode) {
|
||||
case QUIET:
|
||||
if (fan_duty > 40)
|
||||
aio->pump_counter++;
|
||||
else
|
||||
aio->pump_counter = 0;
|
||||
static int16_t counter = 0;
|
||||
if (fan_duty > (float)params.fans.max_duty * 0.75f && counter < 300)
|
||||
counter++;
|
||||
if (fan_duty < (float)params.fans.min_duty * 1.33f && counter > 0)
|
||||
counter--;
|
||||
|
||||
if (aio->pump_counter > 60)
|
||||
aio_set_pump_mode(aio->handle, BALANCED);
|
||||
break;
|
||||
|
||||
case BALANCED:
|
||||
if (fan_duty > 65)
|
||||
aio->pump_counter++;
|
||||
else if (fan_duty < 35 && aio->pump_counter > 0)
|
||||
aio->pump_counter--;
|
||||
|
||||
if (aio->pump_counter > 120)
|
||||
aio_set_pump_mode(aio->handle, EXTREME);
|
||||
else if (aio->pump_counter == 0)
|
||||
aio_set_pump_mode(aio->handle, QUIET);
|
||||
break;
|
||||
|
||||
case EXTREME:
|
||||
if (fan_duty < 60 && aio->pump_counter > 0)
|
||||
aio->pump_counter--;
|
||||
|
||||
if (aio->pump_counter < 60)
|
||||
aio_set_pump_mode(aio->handle, BALANCED);
|
||||
break;
|
||||
|
||||
case UNKNOWN:
|
||||
default:
|
||||
aio_set_pump_mode(aio->handle, BALANCED);
|
||||
break;
|
||||
}
|
||||
if (counter > 280)
|
||||
aio_set_pump_mode(aio->handle, EXTREME);
|
||||
if (counter > 60)
|
||||
aio_set_pump_mode(aio->handle, BALANCED);
|
||||
if (counter == 0)
|
||||
aio_set_pump_mode(aio->handle, QUIET);
|
||||
// applog(LOG_DBG, "aio->pump_counter is %d", aio->pump_counter);
|
||||
|
||||
aio_usb_release(aio->handle);
|
||||
|
||||
Reference in New Issue
Block a user