Correctly scale analog reading per issue #4794

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

View File

@ -123,8 +123,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
adc_sync_read_channel(&adc, self->channel, ((uint8_t *)&value), 2);
adc_sync_deinit(&adc);
// 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) {