Skip to content

Commit c3f5819

Browse files
Correctly scale analog reading per issue #4794
1 parent 5ef1f2d commit c3f5819

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/raspberrypi/common-hal/analogio/AnalogIn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
6565
adc_select_input(self->pin->number - ADC_FIRST_PIN_NUMBER);
6666
uint16_t value = adc_read();
6767

68-
// Map value to from 12 to 16 bits
69-
return value << 4;
68+
// Stretch 12-bit ADC reading to 16-bit range
69+
return (value << 4) | (value >> 8);
7070
}
7171

7272
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {

0 commit comments

Comments
 (0)