Move defines to vars.h, show balance after transaction

This commit is contained in:
Laura Hausmann 2023-02-10 01:25:30 +01:00
parent e33448fed5
commit 82a677eacc
Signed by: zotan
GPG key ID: D044E84C5BE01605
2 changed files with 32 additions and 24 deletions

View file

@ -0,0 +1,25 @@
#pragma once
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
// this should be defined by our build script
#ifndef AFRAPAY_REVISION
#define AFRAPAY_REVISION "unknown"
#endif
//MFRC522 pinout (front) 3V3 RST GND IRQ MISO MOSI SCK SDA
//MFRC522 pinout (rear) SDA SCK MOSI MISO IRQ GND RST 3V3
#define PIN_HSPI_RST 4
#define PIN_HSPI_MISO 12
#define PIN_HSPI_MOSI 13
#define PIN_HSPI_SCLK 14
#define PIN_HSPI_SS 15
#define PIN_HWSERIAL_RX 16
#define PIN_HWSERIAL_TX 17
#define PIN_BUZZER 19
#define PIN_OLED_SDA 21
#define PIN_OLED_SCL 22
#define PIN_INTERRUPT_TRANSACT 26
#define PIN_INTERRUPT_BALANCE 25
#define PIN_INTERRUPT_LINK 33
#define PIN_INTERRUPT_CANCEL 32

View file

@ -16,30 +16,10 @@
#include "utils.h"
#include "oled.h"
#include "cardReader.h"
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
//MFRC522 pinout (front) 3V3 RST GND IRQ MISO MOSI SCK SDA
//MFRC522 pinout (rear) SDA SCK MOSI MISO IRQ GND RST 3V3
#define HSPI_RST 4
#define HSPI_MISO 12
#define HSPI_MOSI 13
#define HSPI_SCLK 14
#define HSPI_SS 15
#define PIN_HWSERIAL_RX 16
#define PIN_HWSERIAL_TX 17
#define PIN_BUZZER 19
#define PIN_OLED_SDA 21
#define PIN_OLED_SCL 22
#define PIN_INTERRUPT_TRANSACT 26
#define PIN_INTERRUPT_BALANCE 25
#define PIN_INTERRUPT_LINK 33
#define PIN_INTERRUPT_CANCEL 32
#include "vars.h"
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
MFRC522 mfrc522(HSPI_SS, HSPI_RST);
MFRC522 mfrc522(PIN_HSPI_SS, PIN_HSPI_RST);
WiFiClient *wifi = new WiFiClientFixed();
HTTPClient *http = new HTTPClient();
Rdm6300 rdm6300;
@ -105,7 +85,7 @@ void setup() {
u8g2.begin();
drawLogo(u8g2, LOGO_MATECARD);
u8g2.sendBuffer();
SPI.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI);
SPI.begin(PIN_HSPI_SCLK, PIN_HSPI_MISO, PIN_HSPI_MOSI);
SPIFFS.begin(true);
WiFiSettings.hostname = "afrapay-";
apiUrl = WiFiSettings.string("AfRApay.Web API", "http://192.168.50.170:5296");
@ -166,7 +146,6 @@ void loop() {
lastStatusText = cardTransaction(wifi, http, apiUrl, scannedCardId, "-150");
if (lastStatusText.startsWith("S:")) {
tone(PIN_BUZZER, NOTE_C7, 650);
lastStatusText += "";
state = STATE_RESULT_SUCCESS;
} else {
tone(PIN_BUZZER, NOTE_CS5, 100);
@ -239,6 +218,10 @@ void loop() {
lastStatusText = lastStatusText.substring(2);
timer = millis();
case STATE_RESULT_SUCCESS:
if (cooldownSecondsRemaining(gTimeout, timer) <= 4) {
lastStatusText = lastStatusText + ":Card #" + scannedCardId;
state = STATE_RESULT_DISPLAY;
}
case STATE_RESULT_FAILURE:
case STATE_RESULT_DISPLAY:
if (!cooldownCheck(gTimeout)) {