Correctly scale analog reading per issue #4794

This commit is contained in:
Paint Your Dragon 2022-05-24 08:45:14 -07:00 committed by GitHub
parent 44b31b098e
commit 5ef1f2dd5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,8 +125,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
value = 0; value = 0;
} }
// Map value to from 14 to 16 bits // Stretch 14-bit ADC reading to 16-bit range
return value << 2; return (value << 2) | (value >> 12);
} }
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) {