summaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/ssd1306test/Kconfig6
-rw-r--r--src/app/ssd1306test/Makefile.inc13
-rw-r--r--src/app/ssd1306test/main.cc41
-rwxr-xr-xsrc/app/ssd1306test/png-to-h23
4 files changed, 83 insertions, 0 deletions
diff --git a/src/app/ssd1306test/Kconfig b/src/app/ssd1306test/Kconfig
new file mode 100644
index 0000000..dd71bba
--- /dev/null
+++ b/src/app/ssd1306test/Kconfig
@@ -0,0 +1,6 @@
+# Copyright 2021 Daniel Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+prompt "SSD1306 Test"
+depends on driver_ssd1306 && loop && !wakeup
diff --git a/src/app/ssd1306test/Makefile.inc b/src/app/ssd1306test/Makefile.inc
new file mode 100644
index 0000000..9a32d56
--- /dev/null
+++ b/src/app/ssd1306test/Makefile.inc
@@ -0,0 +1,13 @@
+# vim:ft=make
+#
+# Copyright 2021 Daniel Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+ifdef app
+ CONFIG_loop = y
+ override arch_drivers += ,i2c
+ CONFIG_driver_ssd1306 = y
+ CONFIG_driver_ssd1306_width = 128
+ CONFIG_driver_ssd1306_height = 64
+endif
diff --git a/src/app/ssd1306test/main.cc b/src/app/ssd1306test/main.cc
new file mode 100644
index 0000000..909d26d
--- /dev/null
+++ b/src/app/ssd1306test/main.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2021 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C)
+#include "driver/i2c.h"
+#else
+#include "driver/soft_i2c.h"
+#endif
+#include "driver/ssd1306.h"
+
+unsigned char const image[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 224, 240, 240, 240, 248, 248, 248, 248, 248, 248, 248, 248, 248, 240, 240, 240, 224, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 184, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 255, 255, 255, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 30, 63, 63, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 223, 3, 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 15, 31, 15, 15, 143, 255, 255, 255, 255, 255, 239, 159, 31, 31, 15, 7, 3, 3, 0, 0, 15, 127, 255, 255, 255, 127, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 224, 240, 248, 252, 254, 135, 7, 7, 6, 142, 236, 252, 248, 152, 16, 48, 96, 96, 192, 192, 128, 128, 128, 128, 128, 128, 128, 128, 128, 192, 192, 128, 128, 128, 192, 224, 248, 252, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 252, 248, 240, 224, 128, 128, 128, 129, 193, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 192, 192, 96, 32, 48, 16, 216, 248, 252, 204, 142, 6, 7, 7, 142, 254, 252, 248, 240, 224, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243, 1, 1, 14, 255, 255, 255, 31, 6, 0, 0, 63, 255, 255, 63, 7, 0, 0, 0, 248, 254, 255, 255, 125, 1, 1, 1, 49, 253, 255, 255, 253, 1, 1, 19, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 191, 1, 1, 33, 253, 255, 255, 253, 49, 1, 1, 1, 125, 255, 255, 252, 248, 0, 0, 0, 7, 63, 255, 255, 63, 0, 0, 6, 31, 255, 255, 255, 30, 1, 1, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 7, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 31, 31, 3, 0, 0, 0, 0, 0, 3, 63, 191, 129, 192, 224, 254, 255, 255, 255, 63, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 255, 255, 255, 224, 224, 192, 131, 191, 127, 7, 0, 0, 0, 0, 0, 3, 63, 63, 0, 0, 0, 0, 0, 0, 1, 7, 0, 0, 0, 0, 0, 0, 7, 15, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 240, 240, 240, 240, 224, 224, 240, 248, 248, 124, 62, 63, 31, 31, 15, 7, 7, 3, 1, 0, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 192, 0, 1, 3, 7, 7, 15, 31, 31, 63, 62, 124, 124, 248, 240, 248, 248, 248, 240, 176, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+void loop(void)
+{
+ static unsigned char i = 0;
+ gpio.led_toggle(1);
+ ssd1306.setInvert((i % 20) >= 10);
+ ssd1306.setContrast((i % 10) * 25);
+
+ i++;
+}
+
+int main(void)
+{
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+ i2c.setup();
+ ssd1306.init();
+
+ ssd1306.showImage((unsigned char*)image, sizeof(image));
+
+ arch.idle_loop();
+
+ return 0;
+}
diff --git a/src/app/ssd1306test/png-to-h b/src/app/ssd1306test/png-to-h
new file mode 100755
index 0000000..5e95967
--- /dev/null
+++ b/src/app/ssd1306test/png-to-h
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+from PIL import Image
+import sys
+
+
+def load_image(filename):
+ im = Image.open(filename)
+ w, h = im.size
+ buf = [0 for i in range(buf_w * buf_h // 8)]
+ for y in range(min(h, buf_h)):
+ for x in range(min(w, buf_w)):
+ if im.getpixel((x, y)):
+ buf[(y // 8) * buf_w + x] |= 1 << (y % 8)
+ return buf
+
+
+buf_w = int(sys.argv[1])
+buf_h = int(sys.argv[2])
+filename = sys.argv[3]
+
+buf = load_image(filename)
+print(", ".join(map(str, buf)))