Read temperature command works

This commit is contained in:
Sebastian H. Gabrielli 2024-04-24 13:40:45 +02:00
parent 1eaeeef9a0
commit 822845cc7a

View File

@ -138,7 +138,32 @@ uint8_t route_command(int pos) {
case READ_CONFIG: case READ_CONFIG:
return READ_CONFIG; return READ_CONFIG;
case READ_VOLTAGE: 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: case READ_TERMPERATURE:
{ {
uint16_t v_therm = thermistor_voltage_read(); uint16_t v_therm = thermistor_voltage_read();