diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-11-02 22:01:42 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-11-02 22:01:42 +0100 |
commit | cb2e1564ec96ecea4ec08f332542415ca5a47a31 (patch) | |
tree | 2e3c2736c6652c8c11016ea0580f1866a0dc2e25 /src | |
parent | df860f2b0899779d3ca3b25d6da0e1dd06188818 (diff) |
framebuffer: add OutputStream support with pixelfont
Diffstat (limited to 'src')
-rw-r--r-- | src/app/pervasive-aurora-mb-test/main.cc | 19 | ||||
-rw-r--r-- | src/os/object/framebuffer.cc | 29 |
2 files changed, 41 insertions, 7 deletions
diff --git a/src/app/pervasive-aurora-mb-test/main.cc b/src/app/pervasive-aurora-mb-test/main.cc index 50c5ec2..8880442 100644 --- a/src/app/pervasive-aurora-mb-test/main.cc +++ b/src/app/pervasive-aurora-mb-test/main.cc @@ -8,6 +8,7 @@ #include "driver/stdout.h" #include "driver/pervasive_aurora_mb.h" #include "object/framebuffer.h" +#include "lib/pixelfont/pixeloperator.h" __attribute__ ((section(".text"))) unsigned char lynx[12 * 96] = { @@ -113,17 +114,11 @@ __attribute__ ((section(".text"))) unsigned char lynx[12 * 96] = { void loop(void) { static unsigned int i = 0; - fb.drawAt(i*20, i*20, 96, 96, lynx); - i = (i+1) % 6; - kout << "powerOn" << endl; + fb << "i = " << i++ << " " << endl; pervasiveAuroraMb.powerOn(); - kout << "initialize" << endl; pervasiveAuroraMb.initialize(); - kout << "sendImage" << endl; pervasiveAuroraMb.sendImage((unsigned char*)fb.data); - kout << "sendUpdate" << endl; pervasiveAuroraMb.sendUpdate(); - kout << "poweroff" << endl; pervasiveAuroraMb.powerOff(); } @@ -134,6 +129,16 @@ int main(void) spi.setup(); pervasiveAuroraMb.setup(); + fb.setFont(pixeloperator); + fb.clear(); + fb.drawAt(200, 300, 96, 96, lynx); + fb << "Hello, World!" << endl << endl;; + pervasiveAuroraMb.powerOn(); + pervasiveAuroraMb.initialize(); + pervasiveAuroraMb.sendImage((unsigned char*)fb.data); + pervasiveAuroraMb.sendUpdate(); + pervasiveAuroraMb.powerOff(); + arch.idle_loop(); return 0; diff --git a/src/os/object/framebuffer.cc b/src/os/object/framebuffer.cc index ad128dc..7b3fe0d 100644 --- a/src/os/object/framebuffer.cc +++ b/src/os/object/framebuffer.cc @@ -67,4 +67,33 @@ void Framebuffer::drawAt(unsigned int x, unsigned int y, unsigned int w, unsigne } } +void Framebuffer::put(char c) +{ + if (font == 0) { + return; + } + if (c == '\n') { + fontX = 0; + fontY += 8; + return; + } + if ((c < 32) || (c > 126)) { + c = '?'; + } + glyph_t glyph = font[c - 32]; + const unsigned char glyph_w = glyph[0]; + + if (fontX + glyph_w + 1 >= width) { + put('\n'); + } + if (fontY >= height) { + return; + } + for (unsigned char i = 0; i < glyph_w; i++) { + data[(height/8) * (fontX + i) + fontY/8] = glyph[i+1]; + } + data[(height/8) * (fontX + glyph_w + 1) + fontY/8] = 0; + fontX += glyph_w + 2; +} + Framebuffer fb(framebuffer); |