From cb2e1564ec96ecea4ec08f332542415ca5a47a31 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 2 Nov 2021 22:01:42 +0100 Subject: framebuffer: add OutputStream support with pixelfont --- include/object/framebuffer.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include/object') diff --git a/include/object/framebuffer.h b/include/object/framebuffer.h index 6eac7e0..a76a24a 100644 --- a/include/object/framebuffer.h +++ b/include/object/framebuffer.h @@ -1,11 +1,20 @@ #pragma once +#include "object/outputstream.h" -class Framebuffer +typedef const unsigned char* glyph_t; + +class Framebuffer : public OutputStream { + private: + Framebuffer(Framebuffer& copy); + const glyph_t *font; + unsigned int fontX, fontY; + unsigned char scale; + public: unsigned char *data; - Framebuffer(unsigned char *data) : data(data) {} + Framebuffer(unsigned char *data) : font(0), fontX(0), fontY(0), scale(1), data(data) {} constexpr static unsigned int const width = CONFIG_framebuffer_width; constexpr static unsigned int const height = CONFIG_framebuffer_height; @@ -13,9 +22,9 @@ class Framebuffer void clear(); 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); - - private: - Framebuffer(Framebuffer& copy); + void setFont(const glyph_t *font) { this->font = font; } + void setPos(unsigned int newX, unsigned int newY) { fontX = newX; fontY = newY; } + virtual void put(char c) override; }; extern Framebuffer fb; -- cgit v1.2.3