Change 12- to 16-bit scaling to match other ports

Result is identical, implementation just resembles other ports instead of being all 1337 about it.
This commit is contained in:
Paint Your Dragon 2022-05-24 08:49:05 -07:00 committed by GitHub
parent c3f58193ca
commit 92fa02effa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,8 +81,10 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
}
// Stretch 12-bit ADC reading to 16 bits via 24-bit interim result
return (ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP) * 0x1001) >> 8;
uint16_t value = ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP);
// 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) {