diff --git a/eink/eink b/eink/eink index 91b49cd..8d83694 160000 --- a/eink/eink +++ b/eink/eink @@ -1 +1 @@ -Subproject commit 91b49cd536ea8542908bdfb68a6cb7164128df52 +Subproject commit 8d8369440c2a3ea25c7c5ca31c16e790746eede0 diff --git a/eink/main.cpp b/eink/main.cpp index 8d5f70c..034d4ea 100644 --- a/eink/main.cpp +++ b/eink/main.cpp @@ -1,7 +1,11 @@ #include "clock.hpp" +#include #include +#include +#include + #include "eink/eink.hpp" #include "flash/flash.hpp" #include "io/io.hpp" @@ -15,6 +19,214 @@ REGISTER_UART0_INT_VECTORS(uart_t); using spi_t = eink::Spi; using eink_t = eink::Eink<200, 200, spi_t, io::P::C1, io::P::C0>; +using eink::Voltage::VSH1; +using eink::Voltage::VSH2; +using eink::Voltage::VSL1; +using eink::Voltage::VSS1; + +constexpr auto ORIGINAL_WAVEFORM_LUT + [[gnu::progmem]] = + eink::Waveform{ + .lut = {{{ + {.phaseD = VSH1, .phaseC = VSH1, .phaseB = VSS1, .phaseA = VSH1}, + {.phaseD = VSL1, .phaseC = VSL1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSL1, .phaseC = VSH1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSL1, .phaseC = VSL1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSL1, .phaseC = VSL1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSH1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSH1}, + }}, + {{ + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSH1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSL1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSL1, .phaseC = VSH1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSH1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSL1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSL1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + }}, + {{ + {.phaseD = VSL1, .phaseC = VSL1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSL1, .phaseC = VSL1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSL1, .phaseC = VSH1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSH1, .phaseC = VSH1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSH2, .phaseC = VSL1, .phaseB = VSL1, .phaseA = VSS1}, + {.phaseD = VSH2, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSL1}, + {.phaseD = VSH2, .phaseC = VSH2, .phaseB = VSH2, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSH2, .phaseB = VSH2, .phaseA = VSH2}, + }}, + {{ + {.phaseD = VSL1, .phaseC = VSL1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSL1, .phaseC = VSL1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSL1, .phaseC = VSH1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSH1, .phaseC = VSH1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSH1, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSH2, .phaseC = VSL1, .phaseB = VSL1, .phaseA = VSS1}, + {.phaseD = VSH2, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSL1}, + {.phaseD = VSH2, .phaseC = VSH2, .phaseB = VSH2, .phaseA = VSL1}, + {.phaseD = VSS1, .phaseC = VSH2, .phaseB = VSH2, .phaseA = VSH2}, + }}, + {{ + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSL1, .phaseA = VSH1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + {.phaseD = VSS1, .phaseC = VSS1, .phaseB = VSS1, .phaseA = VSS1}, + }}}, + .timings = + { + { + .frameCountPhaseA = 32, + .frameCountPhaseB = 16, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 19, + .frameCountPhaseD = 20, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + { + .frameCountPhaseA = 3, + .frameCountPhaseB = 3, + .repeatSubPhaseAB = 6, + .frameCountPhaseC = 12, + .frameCountPhaseD = 10, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + { + .frameCountPhaseA = 3, + .frameCountPhaseB = 4, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 3, + .frameCountPhaseD = 4, + .repeatSubPhaseCD = 0, + .repeat = 10, + }, + { + .frameCountPhaseA = 3, + .frameCountPhaseB = 3, + .repeatSubPhaseAB = 10, + .frameCountPhaseC = 22, + .frameCountPhaseD = 2, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + { + .frameCountPhaseA = 3, + .frameCountPhaseB = 3, + .repeatSubPhaseAB = 3, + .frameCountPhaseC = 0, + .frameCountPhaseD = 0, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + { + .frameCountPhaseA = 2, + .frameCountPhaseB = 2, + .repeatSubPhaseAB = 3, + .frameCountPhaseC = 5, + .frameCountPhaseD = 5, + .repeatSubPhaseCD = 1, + .repeat = 0, + }, + { + .frameCountPhaseA = 22, + .frameCountPhaseB = 20, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 20, + .frameCountPhaseD = 0, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + { + .frameCountPhaseA = 0, + .frameCountPhaseB = 0, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 0, + .frameCountPhaseD = 0, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + { + .frameCountPhaseA = 4, + .frameCountPhaseB = 5, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 3, + .frameCountPhaseD = 40, + .repeatSubPhaseCD = 0, + .repeat = 2, + }, + { + .frameCountPhaseA = 2, + .frameCountPhaseB = 3, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 3, + .frameCountPhaseD = 50, + .repeatSubPhaseCD = 0, + .repeat = 1, + }, + { + .frameCountPhaseA = 6, + .frameCountPhaseB = 3, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 34, + .frameCountPhaseD = 5, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + { + .frameCountPhaseA = 4, + .frameCountPhaseB = 5, + .repeatSubPhaseAB = 0, + .frameCountPhaseC = 5, + .frameCountPhaseD = 1, + .repeatSubPhaseCD = 0, + .repeat = 0, + }, + }, + .frameRates = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, + .subPhaseGateStates = {}, + }; + +static inline constexpr auto createFastWaveformLut(const eink::Waveform &original) +{ + auto fastWaveformLut = original; + + for (auto &timing : fastWaveformLut.timings) { + timing.repeatSubPhaseAB = 0; + timing.repeatSubPhaseCD = 0; + timing.repeat = 0; + } + + return fastWaveformLut; +} + +constexpr auto FAST_WAVEFORM_LUT [[gnu::progmem]] = createFastWaveformLut(ORIGINAL_WAVEFORM_LUT); + void dumpOTP(eink_t &einkDisplay, uart_t &serial) { constexpr auto printWidth = 16; @@ -59,6 +271,9 @@ int main() serial << F("e-Paper clear") << F("\r\n"); einkDisplay.clear(); + serial << F("e-Paper draw fast") << F("\r\n"); + einkDisplay.draw(RLE_IMAGE, FAST_WAVEFORM_LUT); + serial << F("e-Paper draw") << F("\r\n"); einkDisplay.draw(RLE_IMAGE);