extmod/modframebuf.c framebuf1_text() does not clear pixels
This section of the code looks wrong:
if (vline_data & 1) { // only draw if pixel set
if (0 <= y && y < self->height) { // clip y
uint byte_pos = x0 + self->stride * ((uint)y >> 3);
if (col == 0) {
// clear pixel
self->buf[byte_pos] &= ~(1 << (y & 7));
} else {
// set pixel
self->buf[byte_pos] |= 1 << (y & 7);
}
}
If the pixel is not set, it should surely clear down the pixel in the framebuf as we don't know its prior contents. Further, if we happen to be drawing with col==0 to a part of the framebuf which is already zero, then nothing will be drawn, because in that circumstance the code never sets a pixel.
I hope I'm right on this observation from reviewing the code: I haven't had the opportunity to try it since my SSD1306 was DOA.
pixel() in extmod/modframebuf.c returning unexpected result
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?