← index #7081Issue #2362
Related · high · value 1.690
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

pixel() in extmod/modframebuf.c returning unexpected result

closedby mcauseropened 2016-08-26updated 2016-08-29

framebuf.pixel() is returning results different to what is being set.

Given a simple 16x16 buffer.

>>> import framebuf
>>> width = 16
>>> height = 16
>>> pages = height // 8
>>> buffer = bytearray(pages * width)
>>> framebuf = framebuf.FrameBuffer1(buffer, width, height)

Set 3 pixels to black:

>>> framebuf.pixel(0,0,0)
>>> framebuf.pixel(0,1,1)
>>> framebuf.pixel(0,2,1)
>>> framebuf.pixel(0,3,1)

Then retrieve them:

>>> framebuf.pixel(0,0)
14
>>> framebuf.pixel(0,1)
7
>>> framebuf.pixel(0,2)
3
>>> framebuf.pixel(0,3)
1

Expected to see:

>>> framebuf.pixel(0,0)
0
>>> framebuf.pixel(0,1)
1
>>> framebuf.pixel(0,2)
1
>>> framebuf.pixel(0,3)
1

I can get the expected result if I AND them with 1:

>>> framebuf.pixel(0,0) & 1
0
>>> framebuf.pixel(0,1) & 1
1
>>> framebuf.pixel(0,2) & 1
1
>>> framebuf.pixel(0,3) & 1
1

Am I wrong in my expectation that col in pixel(0,1,col) and col = pixel(0,1) should match?
Is it useful for pixel() to return its adjacent bits?

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