From e816a7d8ee9c4ff1a2ed756cb7ed91619079f9e2 Mon Sep 17 00:00:00 2001 From: Drath Date: Wed, 22 Jul 2026 00:01:22 +0200 Subject: [PATCH] fixed water temp bug? --- src/aio.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/aio.c b/src/aio.c index 18e4e72..097604a 100644 --- a/src/aio.c +++ b/src/aio.c @@ -7,7 +7,6 @@ static constexpr uint16_t usb_timeout = 250; static constexpr uint8_t buf_size = 32; // needs 32 bc of overflow issue on these aios? - static constexpr uint8_t max_curve_points = 7; static struct aio_params_t params = { @@ -66,11 +65,16 @@ static void aio_post(libusb_device_handle *dev, uint8_t *req, const int req_len, } static float aio_get_water_temp(libusb_device_handle *dev) { - static float last_read; + static float last_read = 36.6f; // sane init value so it doenst ramp the fan up POST_AND_GET_RESP(0xa9, 6); const float temp = (float)resp[3] + (float)resp[4] / 10.0f; - if (temp > 10.0f && temp < 65.0f) - last_read = temp; + + if (temp > 10.0f && temp < 65.0f) { + constexpr float max_change = 0.5f; // 0.5C change per refresh cycle + const float delta = temp - last_read; + last_read += fmaxf(fminf(delta, max_change), -max_change); + } + return last_read; } @@ -199,7 +203,7 @@ void aio_detect(struct aio_t *aio) { aio_usb_claim(aio->handle); applog(LOG_INF, "found Corsair AIO device at %04x:%04x, fw ver: %s. Set point is %.1fC, fan stop %s", AIO_USB_VID, AIO_USB_PID, aio_get_firmware_version(aio->handle, (char[16]){0}), (double)params.fans.setpoint, params.fans.fan_stop ? "ENABLED" : "DISABLED"); - aio_set_pump_mode(aio->handle, QUIET); // needed for init ig? + aio_set_pump_mode(aio->handle, QUIET); // needed for init ig? aio_set_color(aio->handle, AIO_COLOR_FIXED, 0, nullptr, 0); // so it doenst complain the func is unused aio_usb_release(aio->handle); } @@ -225,7 +229,7 @@ void aio_update(struct aio_t *aio) { fan_duty += error * params.fans.ctrl.Ki + slope * params.fans.ctrl.Kd; fan_duty = clamp(fan_duty, params.fans.min_duty, params.fans.max_duty); - // applog(LOG_DBG, "Fan duty %.3f, error %.4f, slope %.4f", (double)fan_duty, (double)error * (double)params.fans.ctrl.Ki, (double)slope * (double)params.fans.ctrl.Kd); + applog(LOG_DBG, "Fan duty %.3f, error %.4f, slope %.4f", (double)fan_duty, (double)error * (double)params.fans.ctrl.Ki, (double)slope * (double)params.fans.ctrl.Kd); SET_FANS_DUTY(aio->handle, fan_duty); /* pump logic */