Merge I2C command handler into main #18

Merged
sebgab merged 15 commits from output-fan-data-over-i2c into main 2024-04-30 08:37:29 +00:00
Showing only changes of commit 822845cc7a - Show all commits

View File

@ -138,7 +138,32 @@ uint8_t route_command(int pos) {
case READ_CONFIG:
return READ_CONFIG;
case READ_VOLTAGE:
return READ_VOLTAGE;
{
// Create a union to store the data
union {
int16_t v;
uint8_t bytes[2];
} voltage;
// Figure out which voltage source to read
switch (context.src_voltage) {
case SRC_INTERNAL:
voltage.v = internal_voltage_read();
break;
case SRC_EXTRNAL:
voltage.v = external_voltage_read();
break;
case SRC_THERMISTOR:
voltage.v = thermistor_voltage_read();
break;
default:
return 0xFF;
break;
}
// Send the data
return voltage.bytes[pos];
}
case READ_TERMPERATURE:
{
uint16_t v_therm = thermistor_voltage_read();