neater temp setting

This commit is contained in:
2026-05-25 13:41:24 +00:00
parent a28da52f8a
commit 920600b294
3 changed files with 13 additions and 7 deletions

View File

@@ -16,11 +16,13 @@ struct aio_t{
libusb_device_handle* handle;
enum aio_pump_mode_t pump_mode;
float water_temp;
float t_q;
float t_b;
uint16_t pump_speed;
uint16_t fan_speed[2];
};
void aio_detect(struct aio_t *aio);
void aio_detect(struct aio_t *aio, float t_quiet, float t_balanced);
void aio_update(struct aio_t *aio);
void aio_close(const struct aio_t *aio);

View File

@@ -65,7 +65,7 @@ static void aio_set_pump_mode(libusb_device_handle* dev, const enum aio_pump_mod
POST_AND_GET_RESP2(0x32, mode, 6);
}
void aio_detect(struct aio_t *aio) {
void aio_detect(struct aio_t *aio, const float t_quiet, const float t_balanced) {
libusb_init(NULL);
aio->handle = libusb_open_device_with_vid_pid(NULL, AIO_USB_VID, AIO_USB_PID);
if (aio->handle == NULL) {
@@ -73,6 +73,9 @@ void aio_detect(struct aio_t *aio) {
return;
}
aio->t_q = t_quiet;
aio->t_b = t_balanced;
/* detaches other software that might take the device? */
if (libusb_kernel_driver_active(aio->handle, 0))
libusb_detach_kernel_driver(aio->handle, 0);
@@ -80,7 +83,7 @@ void aio_detect(struct aio_t *aio) {
aio_usb_claim(aio->handle);
aio_set_pump_mode(aio->handle, QUIET); // needed for init ig?
aio_usb_release(aio->handle);
applog(LOG_INF, "found Corsair AIO device at %04x:%04x, fw %s", AIO_USB_VID, AIO_USB_PID, aio_get_firmware_version(aio->handle, (char[16]){0}));
applog(LOG_INF, "found Corsair AIO device at %04x:%04x, fw ver: %s, B mode at %.1fC, Q mode at %.1fC", AIO_USB_VID, AIO_USB_PID, aio_get_firmware_version(aio->handle, (char[16]){0}), aio->t_b, aio->t_q);
}
void aio_update(struct aio_t *aio) {
@@ -94,10 +97,10 @@ void aio_update(struct aio_t *aio) {
aio->pump_mode = aio_get_pump_mode(aio->handle);
aio_get_fan_speed(aio->handle, aio->fan_speed);
if (aio->water_temp > 36.0f && aio->pump_mode != BALANCED)
if (aio->water_temp > aio->t_b && aio->pump_mode != BALANCED)
aio_set_pump_mode(aio->handle, BALANCED);
if (aio->water_temp < 34.0f && aio->pump_mode != QUIET)
if (aio->water_temp < aio->t_q && aio->pump_mode != QUIET)
aio_set_pump_mode(aio->handle, QUIET);
aio_usb_release(aio->handle);

View File

@@ -54,7 +54,7 @@ static void *sensors_thread(void *arg) {
cpu_detect(&sensors->cpu, cpu_pcidev);
gpu_detect(&sensors->gpu, gpu_pcidev);
sys_detect(&sensors->sys, "nct6775.656");
aio_detect(&sensors->aio);
aio_detect(&sensors->aio, 34.0f, 36.0f);
/* main sensor loop */
applog(LOG_START, "reached sensors main loop");
@@ -147,7 +147,8 @@ static void *display_thread(void *arg) {
lcd_writef(&lcd, 0, 2, "%.0fW", sensors->cpu.ptotal);
lcd_writef(&lcd, 5, 2, "%dR", avg_fan_speed);
lcd_writef(&lcd, 12, 2, "%c%s %c%s", 3, P_BYTES(sensors->net.upload, 1), 4, P_BYTES(sensors->net.download, 1));
lcd_writef(&lcd, 12, 2, "%5s%c", P_BYTES(sensors->net.upload, 1), 3);
lcd_writef(&lcd, 19, 2, "%c%s", 4, P_BYTES(sensors->net.upload, 1));
lcd_writef(&lcd, 26, 2, "%4dR", sensors->gpu.fan_speed);
lcd_writef(&lcd, 32, 2, "%3d/%3dW", sensors->gpu.power_avg, sensors->gpu.power_cap);