Skeleton of state machine introduced, Screens created and logos added (init, home, payments, qrcode)
This commit is contained in:
parent
241540d060
commit
90b894a307
16 changed files with 1991 additions and 42 deletions
18
.vscode/c_cpp_properties.json
vendored
Normal file
18
.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "windows-gcc-x64",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"compilerPath": "c:/wingw64/bin/gcc.exe",
|
||||
"cStandard": "${default}",
|
||||
"cppStandard": "${default}",
|
||||
"intelliSenseMode": "windows-gcc-x64",
|
||||
"compilerArgs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
24
.vscode/launch.json
vendored
Normal file
24
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C/C++ Runner: Debug Session",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"cwd": "c:/Users/jnoack/Documents/SONSTIGE/GIT/Atm-Automat/firmware",
|
||||
"program": "c:/Users/jnoack/Documents/SONSTIGE/GIT/Atm-Automat/firmware/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "c:/wingw64/bin/gdb.exe",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
59
.vscode/settings.json
vendored
Normal file
59
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"C_Cpp_Runner.cCompilerPath": "c:/wingw64/bin/gcc.exe",
|
||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||
"C_Cpp_Runner.debuggerPath": "c:/wingw64/bin/gdb.exe",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "",
|
||||
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Wshadow",
|
||||
"-Wformat=2",
|
||||
"-Wcast-align",
|
||||
"-Wconversion",
|
||||
"-Wsign-conversion",
|
||||
"-Wnull-dereference"
|
||||
],
|
||||
"C_Cpp_Runner.msvcWarnings": [
|
||||
"/W4",
|
||||
"/permissive-",
|
||||
"/w14242",
|
||||
"/w14287",
|
||||
"/w14296",
|
||||
"/w14311",
|
||||
"/w14826",
|
||||
"/w44062",
|
||||
"/w44242",
|
||||
"/w14905",
|
||||
"/w14906",
|
||||
"/w14263",
|
||||
"/w44265",
|
||||
"/w14928"
|
||||
],
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.compilerArgs": [],
|
||||
"C_Cpp_Runner.linkerArgs": [],
|
||||
"C_Cpp_Runner.includePaths": [],
|
||||
"C_Cpp_Runner.includeSearch": [
|
||||
"*",
|
||||
"**/*"
|
||||
],
|
||||
"C_Cpp_Runner.excludeSearch": [
|
||||
"**/build",
|
||||
"**/build/**",
|
||||
"**/.*",
|
||||
"**/.*/**",
|
||||
"**/.vscode",
|
||||
"**/.vscode/**"
|
||||
],
|
||||
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||
"C_Cpp_Runner.showCompilationTime": false,
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
||||
}
|
BIN
Logos/logosATM.cdr
Normal file
BIN
Logos/logosATM.cdr
Normal file
Binary file not shown.
BIN
Logos/logosATM_BC_LN.png
Normal file
BIN
Logos/logosATM_BC_LN.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
Logos/logosATM_ML.png
Normal file
BIN
Logos/logosATM_ML.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
Logos/logosATM_ML_logo_land.png
Normal file
BIN
Logos/logosATM_ML_logo_land.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
Logos/logosATM_ML_logo_land_big.png
Normal file
BIN
Logos/logosATM_ML_logo_land_big.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
Logos/logosATM_ML_logo_only.png
Normal file
BIN
Logos/logosATM_ML_logo_only.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
Logos/logosATM_hand.png
Normal file
BIN
Logos/logosATM_hand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,13 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
typedef enum {
|
||||
INIT,
|
||||
WAIT_FOR_COIN,
|
||||
PROCESS_COIN,
|
||||
GENERATE_QR,
|
||||
PAYMENT_CONFIRMED,
|
||||
ERROR_STATE
|
||||
} State;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,6 +51,7 @@ bool AtmButton::iswaitingUntilPressed(unsigned long maxTimeToWaitMs, unsigned lo
|
|||
{
|
||||
/* will return as longs as waiting until the button is pressed */
|
||||
/* if blinkPeriodMs is 0 - there is no LED blinking */
|
||||
/* if maxTimeToWaitMs is 0 - there is no time out and wait is until button was pressed */
|
||||
unsigned long currentMs = millis();
|
||||
|
||||
if(false == activeWaiting)
|
||||
|
@ -62,7 +63,7 @@ bool AtmButton::iswaitingUntilPressed(unsigned long maxTimeToWaitMs, unsigned lo
|
|||
ledOn();
|
||||
}
|
||||
|
||||
if( (true == pressed) || ((currentMs - startWaitTime) >= maxTimeToWaitMs))
|
||||
if( (true == pressed) || ((maxTimeToWaitMs > 0) && ((currentMs - startWaitTime) >= maxTimeToWaitMs)) )
|
||||
{
|
||||
ledOff();
|
||||
activeWaiting = false;
|
||||
|
|
|
@ -31,9 +31,42 @@ void EpaperDisplay::init()
|
|||
#endif
|
||||
|
||||
epDisplay->setRotation(1);
|
||||
setTextFont(1);
|
||||
|
||||
}
|
||||
|
||||
void EpaperDisplay::setTextFont(uint8_t size)
|
||||
{
|
||||
switch(size){
|
||||
case 0:
|
||||
/* provide text size of 0 to keep a set font as it is*/
|
||||
break;
|
||||
case 1:
|
||||
epDisplay->setTextSize(1);
|
||||
epDisplay->setFont(&FreeSans9pt7b);
|
||||
break;
|
||||
case 2:
|
||||
epDisplay->setTextSize(1);
|
||||
epDisplay->setFont(&FreeSans12pt7b);
|
||||
break;
|
||||
case 3:
|
||||
epDisplay->setTextSize(1);
|
||||
epDisplay->setFont(&FreeSans18pt7b);
|
||||
break;
|
||||
case 4:
|
||||
epDisplay->setTextSize(1);
|
||||
epDisplay->setFont(&FreeSans24pt7b);
|
||||
break;
|
||||
// case 5:
|
||||
// epDisplay->setTextSize(1);
|
||||
// epDisplay->setFont(&FreeMonoBoldOblique24pt7b);
|
||||
// break;
|
||||
default:
|
||||
epDisplay->setTextSize(1);
|
||||
epDisplay->setFont(&FreeSans9pt7b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EpaperDisplay::cleanScreen()
|
||||
{
|
||||
|
@ -59,26 +92,57 @@ uint16_t EpaperDisplay::xCenterText(const char* text)
|
|||
return xul;
|
||||
}
|
||||
|
||||
uint16_t EpaperDisplay::yCenterText(const char* text)
|
||||
{
|
||||
int16_t xul, yul;
|
||||
uint16_t textWidth, textHeight;
|
||||
epDisplay->getTextBounds(text, 0, 0, &xul, &yul, &textWidth, &textHeight);
|
||||
yul = (epDisplay->height() - textHeight)/2;
|
||||
if(yul < 0 )
|
||||
{
|
||||
yul = 0;
|
||||
}
|
||||
return yul;
|
||||
}
|
||||
|
||||
void EpaperDisplay::drawText(const char* text, uint16_t x, uint16_t y)
|
||||
{
|
||||
epDisplay->setCursor(x, y);
|
||||
epDisplay->printf(text);
|
||||
epDisplay->printf(text);
|
||||
}
|
||||
|
||||
void EpaperDisplay::drawText(const char* text, uint8_t textSize, uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor )
|
||||
{
|
||||
epDisplay->setTextSize(textSize);
|
||||
//epDisplay->setTextSize(textSize);
|
||||
setTextFont(textSize);
|
||||
epDisplay->setTextColor(fgColor, bgColor);
|
||||
drawText(text, x, y);
|
||||
}
|
||||
|
||||
void EpaperDisplay::drawXCenteredText(const char* text, uint8_t textSize, uint16_t y, uint16_t fgColor, uint16_t bgColor )
|
||||
{
|
||||
epDisplay->setTextSize(textSize);
|
||||
//epDisplay->setTextSize(textSize);
|
||||
setTextFont(textSize);
|
||||
epDisplay->setTextColor(fgColor, bgColor);
|
||||
drawText(text, xCenterText(text), y);
|
||||
}
|
||||
|
||||
void EpaperDisplay::drawYCenteredText(const char* text, uint8_t textSize, uint16_t x, uint16_t fgColor, uint16_t bgColor )
|
||||
{
|
||||
//epDisplay->setTextSize(textSize);
|
||||
setTextFont(textSize);
|
||||
epDisplay->setTextColor(fgColor, bgColor);
|
||||
drawText(text, x, yCenterText(text));
|
||||
}
|
||||
|
||||
void EpaperDisplay::drawCenteredText(const char* text, uint8_t textSize, uint16_t fgColor, uint16_t bgColor )
|
||||
{
|
||||
//epDisplay->setTextSize(textSize);
|
||||
setTextFont(textSize);
|
||||
epDisplay->setTextColor(fgColor, bgColor);
|
||||
drawText(text, xCenterText(text), yCenterText(text));
|
||||
}
|
||||
|
||||
void EpaperDisplay::updateText(const char* text, uint16_t x, uint16_t y)
|
||||
{
|
||||
int16_t xul, yul;
|
||||
|
@ -95,34 +159,107 @@ void EpaperDisplay::updateText(const char* text, uint16_t x, uint16_t y)
|
|||
|
||||
void EpaperDisplay::updateText(const char* text, uint8_t textSize, uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor)
|
||||
{
|
||||
epDisplay->setTextSize(textSize);
|
||||
//epDisplay->setTextSize(textSize);
|
||||
setTextFont(textSize);
|
||||
epDisplay->setTextColor(fgColor, bgColor);
|
||||
updateText(text, x, y);
|
||||
}
|
||||
|
||||
|
||||
void EpaperDisplay::homeScreen()
|
||||
{
|
||||
|
||||
void EpaperDisplay::initScreen()
|
||||
{
|
||||
uint16_t y = 360;
|
||||
epDisplay->setFullWindow();
|
||||
epDisplay->firstPage();
|
||||
do
|
||||
{
|
||||
drawText("Insert Euro coins\n on the right ->\n to start ATM\n", 2, 11, 20, GxEPD_BLACK, GxEPD_WHITE);
|
||||
epDisplay->drawBitmap(172, 65, bitcoin_logo, 64, 64, GxEPD_BLACK);
|
||||
drawText("Prepare Lightning enabled Bitcoin\n wallet before starting!\n Supported coins: 1 - 50 Cent, 1 - 2 Euro\n", 1, 12, 140, GxEPD_BLACK, GxEPD_WHITE);
|
||||
epDisplay->fillRect(0,0,epDisplay->width(), y - 50, GxEPD_BLACK);
|
||||
epDisplay->drawBitmap(25, 30, epd_bitmap_makerlablogosATM_ML, 250, 250, GxEPD_WHITE);
|
||||
|
||||
//epDisplay->drawFastHLine(20,y-50,epDisplay->width()-40, GxEPD_BLACK);
|
||||
drawXCenteredText("Initialisierung ATM ...\n",2, y-20, GxEPD_BLACK,GxEPD_WHITE);
|
||||
//epDisplay->drawFastHLine(20,y,epDisplay->width()-40, GxEPD_BLACK);
|
||||
|
||||
epDisplay->fillRect(0,epDisplay->height()-40,epDisplay->width(), 40, GxEPD_BLACK);
|
||||
drawXCenteredText("Zum Fortfahren Taster druecken!\n",1, epDisplay->height()-12, GxEPD_WHITE, GxEPD_BLACK);
|
||||
} while (epDisplay->nextPage());
|
||||
epDisplay->hibernate();
|
||||
}
|
||||
|
||||
void EpaperDisplay::showInsertedAmount(const char* amount_in_euro)
|
||||
void EpaperDisplay::homeScreen()
|
||||
{
|
||||
uint16_t y = 0;
|
||||
epDisplay->setFullWindow();
|
||||
epDisplay->firstPage();
|
||||
do
|
||||
{
|
||||
drawText("Inserted amount:\n", 2, 11, 10, GxEPD_BLACK, GxEPD_WHITE);
|
||||
drawText(amount_in_euro, 3, 20, 75, GxEPD_BLACK, GxEPD_WHITE);
|
||||
drawText("Press button\n once finished.\n", 2, 11, 135, GxEPD_BLACK, GxEPD_WHITE);
|
||||
y = 0;
|
||||
epDisplay->fillRect(0,y,epDisplay->width(), 50, GxEPD_BLACK);
|
||||
drawXCenteredText("Belade deine MakerLab\n", 1, y+20, GxEPD_WHITE, GxEPD_BLACK);
|
||||
drawXCenteredText("Lightning Wallet hier!\n", 1, y+40, GxEPD_WHITE, GxEPD_BLACK);
|
||||
|
||||
y = 210;
|
||||
epDisplay->drawFastHLine(10,y,epDisplay->width()-20, GxEPD_BLACK);
|
||||
drawXCenteredText("Bitte Muenzen einwerfen!\n", 2, y + 25, GxEPD_BLACK, GxEPD_WHITE);
|
||||
epDisplay->drawFastHLine(10,y+35,epDisplay->width()-20, GxEPD_BLACK);
|
||||
|
||||
y = 20;
|
||||
epDisplay->drawBitmap(50, y, epd_bitmap_makerlablogosATM_hand, 280,197,GxEPD_BLACK);
|
||||
//drawXCenteredText("Betriebsbereit!\n", 3, 100, GxEPD_BLACK, GxEPD_BLACK);
|
||||
|
||||
y = 270;
|
||||
drawXCenteredText("1, 2, 5, 10, 20, 50 Cent,\n", 1, y, GxEPD_BLACK, GxEPD_WHITE);
|
||||
drawXCenteredText("1 oder 2 Euro Muenzen.\n", 1, y+20, GxEPD_BLACK, GxEPD_WHITE);
|
||||
|
||||
y = 310;
|
||||
epDisplay->fillRect(0,y,epDisplay->width(), epDisplay->height()-y, GxEPD_BLACK);
|
||||
epDisplay->drawBitmap(1, y+10, epd_bitmap_makerlablogosATM_ML_logo_land, 248, 69, GxEPD_WHITE);
|
||||
epDisplay->drawBitmap(220, y+10, epd_bitmap_makerlablogosATM_BC_LN, 73, 64, GxEPD_WHITE);
|
||||
|
||||
epDisplay->drawRoundRect(5, 55, epDisplay->width()-10, 250, 5, GxEPD_BLACK);
|
||||
|
||||
} while (epDisplay->nextPage());
|
||||
}
|
||||
|
||||
void EpaperDisplay::showInsertedAmount(const char* amount_in_euro)
|
||||
{
|
||||
|
||||
uint16_t y = 0;
|
||||
epDisplay->setFullWindow();
|
||||
epDisplay->firstPage();
|
||||
do
|
||||
{
|
||||
y = 0;
|
||||
epDisplay->fillRect(0,y,epDisplay->width(), 50, GxEPD_BLACK);
|
||||
drawXCenteredText("Druecke den Taster, um die\n", 1, y+20, GxEPD_WHITE, GxEPD_BLACK);
|
||||
drawXCenteredText("Einzahlung abzuschliessen!\n", 1, y+40, GxEPD_WHITE, GxEPD_BLACK);
|
||||
|
||||
y = 180;
|
||||
epDisplay->setFont();
|
||||
epDisplay->setTextSize(1);
|
||||
drawXCenteredText("Aktueller Einzahlbetrag in Euro:\n", 0, 70, GxEPD_BLACK, GxEPD_WHITE);
|
||||
epDisplay->setTextSize(9);
|
||||
drawXCenteredText(amount_in_euro, 0, y - 75, GxEPD_BLACK, GxEPD_WHITE);
|
||||
//epDisplay->drawFastHLine(10,y,epDisplay->width()-20, GxEPD_BLACK);
|
||||
epDisplay->setTextSize(1);
|
||||
drawXCenteredText("Maximaler Betrag: 10,00 Euro.\n", 0, y + 25, GxEPD_BLACK, GxEPD_WHITE);
|
||||
epDisplay->drawFastHLine(10,y+50,epDisplay->width()-20, GxEPD_BLACK);
|
||||
|
||||
y = 250;
|
||||
epDisplay->setFont();
|
||||
epDisplay->setTextSize(1);
|
||||
drawText("1ct 2ct 5ct 10ct 20ct 50ct 1Eur 2Eur\n", 0, 20, y, GxEPD_BLACK, GxEPD_WHITE);
|
||||
|
||||
drawText(" 0 0 0 0 0 0 0 0 \n", 0, 20, y+20, GxEPD_BLACK, GxEPD_WHITE);
|
||||
|
||||
y = 310;
|
||||
epDisplay->fillRect(0,y,epDisplay->width(), epDisplay->height()-y, GxEPD_BLACK);
|
||||
epDisplay->drawBitmap(1, y+10, epd_bitmap_makerlablogosATM_ML_logo_land, 248, 69, GxEPD_WHITE);
|
||||
epDisplay->drawBitmap(220, y+10, epd_bitmap_makerlablogosATM_BC_LN, 73, 64, GxEPD_WHITE);
|
||||
|
||||
epDisplay->drawRoundRect(5, 55, epDisplay->width()-10, 250, 5, GxEPD_BLACK);
|
||||
|
||||
} while (epDisplay->nextPage());
|
||||
}
|
||||
|
||||
|
@ -172,9 +309,9 @@ void EpaperDisplay::qrCode(const char* content)
|
|||
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", 2, 10, GxEPD_BLACK, GxEPD_WHITE );
|
||||
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", 2, epDisplay->height() - 20, GxEPD_BLACK, GxEPD_WHITE );
|
||||
drawXCenteredText("Reset - press button\n", 1, epDisplay->height() - 20, GxEPD_BLACK, GxEPD_WHITE );
|
||||
|
||||
/* code */
|
||||
} while (epDisplay->nextPage());
|
||||
|
|
|
@ -8,11 +8,11 @@ const char* FIATCURRENCY = "EUR";
|
|||
|
||||
Lnurl::SignerConfig getLnurlSignerConfig() {
|
||||
struct Lnurl::SignerConfig lnurl;
|
||||
lnurl.apiKey.id = "86f6d045d26e4e39";
|
||||
lnurl.apiKey.key = "b2ff678c2c634868b70bf678948e92c4382b1e8f7c651bd648b0caefd5cca613";
|
||||
lnurl.apiKey.encoding = "hex";
|
||||
lnurl.callbackUrl = "https://lnbits.makerlab-murnau.de/bleskomat/u";
|
||||
lnurl.shorten = true;
|
||||
lnurl.apiKey.id = APIKEY_ID;
|
||||
lnurl.apiKey.key = APIKEY_KEY;
|
||||
lnurl.apiKey.encoding = APIKEY_ENCODING;
|
||||
lnurl.callbackUrl = CALLBACK_URL;
|
||||
lnurl.shorten = SHORTEN;
|
||||
return lnurl;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,34 +10,81 @@ EpaperDisplay epDisp(DSPLY_PIN_CS, DSPLY_PIN_DC, DSPLY_PIN_RST, DSPLY_PIN_BUSY);
|
|||
AtmButton button(BUTTON_PIN, LED_BUTTON_PIN);
|
||||
CoinAcceptor cacc(COIN_PIN, MOSFET_PIN, COINS, COINS_COUNT, COIN_PULSE_WIDTH_MS);
|
||||
|
||||
static State current_state = INIT;
|
||||
static State next_state = INIT;
|
||||
|
||||
std::string lnurl_str = "";
|
||||
|
||||
void init_atm();
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
cacc.begin();
|
||||
button.begin();
|
||||
epDisp.init();
|
||||
std::string lnurl = lnurlutil::createQrContent(0.05);
|
||||
epDisp.qrCode(lnurl.c_str());
|
||||
while(0==0)
|
||||
{delay(1000);}
|
||||
epDisp.init(); // Init eInk display
|
||||
|
||||
epDisp.homeScreen();
|
||||
epDisp.initScreen();
|
||||
|
||||
while(0 == 0)
|
||||
{
|
||||
Serial.println("Insert coin please.");
|
||||
cacc.enable();
|
||||
do
|
||||
{
|
||||
} while (false == cacc.detectCoin());
|
||||
delay(1000);
|
||||
}
|
||||
cacc.begin(); // Init Coin acceptor
|
||||
cacc.disable(); // Disable coin detection
|
||||
button.begin(); // Init button
|
||||
button.wasPressed(); // Reset button - if already pressed
|
||||
|
||||
while( true == button.iswaitingUntilPressed(/* maxTimeToWaitMs0= */ 0, /* blinkPeriodMs= */ 1000))
|
||||
{}
|
||||
|
||||
while(0==0)
|
||||
{delay(1000);}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
switch (current_state) {
|
||||
case INIT:
|
||||
init_atm();
|
||||
button.wasPressed();
|
||||
next_state = WAIT_FOR_COIN;
|
||||
break;
|
||||
case WAIT_FOR_COIN:
|
||||
if(button.wasPressed())
|
||||
{
|
||||
epDisp.showInsertedAmount("10,00");
|
||||
button.wasPressed();
|
||||
next_state = PROCESS_COIN;
|
||||
}
|
||||
break;
|
||||
case PROCESS_COIN:
|
||||
//update coin ammount until OK or CANCEL button is pressed
|
||||
if(button.wasPressed())
|
||||
{
|
||||
next_state = GENERATE_QR;
|
||||
button.wasPressed();
|
||||
}
|
||||
break;
|
||||
|
||||
case GENERATE_QR:
|
||||
lnurl_str = lnurlutil::createQrContent(0.05);
|
||||
epDisp.qrCode(lnurl_str.c_str());
|
||||
next_state = PAYMENT_CONFIRMED;
|
||||
button.wasPressed();
|
||||
break;
|
||||
case PAYMENT_CONFIRMED:
|
||||
if(button.wasPressed())
|
||||
{
|
||||
next_state = INIT;
|
||||
button.wasPressed();
|
||||
}
|
||||
break;
|
||||
|
||||
case ERROR_STATE:
|
||||
next_state = WAIT_FOR_COIN;
|
||||
break;
|
||||
}
|
||||
|
||||
current_state = next_state;
|
||||
}
|
||||
|
||||
void init_atm()
|
||||
{
|
||||
button.ledOff();
|
||||
epDisp.homeScreen();
|
||||
cacc.enable();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue