From 1f70f2ead280813d4f39f9a9241f77e489de5500 Mon Sep 17 00:00:00 2001 From: drath Date: Fri, 14 Aug 2026 01:05:17 +0200 Subject: [PATCH] refactor enum, it was dumb --- include/aio.h | 8 ++++---- src/aio.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/aio.h b/include/aio.h index 380bede..2065adb 100644 --- a/include/aio.h +++ b/include/aio.h @@ -27,10 +27,10 @@ struct aio_params_t { }; enum aio_pump_mode_t { - QUIET, - BALANCED, - EXTREME, - UNKNOWN + AIO_PUMP_MODE_QUIET, + AIO_PUMP_MODE_BALANCED, + AIO_PUMP_MODE_EXTREME, + AIO_PUMP_MODE_UNKNOWN }; enum aio_color_mode_t : uint8_t { diff --git a/src/aio.c b/src/aio.c index caf7ecf..0daf8ca 100644 --- a/src/aio.c +++ b/src/aio.c @@ -76,7 +76,7 @@ static uint16_t aio_get_pump_speed(libusb_device_handle *dev) { static enum aio_pump_mode_t aio_get_pump_mode(libusb_device_handle *dev) { req[0] = 0x33; if (aio_post(dev, 1, 4) != 0) - return UNKNOWN; + return AIO_PUMP_MODE_UNKNOWN; return (enum aio_pump_mode_t)resp[3]; } @@ -113,7 +113,7 @@ static char *aio_get_firmware_version(libusb_device_handle *dev, char *buf) { } static void aio_set_pump_mode(libusb_device_handle *dev, const enum aio_pump_mode_t mode) { - static enum aio_pump_mode_t last_mode = UNKNOWN; + static enum aio_pump_mode_t last_mode = AIO_PUMP_MODE_UNKNOWN; if (mode == last_mode) return; applog(LOG_DBG, "setting pump to %u", mode); @@ -200,7 +200,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, AIO_PUMP_MODE_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); } @@ -236,11 +236,11 @@ void aio_update(struct aio_t *aio) { aio->pump_counter--; if (aio->pump_counter > 280) - aio_set_pump_mode(aio->handle, EXTREME); + aio_set_pump_mode(aio->handle, AIO_PUMP_MODE_EXTREME); if (aio->pump_counter > 60) - aio_set_pump_mode(aio->handle, BALANCED); + aio_set_pump_mode(aio->handle, AIO_PUMP_MODE_BALANCED); if (aio->pump_counter == 0) - aio_set_pump_mode(aio->handle, QUIET); + aio_set_pump_mode(aio->handle, AIO_PUMP_MODE_QUIET); aio_usb_release(aio->handle); } @@ -254,7 +254,7 @@ void aio_close(const struct aio_t *aio) { { .temp = 55, .duty = 100} }; - aio_set_pump_mode(aio->handle, BALANCED); + aio_set_pump_mode(aio->handle, AIO_PUMP_MODE_BALANCED); aio_set_fan_curve(aio->handle, fan_curve, sizeof(fan_curve) / sizeof(fan_curve[0])); libusb_attach_kernel_driver(aio->handle, 0); // reattach so liquidctl still works libusb_close(aio->handle);