Added counter for payment confirment
This commit is contained in:
parent
c54a0c07cc
commit
203a59d8b9
3 changed files with 37 additions and 8 deletions
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue