diff --git a/flight/modules/System/systemmod.c b/flight/modules/System/systemmod.c index df9a110f3..3268f7d95 100644 --- a/flight/modules/System/systemmod.c +++ b/flight/modules/System/systemmod.c @@ -472,7 +472,7 @@ static void updateStats() idleCounterClear = 1; #if defined(PIOS_INCLUDE_ADC) && defined(PIOS_ADC_USE_TEMP_SENSOR) float temp_voltage = PIOS_ADC_PinGetVolt(PIOS_ADC_TEMPERATURE_PIN); - stats.CPUTemp = (temp_voltage - PIOS_ADC_STM32_TEMP_V25) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f; + stats.CPUTemp = PIOS_CONVERT_VOLT_TO_CPU_TEMP(temp_voltage);; #endif SystemStatsSet(&stats); } diff --git a/flight/targets/boards/coptercontrol/pios_board.h b/flight/targets/boards/coptercontrol/pios_board.h index 46a055da4..8987c4f36 100644 --- a/flight/targets/boards/coptercontrol/pios_board.h +++ b/flight/targets/boards/coptercontrol/pios_board.h @@ -218,6 +218,8 @@ extern uint32_t pios_com_hkosd_id; #define PIOS_ADC_TEMPERATURE_PIN 0 #define PIOS_ADC_STM32_TEMP_V25 1.43f /* V */ #define PIOS_ADC_STM32_TEMP_AVG_SLOPE 4.3f /* mV/C */ +#define PIOS_CONVERT_VOLT_TO_CPU_TEMP(x) ((PIOS_ADC_STM32_TEMP_V25 - x) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f) + // ------------------------ // PIOS_RCVR // See also pios_board.c diff --git a/flight/targets/boards/oplinkmini/pios_board.h b/flight/targets/boards/oplinkmini/pios_board.h index 6022cb747..2eda66945 100644 --- a/flight/targets/boards/oplinkmini/pios_board.h +++ b/flight/targets/boards/oplinkmini/pios_board.h @@ -238,6 +238,8 @@ extern uint32_t pios_ppm_out_id; #define PIOS_ADC_TEMPERATURE_PIN 0 #define PIOS_ADC_STM32_TEMP_V25 1.43f /* V */ #define PIOS_ADC_STM32_TEMP_AVG_SLOPE 4.3f /* mV/C */ +#define PIOS_CONVERT_VOLT_TO_CPU_TEMP(x) ((PIOS_ADC_STM32_TEMP_V25 - x) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f) + // ------------------------ // PIOS_RCVR // See also pios_board.c diff --git a/flight/targets/boards/osd/pios_board.h b/flight/targets/boards/osd/pios_board.h index e2c5d5ddb..5c58a789f 100644 --- a/flight/targets/boards/osd/pios_board.h +++ b/flight/targets/boards/osd/pios_board.h @@ -230,6 +230,7 @@ extern uint32_t pios_com_telem_usb_id; #define PIOS_ADC_TEMPERATURE_PIN 6 /* V */ #define PIOS_ADC_STM32_TEMP_V25 0.76f /* mV/C */ #define PIOS_ADC_STM32_TEMP_AVG_SLOPE 2.5f +#define PIOS_CONVERT_VOLT_TO_CPU_TEMP(x) ((x - PIOS_ADC_STM32_TEMP_V25) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f) // ***************************************************************** // USB diff --git a/flight/targets/boards/revolution/pios_board.h b/flight/targets/boards/revolution/pios_board.h index c5fea3d92..64a2cefbd 100644 --- a/flight/targets/boards/revolution/pios_board.h +++ b/flight/targets/boards/revolution/pios_board.h @@ -298,6 +298,7 @@ extern uint32_t pios_packet_handler; #define PIOS_ADC_TEMPERATURE_PIN 3 #define PIOS_ADC_STM32_TEMP_V25 0.76f /* V */ #define PIOS_ADC_STM32_TEMP_AVG_SLOPE 2.5f /* mV/C */ +#define PIOS_CONVERT_VOLT_TO_CPU_TEMP(x) ((x - PIOS_ADC_STM32_TEMP_V25) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f) // ------------------------- // USB diff --git a/flight/targets/boards/revoproto/pios_board.h b/flight/targets/boards/revoproto/pios_board.h index 6c9dd2a5b..66bb03073 100644 --- a/flight/targets/boards/revoproto/pios_board.h +++ b/flight/targets/boards/revoproto/pios_board.h @@ -260,6 +260,7 @@ extern uint32_t pios_com_hkosd_id; #define PIOS_ADC_TEMPERATURE_PIN 3 /* V */ #define PIOS_ADC_STM32_TEMP_V25 0.76f /* mV/C */ #define PIOS_ADC_STM32_TEMP_AVG_SLOPE 2.5f +#define PIOS_CONVERT_VOLT_TO_CPU_TEMP(x) ((x - PIOS_ADC_STM32_TEMP_V25) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f) // ------------------------- // USB