← index #2572PR #2383
Off-topic · high · value 1.281
QUERY · ISSUE

extmod/modframebuf.c framebuf1_text() does not clear pixels

openby peterhinchopened 2016-10-29updated 2016-11-11

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.

CANDIDATE · PULL REQUEST

extmod/framebuf: Add the xstep!=0 case to scroll()

closedby deshipuopened 2016-09-02updated 2016-09-05

Adds horizontal scrolling. Right now, I'm just leaving the margins
created by the scrolling as they were -- so they will repeat the
edge of the framebuf. This is fast, and the user can always fill
the margins with a fill_rect call.

There are two other alternatives:

  • we can clear them ourselves, like with vertical scroll (perhaps we
    want to have an extra argument specifying the color?)
  • we can wrap around -- this is a bit tricky, would require to either
    do the scroll pixel by pixel, or create a buffer.

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