From 061b789319293820361731997a5c49e635660ddc Mon Sep 17 00:00:00 2001 From: BlackMark Date: Thu, 2 Jun 2022 21:38:32 +0200 Subject: [PATCH] Implement OTP dumping --- eink/eink | 2 +- eink/eink.cppproj | 3 +++ eink/flash | 2 +- eink/main.cpp | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/eink/eink b/eink/eink index 7a0f00c..91b49cd 160000 --- a/eink/eink +++ b/eink/eink @@ -1 +1 @@ -Subproject commit 7a0f00ceab04f291596d0c1064e64833b4f7a280 +Subproject commit 91b49cd536ea8542908bdfb68a6cb7164128df52 diff --git a/eink/eink.cppproj b/eink/eink.cppproj index 0d12cc2..f021aa5 100644 --- a/eink/eink.cppproj +++ b/eink/eink.cppproj @@ -224,6 +224,9 @@ compile + + compile + compile diff --git a/eink/flash b/eink/flash index 6edb2e5..f9014ae 160000 --- a/eink/flash +++ b/eink/flash @@ -1 +1 @@ -Subproject commit 6edb2e5a21e0ce58ff2df936caee8b84e240a46b +Subproject commit f9014aea6cbbb1ea76f30148a64e6c3fc3152dcd diff --git a/eink/main.cpp b/eink/main.cpp index 450907b..8d5f70c 100644 --- a/eink/main.cpp +++ b/eink/main.cpp @@ -1,5 +1,7 @@ #include "clock.hpp" +#include + #include "eink/eink.hpp" #include "flash/flash.hpp" #include "io/io.hpp" @@ -13,6 +15,33 @@ 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>; +void dumpOTP(eink_t &einkDisplay, uart_t &serial) +{ + constexpr auto printWidth = 16; + auto printedCnt = std::size_t{0}; + + einkDisplay.dumpOTP([&serial, &printedCnt](const auto &data) { + constexpr auto printAddress = true; + + if (printedCnt > 0 && printedCnt % printWidth == 0) { + serial << F("\r\n"); + } + + if (printAddress && printedCnt % printWidth == 0) { + serial << F("0x"); + serial.txNumber(printedCnt); + serial << F(": "); + } + + serial << F("0x"); + serial.txNumber, 16, 2>(data); + serial << F(", "); + + ++printedCnt; + }); + serial << F("\r\n"); +} + int main() { uart_t serial; @@ -33,6 +62,9 @@ int main() serial << F("e-Paper draw") << F("\r\n"); einkDisplay.draw(RLE_IMAGE); + serial << F("e-Paper dump OTP") << F("\r\n"); + dumpOTP(einkDisplay, serial); + serial << F("e-Paper sleep") << F("\r\n"); einkDisplay.sleep();