diff --git a/include/object/framebuffer.h b/include/object/framebuffer.h index a76a24a28164010ce6cda3f78060bb0918698f0f..bfbd215bdb2e94d29062ce25b16c7245cc808f48 100644 --- a/include/object/framebuffer.h +++ b/include/object/framebuffer.h @@ -20,6 +20,7 @@ class Framebuffer : public OutputStream constexpr static unsigned int const height = CONFIG_framebuffer_height; void clear(); + void scroll(); void fillBox(unsigned int x, unsigned int y, unsigned int w, unsigned int h); void drawAt(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *image); void setFont(const glyph_t *font) { this->font = font; } diff --git a/src/os/object/framebuffer.cc b/src/os/object/framebuffer.cc index f23cd84cf0f618bdcfce58d24a19d65f4f2c669f..e8b0ee057cf359521eaf5b2b8d447a87d77ee8b6 100644 --- a/src/os/object/framebuffer.cc +++ b/src/os/object/framebuffer.cc @@ -71,6 +71,19 @@ void Framebuffer::drawAt(unsigned int x, unsigned int y, unsigned int w, unsigne } } +void Framebuffer::scroll() +{ + for (unsigned int pos_x = 0; pos_x < width; pos_x++) { + for (unsigned int pos_y = 1; pos_y < height/8; pos_y++) { + data[pos_x * (height/8) + pos_y - 1] = data[pos_x * (height/8) + pos_y]; + } + data[pos_x * (height/8) + height/8 - 1] = 0; + } + if (fontY >= 8) { + fontY -= 8; + } +} + void Framebuffer::put(char c) { if (font == 0) { @@ -96,7 +109,7 @@ void Framebuffer::put(char c) put('\n'); } if (fontY >= height) { - return; + scroll(); } for (unsigned char i = 0; i < glyph_w; i++) { #ifdef MULTIPASS_ARCH_arduino_nano