Correctly scale analog reading per issue #4794

This commit is contained in:
Paint Your Dragon 2022-05-24 08:44:09 -07:00 committed by GitHub
parent e9b9f0b13f
commit 44b31b098e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -81,8 +81,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
} }
// Shift the value to be 16 bit // Stretch 12-bit ADC reading to 16 bits via 24-bit interim result
return ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP) << 4; return (ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP) * 0x1001) >> 8;
} }
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) { float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {