Correctly scale analog reading per issue #4794

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

View File

@ -65,8 +65,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
adc_select_input(self->pin->number - ADC_FIRST_PIN_NUMBER);
uint16_t value = adc_read();
// Map value to from 12 to 16 bits
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) {