Correctly scale analog reading per issue #4794

This commit is contained in:
Paint Your Dragon 2022-05-24 08:42:00 -07:00 committed by GitHub
parent eefba16644
commit e9b9f0b13f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {