summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/object/framebuffer.h21
-rwxr-xr-xscript/mkconfig21
-rw-r--r--src/app/pervasive-aurora-mb-test/Kconfig6
-rw-r--r--src/app/pervasive-aurora-mb-test/Makefile.inc9
-rw-r--r--src/app/pervasive-aurora-mb-test/main.cc140
-rw-r--r--src/os/object/framebuffer.cc70
6 files changed, 267 insertions, 0 deletions
diff --git a/include/object/framebuffer.h b/include/object/framebuffer.h
new file mode 100644
index 0000000..6eac7e0
--- /dev/null
+++ b/include/object/framebuffer.h
@@ -0,0 +1,21 @@
+#pragma once
+
+class Framebuffer
+{
+ public:
+ unsigned char *data;
+
+ Framebuffer(unsigned char *data) : data(data) {}
+
+ constexpr static unsigned int const width = CONFIG_framebuffer_width;
+ constexpr static unsigned int const height = CONFIG_framebuffer_height;
+
+ 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);
+};
+
+extern Framebuffer fb;
diff --git a/script/mkconfig b/script/mkconfig
index 4cb5666..5442f02 100755
--- a/script/mkconfig
+++ b/script/mkconfig
@@ -37,6 +37,27 @@ range 1 10000
default 10
depends on meta_driver_timer
+config framebuffer
+bool "Framebuffer"
+default n
+
+config framebuffer_in_text_segment
+bool "Place Framebuffer in text segment"
+default y
+depends on framebuffer
+
+config framebuffer_width
+int "Framebuffer Width"
+default 300
+range 8 800
+depends on framebuffer
+
+config framebuffer_height
+int "Framebuffer Height"
+default 400
+range 8 800
+depends on framebuffer
+
endmenu
choice Architecture
diff --git a/src/app/pervasive-aurora-mb-test/Kconfig b/src/app/pervasive-aurora-mb-test/Kconfig
new file mode 100644
index 0000000..57c5874
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-test/Kconfig
@@ -0,0 +1,6 @@
+# Copyright 2021 Daniel Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+prompt "Pervasive Aurora Mb Test"
+depends on framebuffer && driver_pervasive_aurora_mb && loop && !wakeup
diff --git a/src/app/pervasive-aurora-mb-test/Makefile.inc b/src/app/pervasive-aurora-mb-test/Makefile.inc
new file mode 100644
index 0000000..0eea52a
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-test/Makefile.inc
@@ -0,0 +1,9 @@
+# vim:ft=make
+#
+# Copyright 2020 Daniel Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+ifdef app
+ loop = 1
+endif
diff --git a/src/app/pervasive-aurora-mb-test/main.cc b/src/app/pervasive-aurora-mb-test/main.cc
new file mode 100644
index 0000000..50c5ec2
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-test/main.cc
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2020 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "arch.h"
+#include "driver/spi.h"
+#include "driver/stdout.h"
+#include "driver/pervasive_aurora_mb.h"
+#include "object/framebuffer.h"
+
+
+__attribute__ ((section(".text"))) unsigned char lynx[12 * 96] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x88, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x0C, 0x16, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x18, 0x0A, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x10, 0x0A, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x30, 0x0B, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x60, 0x0D, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x40, 0x2D, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x80, 0x3D, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3F, 0x81, 0x80, 0x1D, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3F, 0xC1, 0x00, 0x1C, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3F, 0xE3, 0x00, 0xFC, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF6, 0x11, 0xFC, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFE, 0x10, 0x7C, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFE, 0x10, 0x7C, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x10, 0xFC, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x10, 0xFF, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x03, 0xFF, 0x0F, 0x19, 0xFF, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0xFF, 0x80, 0x0F, 0xFF, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1F, 0x71, 0xC0, 0xFF, 0x7F, 0xE0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x38, 0x70, 0x40, 0x7C, 0x7F, 0xF0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x70, 0x60, 0x20, 0x00, 0x7F, 0xF0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0xC0, 0xE0, 0x00, 0x00, 0xE1, 0xB8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x07, 0x81, 0xC0, 0x00, 0x00, 0x70, 0x9E, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0F, 0x81, 0xC0, 0x00, 0x00, 0x70, 0x1F, 0xC0, 0x00, 0x00,
+ 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x0F, 0xE0, 0x00, 0x00,
+ 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x0F, 0xF8, 0x00, 0x00,
+ 0x00, 0x00, 0x0C, 0x01, 0xFE, 0x00, 0x3F, 0x80, 0x0F, 0xFE, 0x00, 0x00,
+ 0x00, 0x00, 0x0C, 0x03, 0xE0, 0x00, 0x0F, 0x80, 0x0F, 0xFF, 0x00, 0x00,
+ 0x00, 0x00, 0x0C, 0x07, 0x18, 0x00, 0x03, 0x8C, 0x07, 0xFF, 0x80, 0x00,
+ 0x00, 0x00, 0x08, 0x3E, 0x60, 0x00, 0x01, 0xCC, 0x03, 0xFF, 0xC0, 0x00,
+ 0x00, 0x00, 0x08, 0x39, 0xC0, 0x00, 0x00, 0xFC, 0x03, 0x80, 0xE0, 0x00,
+ 0x00, 0x00, 0x18, 0x7F, 0xE0, 0x01, 0xE0, 0x7E, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x33, 0xC4, 0x00, 0x00, 0x3C, 0x3F, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x07, 0x9F, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xEC, 0x00, 0x01, 0xFE, 0x01, 0xEF, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x03, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x06, 0x10, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x00,
+ 0x00, 0x0E, 0x20, 0x1C, 0x00, 0x00, 0x0F, 0x07, 0xF0, 0x00, 0x00, 0x00,
+ 0x00, 0x0F, 0xA0, 0x70, 0x00, 0x00, 0x01, 0xC7, 0xF0, 0x00, 0x00, 0x00,
+ 0x00, 0x0F, 0xC1, 0xC6, 0x00, 0x0F, 0xFF, 0xF3, 0xE0, 0x00, 0x00, 0x00,
+ 0x00, 0x0F, 0xC3, 0x1C, 0x00, 0x00, 0x1F, 0xFD, 0xF0, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x86, 0x3F, 0x80, 0x00, 0x03, 0xFF, 0xF8, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x99, 0xFF, 0xE0, 0x00, 0x07, 0xFF, 0xFC, 0x00, 0x00, 0x00,
+ 0x00, 0x03, 0xFF, 0xFD, 0xF8, 0x00, 0x00, 0x7F, 0xFC, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0xFF, 0xC5, 0xFE, 0x00, 0x06, 0x3F, 0xFC, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xE2, 0x6F, 0xFF, 0x80, 0x03, 0x8F, 0xF6, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x5F, 0xFF, 0xC0, 0x00, 0xC7, 0xF0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x21, 0x43, 0xFE, 0xF0, 0x00, 0x73, 0xF8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0xC0, 0xFE, 0xF8, 0x00, 0x11, 0xF8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1C, 0xC0, 0x7E, 0xF8, 0x00, 0x08, 0xF8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0C, 0x40, 0x36, 0x7C, 0x0C, 0x04, 0x7C, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x17, 0x7E, 0x07, 0x80, 0x3C, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0B, 0x3E, 0x01, 0xE0, 0x1E, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0B, 0x9E, 0x00, 0xF0, 0x0E, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0xCF, 0x00, 0x7C, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0xEF, 0x00, 0x3E, 0x03, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0x00, 0x1F, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x7F, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0xFE, 0x00, 0x33, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0xDE, 0x01, 0x3B, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xDE, 0x01, 0xBF, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x01, 0xFF, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x11, 0x0E, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x03, 0xFF, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x07, 0xFF, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x07, 0xFF, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, 0xFF, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x82, 0xEE, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDE, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+
+void loop(void)
+{
+ static unsigned int i = 0;
+ fb.drawAt(i*20, i*20, 96, 96, lynx);
+ i = (i+1) % 6;
+ kout << "powerOn" << 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();
+}
+
+int main(void)
+{
+ arch.setup();
+ kout.setup();
+ spi.setup();
+ pervasiveAuroraMb.setup();
+
+ arch.idle_loop();
+
+ return 0;
+}
diff --git a/src/os/object/framebuffer.cc b/src/os/object/framebuffer.cc
new file mode 100644
index 0000000..ad128dc
--- /dev/null
+++ b/src/os/object/framebuffer.cc
@@ -0,0 +1,70 @@
+#include "object/framebuffer.h"
+
+#ifdef CONFIG_framebuffer_in_text_segment
+__attribute__ ((section(".text")))
+#endif
+static unsigned char framebuffer[(unsigned long int)CONFIG_framebuffer_width * (unsigned long int)CONFIG_framebuffer_height / 8];
+
+void Framebuffer::clear()
+{
+ for (unsigned int i = 0; i < width * (height / 8); i++) {
+ data[i] = 0;
+ }
+}
+
+void Framebuffer::fillBox(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
+{
+ if (w == 0 || h == 0) {
+ return;
+ }
+ w -= 1;
+ h -= 1;
+ if ((x+w) >= width || (y+h) >= height) {
+ return;
+ }
+
+ unsigned int x1 = (height/8)*x;
+ unsigned int x2 = (height/8)*(x+w);
+ unsigned int y2 = height-1-y;
+ unsigned int y1 = y2-h;
+ unsigned char y2_mask = 0xff << (8 - (y2 % 8)); // bits from 0 to y2%8 must be filled
+ unsigned char y1_mask = 0xff >> (y1 % 8); // bits from y1%8 to 7 must be filled
+ y1 = y1/8;
+ y2 = y2/8;
+
+ if (y1 == y2) {
+ // y1_mask and y2_mask overlap
+ for (unsigned int pos_x = x1; pos_x < x2; pos_x += height/8) {
+ data[pos_x + y1] |= y1_mask & y2_mask;
+ }
+ } else {
+ if (y1_mask != 0xff) {
+ for (unsigned int pos_x = x1; pos_x < x2; pos_x += height/8) {
+ data[pos_x + y1] |= y1_mask;
+ }
+ y1++;
+ }
+ for (unsigned int pos_x = x1; pos_x < x2; pos_x += height/8) {
+ for (unsigned int pos_y = y1; pos_y < y2; pos_y++) {
+ data[pos_x + pos_y] = 0xff;
+ }
+ }
+ if (y2_mask) {
+ for (unsigned int pos_x = x1; pos_x < x2; pos_x += height/8) {
+ data[pos_x + y2] |= y2_mask;
+ }
+ }
+ }
+}
+
+void Framebuffer::drawAt(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *image)
+{
+ y /= 8;
+ for (unsigned int pos_x = 0; pos_x < w; pos_x++) {
+ for (unsigned int pos_y = 0; pos_y < h/8; pos_y++) {
+ data[(x + pos_x) * (height/8) + y + pos_y] = image[pos_x * (h/8) + pos_y];
+ }
+ }
+}
+
+Framebuffer fb(framebuffer);