summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/lib/pixelfont/pixeloperator.h207
-rw-r--r--include/object/framebuffer.h19
-rw-r--r--src/app/pervasive-aurora-mb-test/main.cc19
-rw-r--r--src/os/object/framebuffer.cc29
4 files changed, 262 insertions, 12 deletions
diff --git a/include/lib/pixelfont/pixeloperator.h b/include/lib/pixelfont/pixeloperator.h
new file mode 100644
index 0000000..8ca3030
--- /dev/null
+++ b/include/lib/pixelfont/pixeloperator.h
@@ -0,0 +1,207 @@
+#pragma once
+/*
+ * Pixel Operator Font
+ * <https://notabug.org/HarvettFox96/ttf-pixeloperator>
+ * <https://www.dafont.com/pixel-operator.font>
+ *
+ * Copyright 2018 Jayvee Enaguas
+ *
+ * SPDX-License-Identifier: CC0-1.0
+ */
+
+typedef const unsigned char glyph_line_t;
+typedef const unsigned char* glyph_t;
+
+glyph_line_t chr_032[] = {0x03,0x00,0x00,0x00}; // <space>
+glyph_line_t chr_033[] = {0x01,0x7D}; // !
+glyph_line_t chr_034[] = {0x04,0x30,0x40,0x30,0x40}; // "
+glyph_line_t chr_035[] = {0x06,0x12,0x3F,0x12,0x12,0x3F,0x12}; // #
+glyph_line_t chr_036[] = {0x05,0x12,0x2A,0x7F,0x2A,0x24}; // $
+glyph_line_t chr_037[] = {0x07,0x30,0x4A,0x34,0x08,0x16,0x29,0x06}; // %
+glyph_line_t chr_038[] = {0x05,0x36,0x49,0x49,0x49,0x27}; // &
+glyph_line_t chr_039[] = {0x01,0x70}; // '
+glyph_line_t chr_040[] = {0x03,0x1C,0x22,0x41}; // (
+glyph_line_t chr_041[] = {0x03,0x41,0x22,0x1C}; // )
+glyph_line_t chr_042[] = {0x05,0x28,0x10,0x7C,0x10,0x28}; // *
+glyph_line_t chr_043[] = {0x05,0x08,0x08,0x3E,0x08,0x08}; // +
+glyph_line_t chr_044[] = {0x02,0x01,0x02}; // ,
+glyph_line_t chr_045[] = {0x05,0x08,0x08,0x08,0x08,0x08}; // -
+glyph_line_t chr_046[] = {0x01,0x01}; // .
+glyph_line_t chr_047[] = {0x03,0x03,0x1C,0x60}; // /
+glyph_line_t chr_048[] = {0x05,0x3E,0x45,0x49,0x51,0x3E}; // 0
+glyph_line_t chr_049[] = {0x03,0x10,0x20,0x7F}; // 1
+glyph_line_t chr_050[] = {0x05,0x21,0x43,0x45,0x49,0x31}; // 2
+glyph_line_t chr_051[] = {0x05,0x22,0x41,0x49,0x49,0x36}; // 3
+glyph_line_t chr_052[] = {0x05,0x0C,0x14,0x24,0x44,0x7F}; // 4
+glyph_line_t chr_053[] = {0x05,0x72,0x51,0x51,0x51,0x4E}; // 5
+glyph_line_t chr_054[] = {0x05,0x3E,0x49,0x49,0x49,0x26}; // 6
+glyph_line_t chr_055[] = {0x05,0x43,0x44,0x48,0x50,0x60}; // 7
+glyph_line_t chr_056[] = {0x05,0x36,0x49,0x49,0x49,0x36}; // 8
+glyph_line_t chr_057[] = {0x05,0x32,0x49,0x49,0x49,0x3E}; // 9
+glyph_line_t chr_058[] = {0x01,0x12}; // :
+glyph_line_t chr_059[] = {0x02,0x01,0x12}; // ;
+glyph_line_t chr_060[] = {0x03,0x08,0x14,0x22}; // <
+glyph_line_t chr_061[] = {0x05,0x14,0x14,0x14,0x14,0x14}; // =
+glyph_line_t chr_062[] = {0x03,0x22,0x14,0x08}; // >
+glyph_line_t chr_063[] = {0x05,0x20,0x40,0x45,0x48,0x30}; // ?
+glyph_line_t chr_064[] = {0x07,0x3E,0x41,0x49,0x55,0x5D,0x45,0x38}; // @
+glyph_line_t chr_065[] = {0x05,0x3F,0x48,0x48,0x48,0x3F}; // A
+glyph_line_t chr_066[] = {0x05,0x7F,0x49,0x49,0x49,0x36}; // B
+glyph_line_t chr_067[] = {0x05,0x3E,0x41,0x41,0x41,0x22}; // C
+glyph_line_t chr_068[] = {0x05,0x7F,0x41,0x41,0x41,0x3E}; // D
+glyph_line_t chr_069[] = {0x05,0x7F,0x49,0x49,0x41,0x41}; // E
+glyph_line_t chr_070[] = {0x05,0x7F,0x48,0x48,0x40,0x40}; // F
+glyph_line_t chr_071[] = {0x05,0x3E,0x41,0x41,0x49,0x2F}; // G
+glyph_line_t chr_072[] = {0x05,0x7F,0x08,0x08,0x08,0x7F}; // H
+glyph_line_t chr_073[] = {0x01,0x7F}; // I
+glyph_line_t chr_074[] = {0x05,0x02,0x01,0x01,0x01,0x7E}; // J
+glyph_line_t chr_075[] = {0x05,0x7F,0x08,0x14,0x22,0x41}; // K
+glyph_line_t chr_076[] = {0x05,0x7F,0x01,0x01,0x01,0x01}; // L
+glyph_line_t chr_077[] = {0x07,0x7F,0x10,0x08,0x04,0x08,0x10,0x7F}; // M
+glyph_line_t chr_078[] = {0x05,0x7F,0x10,0x08,0x04,0x7F}; // N
+glyph_line_t chr_079[] = {0x05,0x3E,0x41,0x41,0x41,0x3E}; // O
+glyph_line_t chr_080[] = {0x05,0x7F,0x48,0x48,0x48,0x30}; // P
+glyph_line_t chr_081[] = {0x05,0x3E,0x41,0x45,0x42,0x3D}; // Q
+glyph_line_t chr_082[] = {0x05,0x7F,0x44,0x44,0x46,0x39}; // R
+glyph_line_t chr_083[] = {0x05,0x32,0x49,0x49,0x49,0x26}; // S
+glyph_line_t chr_084[] = {0x05,0x40,0x40,0x7F,0x40,0x40}; // T
+glyph_line_t chr_085[] = {0x05,0x7E,0x01,0x01,0x01,0x7E}; // U
+glyph_line_t chr_086[] = {0x05,0x7C,0x02,0x01,0x02,0x7C}; // V
+glyph_line_t chr_087[] = {0x07,0x7E,0x01,0x01,0x1E,0x01,0x01,0x7E}; // W
+glyph_line_t chr_088[] = {0x05,0x63,0x14,0x08,0x14,0x63}; // X
+glyph_line_t chr_089[] = {0x05,0x60,0x10,0x0F,0x10,0x60}; // Y
+glyph_line_t chr_090[] = {0x05,0x43,0x45,0x49,0x51,0x61}; // Z
+glyph_line_t chr_091[] = {0x03,0x7F,0x41,0x41}; // [
+glyph_line_t chr_092[] = {0x03,0x60,0x1C,0x03}; // backslash
+glyph_line_t chr_093[] = {0x03,0x41,0x41,0x7F}; // ]
+glyph_line_t chr_094[] = {0x05,0x10,0x20,0x40,0x20,0x10}; // ^
+glyph_line_t chr_095[] = {0x05,0x01,0x01,0x01,0x01,0x01}; // _
+glyph_line_t chr_096[] = {0x02,0x40,0x20}; // `
+glyph_line_t chr_097[] = {0x05,0x02,0x15,0x15,0x15,0x0F}; // a
+glyph_line_t chr_098[] = {0x05,0x7F,0x11,0x11,0x11,0x0E}; // b
+glyph_line_t chr_099[] = {0x05,0x0E,0x11,0x11,0x11,0x0A}; // c
+glyph_line_t chr_100[] = {0x05,0x0E,0x11,0x11,0x11,0x7F}; // d
+glyph_line_t chr_101[] = {0x05,0x0E,0x15,0x15,0x15,0x0C}; // e
+glyph_line_t chr_102[] = {0x05,0x10,0x3F,0x50,0x50,0x40}; // f
+glyph_line_t chr_103[] = {0x05,0x08,0x15,0x15,0x15,0x1E}; // g
+glyph_line_t chr_104[] = {0x05,0x7F,0x10,0x10,0x10,0x0F}; // h
+glyph_line_t chr_105[] = {0x01,0x5F}; // i
+glyph_line_t chr_106[] = {0x05,0x02,0x01,0x01,0x01,0x5E}; // j
+glyph_line_t chr_107[] = {0x05,0x7F,0x04,0x0C,0x12,0x01}; // k
+glyph_line_t chr_108[] = {0x01,0x7F}; // l
+glyph_line_t chr_109[] = {0x07,0x1F,0x10,0x10,0x0C,0x10,0x10,0x0F}; // m
+glyph_line_t chr_110[] = {0x05,0x1F,0x10,0x10,0x10,0x0F}; // n
+glyph_line_t chr_111[] = {0x05,0x0E,0x11,0x11,0x11,0x0E}; // o
+glyph_line_t chr_112[] = {0x05,0x0F,0x14,0x14,0x14,0x08}; // p
+glyph_line_t chr_113[] = {0x05,0x08,0x14,0x14,0x14,0x0F}; // q
+glyph_line_t chr_114[] = {0x05,0x1F,0x04,0x08,0x10,0x10}; // r
+glyph_line_t chr_115[] = {0x05,0x09,0x15,0x15,0x15,0x02}; // s
+glyph_line_t chr_116[] = {0x05,0x10,0x3E,0x11,0x11,0x01}; // t
+glyph_line_t chr_117[] = {0x05,0x1E,0x01,0x01,0x01,0x1E}; // u
+glyph_line_t chr_118[] = {0x05,0x1C,0x02,0x01,0x02,0x1C}; // v
+glyph_line_t chr_119[] = {0x07,0x1E,0x01,0x01,0x02,0x01,0x01,0x1E}; // w
+glyph_line_t chr_120[] = {0x05,0x11,0x0A,0x04,0x0A,0x11}; // x
+glyph_line_t chr_121[] = {0x05,0x19,0x05,0x05,0x05,0x1E}; // y
+glyph_line_t chr_122[] = {0x05,0x11,0x13,0x15,0x19,0x11}; // z
+glyph_line_t chr_123[] = {0x04,0x08,0x36,0x41,0x41}; // {
+glyph_line_t chr_124[] = {0x01,0x7F}; // |
+glyph_line_t chr_125[] = {0x04,0x41,0x41,0x36,0x08}; // }
+glyph_line_t chr_126[] = {0x06,0x20,0x40,0x40,0x20,0x20,0x40}; // ~
+
+const glyph_t pixeloperator[] = {
+ chr_032,
+ chr_033,
+ chr_034,
+ chr_035,
+ chr_036,
+ chr_037,
+ chr_038,
+ chr_039,
+ chr_040,
+ chr_041,
+ chr_042,
+ chr_043,
+ chr_044,
+ chr_045,
+ chr_046,
+ chr_047,
+ chr_048,
+ chr_049,
+ chr_050,
+ chr_051,
+ chr_052,
+ chr_053,
+ chr_054,
+ chr_055,
+ chr_056,
+ chr_057,
+ chr_058,
+ chr_059,
+ chr_060,
+ chr_061,
+ chr_062,
+ chr_063,
+ chr_064,
+ chr_065,
+ chr_066,
+ chr_067,
+ chr_068,
+ chr_069,
+ chr_070,
+ chr_071,
+ chr_072,
+ chr_073,
+ chr_074,
+ chr_075,
+ chr_076,
+ chr_077,
+ chr_078,
+ chr_079,
+ chr_080,
+ chr_081,
+ chr_082,
+ chr_083,
+ chr_084,
+ chr_085,
+ chr_086,
+ chr_087,
+ chr_088,
+ chr_089,
+ chr_090,
+ chr_091,
+ chr_092,
+ chr_093,
+ chr_094,
+ chr_095,
+ chr_096,
+ chr_097,
+ chr_098,
+ chr_099,
+ chr_100,
+ chr_101,
+ chr_102,
+ chr_103,
+ chr_104,
+ chr_105,
+ chr_106,
+ chr_107,
+ chr_108,
+ chr_109,
+ chr_110,
+ chr_111,
+ chr_112,
+ chr_113,
+ chr_114,
+ chr_115,
+ chr_116,
+ chr_117,
+ chr_118,
+ chr_119,
+ chr_120,
+ chr_121,
+ chr_122,
+ chr_123,
+ chr_124,
+ chr_125,
+ chr_126
+};
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;
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);