Correctly scale analog reading per issue #4794
This commit is contained in:
parent
eefba16644
commit
e9b9f0b13f
@ -204,8 +204,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||
uint16_t value = (uint16_t)HAL_ADC_GetValue(&AdcHandle);
|
||||
HAL_ADC_Stop(&AdcHandle);
|
||||
|
||||
// // Shift the value to be 16 bit.
|
||||
return value << 4;
|
||||
// Stretch 12-bit ADC reading to 16-bit range
|
||||
return (value << 4) | (value >> 8);
|
||||
}
|
||||
|
||||
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user