From 203a59d8b9f7024eb3bec77ba99622d8de14eef4 Mon Sep 17 00:00:00 2001 From: niklas Date: Mon, 24 Mar 2025 20:44:32 +0100 Subject: [PATCH] Added counter for payment confirment --- firmware/include/epaperdisplay.h | 1 + firmware/src/epaperdisplay.cpp | 28 ++++++++++++++++++++++++---- firmware/src/state.cpp | 16 ++++++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/firmware/include/epaperdisplay.h b/firmware/include/epaperdisplay.h index cd411c6..fcf4f44 100644 --- a/firmware/include/epaperdisplay.h +++ b/firmware/include/epaperdisplay.h @@ -53,6 +53,7 @@ class EpaperDisplay void updateText(const char* text, uint16_t x, uint16_t y); void updateText(const char* text, uint8_t textSize, uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor); void qrCode(const char* content, const char* sumValue); + void update_ok_counter(uint8_t ok_counter); }; diff --git a/firmware/src/epaperdisplay.cpp b/firmware/src/epaperdisplay.cpp index 81aca43..d76ceed 100644 --- a/firmware/src/epaperdisplay.cpp +++ b/firmware/src/epaperdisplay.cpp @@ -320,15 +320,35 @@ void EpaperDisplay::qrCode(const char* content, const char* sumValue) uint16_t radius_px = 5; epDisplay->drawRoundRect(qr.start_x - radius_px , qr.start_y - radius_px, qr.qr_size+(2*radius_px), qr.qr_size+(2*radius_px), radius_px, GxEPD_BLACK); - drawXCenteredText("Please scan the QR code!\n", 1, 10, GxEPD_BLACK, GxEPD_WHITE ); - drawXCenteredText("This will transfer the paid value to your wallet.\n", 1, 30, GxEPD_BLACK, GxEPD_WHITE ); - drawXCenteredText("Reset - press button\n", 1, epDisplay->height() - 20, GxEPD_BLACK, GxEPD_WHITE ); - + drawXCenteredText("Bitte scanne den QR-Code!\n", 1, 20, GxEPD_BLACK, GxEPD_WHITE ); + drawXCenteredText("Das Geld wird auf\n", 1, 40, GxEPD_BLACK, GxEPD_WHITE ); + drawXCenteredText("deine Wallet geladen.\n", 1, 60, GxEPD_BLACK, GxEPD_WHITE ); + drawXCenteredText("Gescannt? - Druecke 4 mal OK!", 1, epDisplay->height() - 20, GxEPD_BLACK, GxEPD_WHITE ); + /* code */ } while (epDisplay->nextPage()); epDisplay->hibernate(); } +void EpaperDisplay::update_ok_counter(uint8_t ok_counter) +{ + switch(ok_counter) + { + case 1: + updateText(" ",199,epDisplay->height() - 20); + updateText("3", 1, 199, epDisplay->height() - 20, GxEPD_BLACK, GxEPD_WHITE); + break; + case 2: + updateText(" ",199,epDisplay->height() - 20); + updateText("2",199,epDisplay->height() - 20); + break; + case 3: + updateText(" ",199,epDisplay->height() - 20); + updateText("1",199,epDisplay->height() - 20); + break; + } +} + void EpaperDisplay::cancelScreen() { diff --git a/firmware/src/state.cpp b/firmware/src/state.cpp index 1d47b08..97eae31 100644 --- a/firmware/src/state.cpp +++ b/firmware/src/state.cpp @@ -5,6 +5,7 @@ namespace { std::string lnurl_str = ""; bool update_value = false; + uint8_t ok_button_counter = 0; static atm::State current_state = atm::State::INIT; static atm::State next_state = atm::State::INIT; @@ -18,10 +19,11 @@ namespace atm { } void stateMachine(void) - { + { switch (current_state) { case INIT: update_value = false; + ok_button_counter = 0; ok_button.ledOff(); ok_button.reset(); cancel_button.ledOff(); @@ -77,10 +79,16 @@ namespace atm { ok_button.ledOff(); break; case PAYMENT_CONFIRMED: - if(ok_button.wasPressed()) + if (ok_button.wasPressed()) { - next_state = INIT; - ok_button.reset(); + ok_button_counter++; + if(ok_button_counter == 4) + { + next_state = INIT; + break; + } + epDisp.update_ok_counter(ok_button_counter); + ok_button.reset(); } break; case CANCEL_CONFIRMED: