From 738f69e1dc6bde6a6f9c07971f141ebdde111eab Mon Sep 17 00:00:00 2001
From: Benjamin Koch <bbbsnowball@gmail.com>
Date: Sat, 6 May 2023 00:19:14 +0200
Subject: [PATCH] add I2C and display

---
 .../data/c3pb-background-horiz.pbm            | 121 ++++++++++++
 firmware/test1/heizung-test1/platformio.ini   |   6 +-
 firmware/test1/heizung-test1/src/logo.h       |   6 +
 firmware/test1/heizung-test1/src/main.cpp     | 174 +++++++++++++++---
 4 files changed, 276 insertions(+), 31 deletions(-)
 create mode 100644 firmware/test1/heizung-test1/data/c3pb-background-horiz.pbm
 create mode 100644 firmware/test1/heizung-test1/src/logo.h

diff --git a/firmware/test1/heizung-test1/data/c3pb-background-horiz.pbm b/firmware/test1/heizung-test1/data/c3pb-background-horiz.pbm
new file mode 100644
index 0000000..d4d156b
--- /dev/null
+++ b/firmware/test1/heizung-test1/data/c3pb-background-horiz.pbm
@@ -0,0 +1,121 @@
+P1
+# Created by GIMP version 2.10.32 PNM plug-in
+128 64
+1111111111111111111111111111111111111111111111111111111111111111111111
+1111111111111111111111110111111111111111111111111111111111111111111111
+1111111111111111111111111111111111111111111111111111111111111111111111
+1111111111000001111111111111111111111111111111111111111111111111111111
+1111111111111100000111111111111111111111111111111111111111111111110000
+0000111111111111111111111111111111111111111111111111111111111111111111
+1101100001111111111111111111111111111111111111111111100000000000111111
+1111111111111111111111111111111111111111111111111111111111101111110001
+1111111111111111111111111111111111111110000010011000001111111111111111
+1111111111111111111111111111111111111111111111001111111100011111111111
+1111111111111111111111111000001110011110000011111111111111111111111111
+1111111111111111111111111111111111011111111111000111111111111111111111
+1111111111110000111110011111100001111111111111111111111111111111111111
+1111111111111111111110111011111111110011111111111111111111111111111100
+0011111110011111110000011111111111111111111111111111111111111111111111
+1111111110111011111111111001111111111111111111111111110000011111111001
+1111111100000111111111111111111111111111111111111111111111111111110111
+1011111111111100111111111111111111111111000001111111111001111111111100
+0001111111111111111111111111111111111111111111111111100111101111111111
+1110011111111111111111111110000111111111111000111111111111000011111111
+1111111111111111111111111111111111111111101111101111111111111001111111
+1111111111111000011111111111100000011111111111100000111111111111111111
+1111111111111111111111111111001101101111111111111011111111111111111110
+0000111111111111000000000111111111111000001111111111111111111111111111
+1111111111111111011101101111111111110011111111111111111000001111111111
+1100000111000001111111111110000111111111111111111111111111111111111111
+1110111101011111011111110111111111111111110000111111111111000001111111
+0000011111111111100001111111111111111111111111111111111111110011110101
+1110011111100111111111111111000001111111111100000111111111110000111111
+1111110000011111111111111111111111111111111111110111110101110011111110
+1111111111111110000111111111111000011111111111111000001111111111110000
+1111111111111111111111111111111111100111110101110111111100111111111111
+1110000011111111100000111111111111111110000011111111100000111111111111
+1111111111111111111111101111101011101111111101111111111111111000000111
+1110000000111111111111111111100001111110000000111111111111111111111111
+1111111111001111101011001110001001111111111111111001000001110000100000
+1111111000111111111000011100001100111111111111111111111111111111111100
+1111101010011100111011111111111111111001110000000011111000001111110000
+1111111100000000011100111111111111110000000001111111111110011101111011
+1001110111111111111111111001111100000111111110000111111000001111111100
+0001111100111111100000000000011100000000111111001101010011001110011111
+1111111111111001111110000011111111100001111110000111111000001111110011
+1111100111111111111111111110111111101011110110111110111111111111111111
+1001111110000000111111110000111111100001100000001111110011111110111111
+1111110111111110011111110110101101111100111111111111111111100111111001
+1000001111111111111111110000000011001111110011111100111111111111000111
+1110011111101101101111111101111111111111111111100111111001111000011111
+1111111111111000001111001111110011111100111111111111110000111111111001
+1011011011111011111111111111111111100111111001111110000111111111111111
+0000111111001111110011111100111111111111111111000000001111011101010111
+0011111111111111111111100111111001111111000001111111111100001111111100
+1111110011111100111111111001111111111111111100111011010000011111111111
+1111111111100111111001111111000000011111110000011111111100111111001111
+1100111111111100000000111110000011111011111100111111111111111111111110
+0111111001111111001100001111000001111111111100111111001111110011111111
+1111111100000001111111111010111111111111111111111111111110011111100111
+1111001110000010000111111111111100111111001111110011111111111111111111
+1111111111111010111111111111111111111111111110011111100111111100111110
+0000001111111111111000111111001111110011111111111111111100000001111111
+1010111111111111111111111111111110011111100111111100111111100011111111
+1011110000111111001111110011111111111111000111111111001111101011111111
+1111111111111111111110011111100111111100111111100111111110001111000011
+1111001111110011111111111000111100000001110011101011000001111111111111
+1111111110011111100111111100111111100111111000011111110011111100111111
+0011111111000111000111111110011001101010011001111111111111111111111001
+1111100111111100111111100111111001111111110011111100111111101111110001
+1100011111100111101100111101111100111111111111111111111001111110011111
+1100111111100111111111111111110011111100111111101111101111001111111110
+0111110110110101111110111111111111111111111001111110011111111111111110
+0111111111111111110011111100111111100111111111111111111110111111101101
+1110111110011111111111111111111001111110011111111111111110011111111110
+1111110011111100111111100011111111111111110000111111110110101001111100
+1111111111111111111001111110011111111111111110011111111000111111001111
+1100111111110000000000000000000001111110011110010101111110111111111111
+1111111001111110011111111111111110011111100001111111001111110011111111
+1111111111111111111111111100011011011010111110011111111111111111100111
+1110011111111111111110011111100111111110001111110011111111111111111111
+1111111111111100111111001001001111011111111111111111100111110000011111
+1111111110011111111111111100000111110011111111111111111111111111111111
+1101111101101100100111001111111111111111100111000000001111111111111001
+1111111111110000000001110011111111111111111111111111111111110011110110
+0110011001101111111111111111100100000111000011111111111001111111111110
+0001110000110011111111111111111111111111111111111011110111011100110111
+0111111111111111100000011111100000111111111001111111111000011111100000
+0011111111111111111111111111111111111001111011001110011111011111111111
+1111100000111111111000001111111001111111100000111111111000001111111111
+1111111111111111111111111101111011101111100111101111111111111110000111
+1111111110000111111001111110000011111111111100001111111111111111111111
+1111111111111100111011101111110011100111111111111111000001111111111110
+0001111001111100001111111111110000011111111111111111111111111111111111
+1110111011100111111001110111111111111111110000111111111111000001100111
+0000011111111111100001111111111111111111111111111111111111111001101111
+0111111110110011111111111111111000001111111111110000100000000111111111
+1110000111111111111111111111111111111111111111111101111111011111111111
+1011111111111111111110000011111111111100000000011111111111100000111111
+1111111111111111111111111111111111111110111111111111111111001111111111
+1111111111100001111111111110000001111111111110000011111111111111111111
+1111111111111111111111111110011111111111111111001111111111111111111111
+1000011111111111100011111111111100001111111111111111111111111111111111
+1111111111111111011111111111111110011111111111111111111111110000011111
+1111100111111111110000011111111111111111111111111111111111111111111111
+1111001111111111111000111111111111111111111111111100000111111110011111
+1111000001111111111111111111111111111111111111111111111111111110111111
+1111110011111111111111111111111111111111000011111110011111110000011111
+1111111111111111111111111111111111111111111111111111011111111100011111
+1111111111111111111111111111110000111110011111100001111111111111111111
+1111111111111111111111111111111111111111001111110001111111111111111111
+1111111111111111111000001110011110000011111111111111111111111111111111
+1111111111111111111111111111100111000011111111111111111111111111111111
+1111111110000010011000001111111111111111111111111111111111111111111111
+1111111111111111110000011111111111111111111111111111111111111111111110
+0000000000111111111111111111111111111111111111111111111111111111111111
+1111110001111111111111111111111111111111111111111111111111000000001111
+1111111111111111111111111111111111111111111111111111111111111111111111
+1111111111111111111111111111111111111111111111110000011111111111111111
+1111111111111111111111111111111111111111111111111111111111111111111111
+1111111111111111111111111111111111111101111111111111111111111111111111
+11
\ No newline at end of file
diff --git a/firmware/test1/heizung-test1/platformio.ini b/firmware/test1/heizung-test1/platformio.ini
index 25fb01e..02716d6 100644
--- a/firmware/test1/heizung-test1/platformio.ini
+++ b/firmware/test1/heizung-test1/platformio.ini
@@ -9,12 +9,8 @@
 ; https://docs.platformio.org/page/projectconf.html
 
 [env:pico]
-#platform = raspberrypi
-#board = pico
-#framework = arduino
-
 platform = https://github.com/maxgerhardt/platform-raspberrypi.git
 board = pico
 framework = arduino
 board_build.core = earlephilhower
-#board_build.filesystem_size = 2m
+lib_deps = adafruit/Adafruit SSD1306@^2.5.7
diff --git a/firmware/test1/heizung-test1/src/logo.h b/firmware/test1/heizung-test1/src/logo.h
new file mode 100644
index 0000000..d0943f1
--- /dev/null
+++ b/firmware/test1/heizung-test1/src/logo.h
@@ -0,0 +1,6 @@
+// export PBM file from Gimp and then run:
+// prefix=logo_; ( read; read; read w h; echo "static const int ${prefix}width = $w, ${prefix}height = $h;"; echo "static const uint8_t PROGMEM ${prefix}data[] = {"; echo -n "  "; tr -d '\n' | tr 01 10 | sed -E 's/[01]{8}/0b\0, /g'; echo; echo "};" ) < /tmp/Untitled.pbm
+static const int logo_width = 128, logo_height = 64;
+static const uint8_t PROGMEM logo_data[] = {
+  0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00001111, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b11100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00111111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000010, 0b01111000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01111111, 0b11110000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000100, 0b00001110, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b11110110, 0b01111100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00001100, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000111, 0b11000110, 0b00011111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00001000, 0b00000000, 0b11100000, 0b00000000, 0b00000000, 0b00000000, 0b00001111, 0b00000110, 0b00000111, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010001, 0b00000000, 0b00110000, 0b00000000, 0b00000000, 0b00000000, 0b00111100, 0b00000110, 0b00000011, 0b11100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010001, 0b00000000, 0b00011000, 0b00000000, 0b00000000, 0b00000000, 0b11111000, 0b00000110, 0b00000000, 0b11111000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00100001, 0b00000000, 0b00001100, 0b00000000, 0b00000000, 0b00000011, 0b11100000, 0b00000110, 0b00000000, 0b00111110, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01100001, 0b00000000, 0b00000110, 0b00000000, 0b00000000, 0b00000111, 0b10000000, 0b00000111, 0b00000000, 0b00001111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000001, 0b00000000, 0b00000110, 0b00000000, 0b00000000, 0b00011110, 0b00000000, 0b00011111, 0b10000000, 0b00000111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11001001, 0b00000000, 0b00000100, 0b00000000, 0b00000000, 0b01111100, 0b00000000, 0b00111111, 0b11100000, 0b00000001, 0b11110000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10001001, 0b00000000, 0b00001100, 0b00000000, 0b00000001, 0b11110000, 0b00000000, 0b11111000, 0b11111000, 0b00000000, 0b01111000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b00001010, 0b00001000, 0b00001000, 0b00000000, 0b00000011, 0b11000000, 0b00000011, 0b11100000, 0b00111110, 0b00000000, 0b00011110, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00001010, 0b00011000, 0b00011000, 0b00000000, 0b00001111, 0b10000000, 0b00001111, 0b10000000, 0b00001111, 0b00000000, 0b00001111, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000010, 0b00001010, 0b00110000, 0b00010000, 0b00000000, 0b00011110, 0b00000000, 0b00011110, 0b00000000, 0b00000111, 0b11000000, 0b00000011, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000110, 0b00001010, 0b00100000, 0b00110000, 0b00000000, 0b00011111, 0b00000000, 0b01111100, 0b00000000, 0b00000001, 0b11110000, 0b00000111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000100, 0b00010100, 0b01000000, 0b00100000, 0b00000000, 0b00011111, 0b10000001, 0b11111100, 0b00000000, 0b00000000, 0b01111000, 0b00011111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00001100, 0b00010100, 0b11000111, 0b01100000, 0b00000000, 0b00011011, 0b11100011, 0b11011111, 0b00000001, 0b11000000, 0b00011110, 0b00111100, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00001100, 0b00010101, 0b10001100, 0b01000000, 0b00000000, 0b00011000, 0b11111111, 0b00000111, 0b11000000, 0b11110000, 0b00001111, 0b11111000, 0b11000000, 0b00000000, 0b11111111, 0b10000000, 0b00000110, 0b00100001, 0b00011000, 0b10000000, 0b00000000, 0b00011000, 0b00111110, 0b00000001, 0b11100000, 0b01111100, 0b00000011, 0b11100000, 0b11000000, 0b01111111, 0b11111000, 0b11111111, 0b00000011, 0b00101011, 0b00110001, 0b10000000, 0b00000000, 0b00011000, 0b00011111, 0b00000000, 0b01111000, 0b00011110, 0b00000111, 0b11000000, 0b11000000, 0b01100000, 0b00000000, 0b00000001, 0b00000001, 0b01000010, 0b01000001, 0b00000000, 0b00000000, 0b00011000, 0b00011111, 0b11000000, 0b00111100, 0b00000111, 0b10011111, 0b11000000, 0b11000000, 0b01000000, 0b00000010, 0b00000001, 0b10000000, 0b10010100, 0b10000011, 0b00000000, 0b00000000, 0b00011000, 0b00011001, 0b11110000, 0b00000000, 0b00000011, 0b11111100, 0b11000000, 0b11000000, 0b11000000, 0b00000011, 0b10000001, 0b10000001, 0b00100100, 0b00000010, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b01111000, 0b00000000, 0b00000001, 0b11110000, 0b11000000, 0b11000000, 0b11000000, 0b00000000, 0b11110000, 0b00000110, 0b01001001, 0b00000100, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00011110, 0b00000000, 0b00000011, 0b11000000, 0b11000000, 0b11000000, 0b11000000, 0b00000000, 0b00001111, 0b11110000, 0b10001010, 0b10001100, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001111, 0b10000000, 0b00001111, 0b00000000, 0b11000000, 0b11000000, 0b11000000, 0b00011000, 0b00000000, 0b00000011, 0b00010010, 0b11111000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001111, 0b11100000, 0b00111110, 0b00000000, 0b11000000, 0b11000000, 0b11000000, 0b00001111, 0b11110000, 0b01111100, 0b00010000, 0b00110000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b11110000, 0b11111000, 0b00000000, 0b11000000, 0b11000000, 0b11000000, 0b00000000, 0b00111111, 0b10000000, 0b00010100, 0b00000000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b01111101, 0b11100000, 0b00000000, 0b11000000, 0b11000000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00010100, 0b00000000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b00011111, 0b11000000, 0b00000001, 0b11000000, 0b11000000, 0b11000000, 0b00000000, 0b00001111, 0b11100000, 0b00010100, 0b00000000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b00000111, 0b00000000, 0b01000011, 0b11000000, 0b11000000, 0b11000000, 0b00000000, 0b11100000, 0b00001100, 0b00010100, 0b00000000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b00000110, 0b00000001, 0b11000011, 0b11000000, 0b11000000, 0b11000000, 0b00000111, 0b00001111, 0b11100011, 0b00010100, 0b11111000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b00000110, 0b00000111, 0b10000000, 0b11000000, 0b11000000, 0b11000000, 0b00111000, 0b11100000, 0b00011001, 0b10010101, 0b10011000, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b00000110, 0b00000110, 0b00000000, 0b11000000, 0b11000000, 0b01000000, 0b11100011, 0b10000001, 0b10000100, 0b11000010, 0b00001100, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00001100, 0b00000110, 0b00000000, 0b00000000, 0b11000000, 0b11000000, 0b01000001, 0b00001100, 0b00000001, 0b10000010, 0b01001010, 0b00000100, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00000000, 0b00000110, 0b00000000, 0b00000000, 0b11000000, 0b11000000, 0b01100000, 0b00000000, 0b00000001, 0b00000001, 0b00100001, 0b00000110, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00000000, 0b00000110, 0b00000000, 0b01000000, 0b11000000, 0b11000000, 0b01110000, 0b00000000, 0b00001111, 0b00000000, 0b10010101, 0b10000011, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00000000, 0b00000110, 0b00000001, 0b11000000, 0b11000000, 0b11000000, 0b00111111, 0b11111111, 0b11111110, 0b00000110, 0b00011010, 0b10000001, 0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00000000, 0b00000110, 0b00000111, 0b10000000, 0b11000000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00001110, 0b01001001, 0b01000001, 0b10000000, 0b00000000, 0b00011000, 0b00011000, 0b00000000, 0b00000110, 0b00000110, 0b00000001, 0b11000000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00001100, 0b00001101, 0b10110000, 0b10000000, 0b00000000, 0b00011000, 0b00111110, 0b00000000, 0b00000110, 0b00000000, 0b00000011, 0b11100000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00001000, 0b00100100, 0b11011000, 0b11000000, 0b00000000, 0b00011000, 0b11111111, 0b00000000, 0b00000110, 0b00000000, 0b00001111, 0b11111000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00001100, 0b00100110, 0b01100110, 0b01000000, 0b00000000, 0b00011011, 0b11100011, 0b11000000, 0b00000110, 0b00000000, 0b00011110, 0b00111100, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000100, 0b00100010, 0b00110010, 0b00100000, 0b00000000, 0b00011111, 0b10000001, 0b11110000, 0b00000110, 0b00000000, 0b01111000, 0b00011111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000110, 0b00010011, 0b00011000, 0b00100000, 0b00000000, 0b00011111, 0b00000000, 0b01111100, 0b00000110, 0b00000001, 0b11110000, 0b00000111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000010, 0b00010001, 0b00000110, 0b00010000, 0b00000000, 0b00011110, 0b00000000, 0b00011110, 0b00000110, 0b00000111, 0b11000000, 0b00000011, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00010001, 0b00000011, 0b00011000, 0b00000000, 0b00001111, 0b10000000, 0b00000111, 0b10000110, 0b00001111, 0b00000000, 0b00001111, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b00010001, 0b10000001, 0b10001000, 0b00000000, 0b00000011, 0b11000000, 0b00000011, 0b11100110, 0b00111110, 0b00000000, 0b00011110, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b10010000, 0b10000000, 0b01001100, 0b00000000, 0b00000001, 0b11110000, 0b00000000, 0b11110111, 0b11111000, 0b00000000, 0b01111000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10000000, 0b10000000, 0b00000100, 0b00000000, 0b00000000, 0b01111100, 0b00000000, 0b00111111, 0b11100000, 0b00000001, 0b11110000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b00000000, 0b00001100, 0b00000000, 0b00000000, 0b00011110, 0b00000000, 0b00011111, 0b10000000, 0b00000111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01100000, 0b00000000, 0b00001100, 0b00000000, 0b00000000, 0b00000111, 0b10000000, 0b00000111, 0b00000000, 0b00001111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00100000, 0b00000000, 0b00011000, 0b00000000, 0b00000000, 0b00000011, 0b11100000, 0b00000110, 0b00000000, 0b00111110, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00110000, 0b00000000, 0b01110000, 0b00000000, 0b00000000, 0b00000000, 0b11111000, 0b00000110, 0b00000000, 0b11111000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010000, 0b00000000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00111100, 0b00000110, 0b00000011, 0b11100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00001000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00001111, 0b00000110, 0b00000111, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00001100, 0b00001110, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000111, 0b11000110, 0b00011111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000110, 0b00111100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b11110110, 0b01111100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b11100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01111111, 0b11110000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00111111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00001111, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
+};
diff --git a/firmware/test1/heizung-test1/src/main.cpp b/firmware/test1/heizung-test1/src/main.cpp
index 67bb68d..4983019 100644
--- a/firmware/test1/heizung-test1/src/main.cpp
+++ b/firmware/test1/heizung-test1/src/main.cpp
@@ -1,5 +1,7 @@
 #include <Arduino.h>
 #include <Wire.h>
+#include <Adafruit_GFX.h>
+#include <Adafruit_SSD1306.h>
 
 enum Pinout {
   DRIVE1 = 0,
@@ -34,6 +36,12 @@ enum Pinout {
   MEASURE_VCC = 29,
 };
 
+const int SCREEN_ADDRESS = 0x3C;
+Adafruit_SSD1306 display(128, 64, &Wire, -1);
+bool hasDisplay;
+
+#include "logo.h"
+
 void setup() {
   rp2040.enableDoubleResetBootloader();
 
@@ -51,39 +59,153 @@ void setup() {
   pinMode(REED2, INPUT_PULLUP);
   pinMode(REED3, INPUT_PULLUP);
   pinMode(REED4, INPUT_PULLUP);
+  pinMode(MATRIX_IN1, INPUT_PULLUP);
+  pinMode(MATRIX_IN3, INPUT_PULLUP);
 
-  Serial1.setTX(TX);
+  Serial1.setTX(TX);  // UART0
   Serial1.setRX(RX);
-  Wire.setSDA(I2C_OLED_SDA);
+  Wire.setSDA(I2C_OLED_SDA);  // I2C0
   Wire.setSCL(I2C_OLED_SCL);
 
-  Serial.begin(9600);
+  Serial.begin(9600);  // USB serial, baudrate is ignored
+  Wire.begin();
+  Wire.setClock(400000);
+
+  display.setRotation(2);
+  hasDisplay = display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
+  if (!hasDisplay) {
+    Serial.println(F("SSD1306 allocation failed"));
+  } else {
+    display.clearDisplay();
+    display.drawBitmap(0, 0, logo_data, logo_width, logo_height, SSD1306_WHITE);
+    display.display();
+  }
+}
+
+void i2c_scan() {
+  // copied from here and adapter: https://playground.arduino.cc/Main/I2cScanner/
+  for (byte address = 0; address <= 127; address++ ) {
+    if (address == 0) {
+      Serial.print("00: ");
+    } else if ((address % 16) == 0) {
+      Serial.write("\r\n");
+      Serial.print(address, HEX);
+      Serial.write(":");
+    }
+
+    // The i2c_scanner uses the return value of
+    // the Write.endTransmisstion to see if
+    // a device did acknowledge to the address.
+    Wire.beginTransmission(address);
+    byte error = Wire.endTransmission();
+
+    if (error == 0)
+    {
+      Serial.write(" ");
+      if (address < 16)
+        Serial.write("0");
+      Serial.print(address, HEX);
+    } else if (error==4) {
+      Serial.print(" !!");
+    } else {
+      Serial.print(" --");
+    }
+  }
+  Serial.println();
 }
 
 void loop() {
-  for (int i=2; i<=7; i++) {
-    if (i > 2)
-      digitalWrite(i-1, 0);
-    if (i <= 6)
-      digitalWrite(i, 1);
-    delay(100);
+  static int led_timer = 0;
+  static int led_state = 2;
+  if (led_timer < 500)
+    led_timer++;
+  else {
+    led_timer = 0;
+    led_state++;
+    if (led_state == 8)
+      led_state = 2;
+    if (led_state > 2)
+      digitalWrite(led_state-1, 0);
+    if (led_state <= 6)
+      digitalWrite(led_state, 1);
+  }
+
+  static int print_state_timer = 0;
+  if (led_timer < 500)
+    print_state_timer++;
+  else {
+    print_state_timer = 0;
+    Serial.write("x: ");
+    Serial.write('0' + digitalRead(VBUS_DET));
+    Serial.write('0' + digitalRead(BOOT2));
+    Serial.write('0' + digitalRead(WS2811));
+    Serial.write('0' + digitalRead(REED1));
+    Serial.write('0' + digitalRead(REED2));
+    Serial.write('0' + digitalRead(REED3));
+    Serial.write('0' + digitalRead(REED4));
+    Serial.write(", f_cpu=");
+    Serial.print(rp2040.f_cpu());
+    Serial.write(", id=");
+    Serial.print(rp2040.cpuid());
+    Serial.write(", cycles=");
+    Serial.print(rp2040.getCycleCount64());
+    Serial.write(", rand=");
+    Serial.print(rp2040.hwrand32());
+    Serial.write("\r\n");
+  }
+
+  static int i2c_scan_timer = 0;
+  if (i2c_scan_timer < 5000)
+    i2c_scan_timer++;
+  else {
+    i2c_scan_timer = 0;
+    i2c_scan();
+  }
+
+  if (rp2040.getCycleCount64() > 2 * 133*1000*1000) {
+    display.fillRect(0, 0, 67, 64, SSD1306_BLACK);
+
+    display.setTextSize(1);
+    display.setTextColor(SSD1306_WHITE);
+    display.setCursor(0, 1);
+    display.print(F("ADDR: "));
+    display.println(digitalRead(BOOT2) ? '_' : 'X');
+
+    // Button Matrix:
+    // 1: SDA, IN1
+    // 2: SDA, IN3
+    // 3: SCL, IN1
+    // 4: SCL, IN4
+    Wire.end();
+    pinMode(I2C_OLED_SDA, OUTPUT);
+    pinMode(I2C_OLED_SCL, INPUT_PULLUP);
+    delayMicroseconds(1);
+    bool buttons[4];
+    buttons[0] = digitalRead(MATRIX_IN1);
+    buttons[1] = digitalRead(MATRIX_IN3);
+    pinMode(I2C_OLED_SDA, INPUT_PULLUP);
+    pinMode(I2C_OLED_SCL, OUTPUT);
+    delayMicroseconds(1);
+    buttons[2] = digitalRead(MATRIX_IN1);
+    buttons[3] = digitalRead(MATRIX_IN3);
+    pinMode(I2C_OLED_SDA, INPUT_PULLUP);
+    pinMode(I2C_OLED_SCL, INPUT_PULLUP);
+    Wire.begin();
+
+    display.print(F("SW:   "));
+    for (auto not_pressed : buttons)
+      display.print(not_pressed ? '_' : 'X');
+    display.println();
+
+    display.print(F("Reed: "));
+    display.print(digitalRead(REED1) ? '^' : 'v');
+    display.print(digitalRead(REED2) ? '^' : 'v');
+    display.print(digitalRead(REED3) ? '^' : 'v');
+    display.print(digitalRead(REED4) ? '^' : 'v');
+    display.println();
+
+    display.display();
   }
 
-  Serial.write("x: ");
-  Serial.write('0' + digitalRead(VBUS_DET));
-  Serial.write('0' + digitalRead(BOOT2));
-  Serial.write('0' + digitalRead(WS2811));
-  Serial.write('0' + digitalRead(REED1));
-  Serial.write('0' + digitalRead(REED2));
-  Serial.write('0' + digitalRead(REED3));
-  Serial.write('0' + digitalRead(REED4));
-  Serial.write(", f_cpu=");
-  Serial.print(rp2040.f_cpu());
-  Serial.write(", id=");
-  Serial.print(rp2040.cpuid());
-  Serial.write(", cycles=");
-  Serial.print(rp2040.getCycleCount64());
-  Serial.write(", rand=");
-  Serial.print(rp2040.hwrand32());
-  Serial.write("\r\n");
+  delay(1);
 }
\ No newline at end of file
-- 
GitLab