Skip to content

Commit 8a1dbe4

Browse files
committed
codal_app/microbithal: Make display.get_pixel return a value in 0-9.
Fixes #75. Signed-off-by: Damien George <damien@micropython.org>
1 parent 64c722c commit 8a1dbe4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/codal_app/microbithal.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,12 @@ void microbit_hal_display_clear(void) {
284284
}
285285

286286
int microbit_hal_display_get_pixel(int x, int y) {
287-
return uBit.display.image.getPixelValue(x, y);
287+
uint32_t pixel = uBit.display.image.getPixelValue(x, y);
288+
if (pixel == 255) {
289+
return 9;
290+
} else {
291+
return 32 - __builtin_clz(pixel);
292+
}
288293
}
289294

290295
void microbit_hal_display_set_pixel(int x, int y, int bright) {

0 commit comments

Comments
 (0)