← index #7081Issue #2897
Off-topic · high · value 3.035
QUERY · ISSUE

display.get_pixel unexpected output on microbit

openby marc0janssenopened 2021-03-29updated 2024-09-13
port-nrf

hi there,

The display.get_pixel method with a full bright pixel on the a microbit returns a "255" instead of a "9".
This is not conform the docs on internet. The method should have returned a "9" for a full pixel.

It seems the display.get_pixel method returns a value between 0-255 instead of 0-9.

from microbit import *
display.set_pixel(0, 0, 9)
display.scroll(str(display.get_pixel(0, 0)))

CANDIDATE · ISSUE

lcd160cr get_line() method produces unexpected bytearray offset

closedby peterhinchopened 2017-02-22updated 2017-05-17
import lcd160cr
buf = bytearray(20)
lcd = lcd160cr.LCD160CR('Y')
lcd.set_orient(lcd160cr.LANDSCAPE)
x = 5
y = 1
lcd.set_pixel(x, y, lcd.rgb(255,255,255))
lcd.set_pixel(x + 1, y, lcd.rgb(255,255,255))
lcd.get_line(x, y, buf)
print(buf)

Outcome

bytearray(b'\x0c\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

I tried various values of x and y, and both landscape and portrait modes: the result is always displaced by one byte. The contents of byte 0 seems to depend on orientation.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied