From ca3fb7854e86fc178516c2d8f4df6604973f8061 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Thu, 26 May 2022 14:49:17 +0200 Subject: [PATCH] Add waveshare eink display library --- .gitmodules | 6 ++ eink/clock.hpp | 2 +- eink/eink | 1 + eink/eink.cppproj | 141 ++++++++++++++++++++++++++++------------------ eink/main.cpp | 30 +++++++++- eink/spi | 1 + 6 files changed, 124 insertions(+), 57 deletions(-) create mode 160000 eink/eink create mode 160000 eink/spi diff --git a/.gitmodules b/.gitmodules index 88de5d1..0078131 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ +[submodule "eink/eink"] + path = eink/eink + url = git@git.blackmark.me:avr/eink.git [submodule "eink/uart"] path = eink/uart url = git@git.blackmark.me:avr/uart.git @@ -10,3 +13,6 @@ [submodule "eink/flash"] path = eink/flash url = git@git.blackmark.me:avr/flash.git +[submodule "eink/spi"] + path = eink/spi + url = git@git.blackmark.me:avr/spi.git diff --git a/eink/clock.hpp b/eink/clock.hpp index 376492e..052799d 100644 --- a/eink/clock.hpp +++ b/eink/clock.hpp @@ -1,4 +1,4 @@ #pragma once -#define F_CPU 8'000'000 +#define F_CPU 16'000'000 #include diff --git a/eink/eink b/eink/eink new file mode 160000 index 0000000..08dd107 --- /dev/null +++ b/eink/eink @@ -0,0 +1 @@ +Subproject commit 08dd1073af43b65b358257b968852aae8fc77946 diff --git a/eink/eink.cppproj b/eink/eink.cppproj index d232554..87e345f 100644 --- a/eink/eink.cppproj +++ b/eink/eink.cppproj @@ -83,6 +83,17 @@ + + \Debug\eink.lss + + + .lss + ^\s*(?<address>[a-f0-9]*):\s*.*$ + true + address + $pc + + @@ -146,67 +157,76 @@ - -mmcu=atmega328p - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include - - - Optimize (-O1) - True - Maximum (-g3) - True - True - True - -fno-threadsafe-statics -std=c11 - True - True - - - DEBUG - - - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include - - - Optimize debugging experience (-Og) - True - Maximum (-g3) - True - True - -fno-threadsafe-statics -Wextra -std=c++17 - - - libm - - - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include - - - Default (-Wa,-g) - + -mmcu=atmega328p + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include + + + Optimize (-O1) + True + Maximum (-g3) + True + True + True + -fno-threadsafe-statics -std=c11 + True + True + + + DEBUG + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include + + + Optimize debugging experience (-Og) + True + Maximum (-g3) + True + True + -fno-threadsafe-statics -Wextra -std=c++17 + + + libm + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include + + + Default (-Wa,-g) + compile + + compile + + + compile + + + compile + compile @@ -216,6 +236,15 @@ compile + + compile + + + compile + + + compile + compile @@ -253,6 +282,8 @@ + + diff --git a/eink/main.cpp b/eink/main.cpp index c2297b8..12607ef 100644 --- a/eink/main.cpp +++ b/eink/main.cpp @@ -2,20 +2,48 @@ #include "flash/flash.hpp" #include "io/io.hpp" +#include "spi/spi.hpp" #include "uart/uart.hpp" +#include "eink/epd1in54b_V2.h" +#include "eink/imagedata.h" + using uart_t = uart::Uart0<>; REGISTER_UART0_INT_VECTORS(uart_t); ////////////////////////////////////////////////////////////////////////// int main() { + using spi_t = spi::Hardware>; + uart_t serial; serial.init(); + sei(); + serial << F("e-Paper demo") << F("\r\n"); + + Epd epd; + if (epd.Init() != 0) { + serial << F("e-Paper init failed") << F("\r\n"); + serial.flushTx(); + _delay_ms(1000); + return 0; + } + + serial << F("e-Paper init") << F("\r\n"); + + serial << F("e-Paper clear") << F("\r\n"); + epd.DisplayClear(); + + serial << F("e-Paper draw") << F("\r\n"); + epd.DisplayFrame(IMAGE_BLACK, IMAGE_RED); + + serial << F("e-Paper sleep") << F("\r\n"); + epd.Sleep(); + while (true) { - serial << F("Hello World!") << F("\r\n"); + serial << F("e-Paper running") << F("\r\n"); _delay_ms(1000); } diff --git a/eink/spi b/eink/spi new file mode 160000 index 0000000..70aabc0 --- /dev/null +++ b/eink/spi @@ -0,0 +1 @@ +Subproject commit 70aabc07f64a33b04e3e9ee00627f5c120b1f9ef