Japan mode
This commit is contained in:
parent
58d04bbed7
commit
70c3499e02
|
@ -17,7 +17,7 @@ public:
|
|||
explicit OLED(U8G2 u8g2);
|
||||
void begin();
|
||||
void drawLogo(e_logo logo);
|
||||
void drawStatusText(const String& status, const String& statusRightAligned = "");
|
||||
void updateOLED(e_state state, const String& statusText, const String& statusTextRightAligned = "");
|
||||
void drawStatusText(const String& status, const String& statusRightAligned = "", bool japan = false);
|
||||
void updateOLED(e_state state, const String& statusText, const String& statusTextRightAligned = "", bool japan = false);
|
||||
void updateOLED(e_state state);
|
||||
};
|
||||
|
|
|
@ -52,27 +52,51 @@ void IRAM_ATTR FeliCaInterruptHandler() {
|
|||
}
|
||||
|
||||
void IRAM_ATTR TransactInterruptHandler() {
|
||||
if (interruptFired || state != STATE_IDLE || digitalRead(PIN_INTERRUPT_TRANSACT)) {
|
||||
if (interruptFired || digitalRead(PIN_INTERRUPT_TRANSACT)) {
|
||||
return;
|
||||
}
|
||||
if (state == STATE_IDLE) {
|
||||
interruptFired = true;
|
||||
state = STATE_TRANSACT_CARDSCAN;
|
||||
}
|
||||
else if (state == STATE_TRANSACT_CARDSCAN) {
|
||||
PN532Reader::toggleMode = true;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
interruptFired = true;
|
||||
state = STATE_TRANSACT_CARDSCAN;
|
||||
}
|
||||
|
||||
void IRAM_ATTR LinkInterruptHandler() {
|
||||
if (interruptFired || state != STATE_IDLE || digitalRead(PIN_INTERRUPT_LINK)) {
|
||||
if (interruptFired || digitalRead(PIN_INTERRUPT_LINK)) {
|
||||
return;
|
||||
}
|
||||
if (state == STATE_IDLE) {
|
||||
interruptFired = true;
|
||||
state = STATE_LINK_CARD_SCAN;
|
||||
}
|
||||
else if (state == STATE_LINK_CARD_SCAN) {
|
||||
PN532Reader::toggleMode = true;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
interruptFired = true;
|
||||
state = STATE_LINK_CARD_SCAN;
|
||||
}
|
||||
|
||||
void IRAM_ATTR BalanceInterruptHandler() {
|
||||
if (interruptFired || state != STATE_IDLE || digitalRead(PIN_INTERRUPT_BALANCE)) {
|
||||
if (interruptFired || digitalRead(PIN_INTERRUPT_BALANCE)) {
|
||||
return;
|
||||
}
|
||||
if (state == STATE_IDLE) {
|
||||
interruptFired = true;
|
||||
state = STATE_BALANCE_CARDSCAN;
|
||||
}
|
||||
else if (state == STATE_BALANCE_CARDSCAN) {
|
||||
PN532Reader::toggleMode = true;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
interruptFired = true;
|
||||
state = STATE_BALANCE_CARDSCAN;
|
||||
}
|
||||
|
||||
void IRAM_ATTR CancelInterruptHandler() {
|
||||
|
@ -182,6 +206,9 @@ void loop() {
|
|||
|
||||
switch (state) {
|
||||
case STATE_IDLE:
|
||||
if (PN532Reader::mode != PN532_MIFARE_ISO14443A)
|
||||
PN532Reader::mode = PN532_MIFARE_ISO14443A;
|
||||
|
||||
oled.updateOLED(state);
|
||||
break;
|
||||
case STATE_TRANSACT_CARDSCAN:
|
||||
|
@ -195,7 +222,10 @@ void loop() {
|
|||
}
|
||||
}
|
||||
if (!cooldownCheck(scanTimeout)) {
|
||||
oled.updateOLED(state, String("1.50€"), String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
if (PN532Reader::mode == PN532_MIFARE_ISO14443A)
|
||||
oled.updateOLED(state, String("1.50€"), String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
else
|
||||
oled.updateOLED(state, String("¥150"), String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
}
|
||||
break;
|
||||
case STATE_TRANSACT_VERIFY:
|
||||
|
@ -234,7 +264,10 @@ void loop() {
|
|||
}
|
||||
}
|
||||
if (!cooldownCheck(scanTimeout)) {
|
||||
oled.updateOLED(state, "Link", String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
if (PN532Reader::mode == PN532_MIFARE_ISO14443A)
|
||||
oled.updateOLED(state, "Link", String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
else
|
||||
oled.updateOLED(state, "リンク", String(cooldownSecondsRemaining(scanTimeout, timer)), true);
|
||||
}
|
||||
break;
|
||||
case STATE_LINK_CARD_RESCAN:
|
||||
|
@ -252,7 +285,10 @@ void loop() {
|
|||
}
|
||||
}
|
||||
if (!cooldownCheck(scanTimeout)) {
|
||||
oled.updateOLED(state, "Link - rescan ", String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
if (PN532Reader::mode == PN532_MIFARE_ISO14443A)
|
||||
oled.updateOLED(state, "Link - rescan ", String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
else
|
||||
oled.updateOLED(state, "リンク - rescan ", String(cooldownSecondsRemaining(scanTimeout, timer)), true);
|
||||
}
|
||||
break;
|
||||
case STATE_LINK_VERIFY:
|
||||
|
@ -284,7 +320,10 @@ void loop() {
|
|||
}
|
||||
}
|
||||
if (!cooldownCheck(scanTimeout)) {
|
||||
oled.updateOLED(state, "Balance", String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
if (PN532Reader::mode == PN532_MIFARE_ISO14443A)
|
||||
oled.updateOLED(state, "Balance", String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
else
|
||||
oled.updateOLED(state, "残高", String(cooldownSecondsRemaining(scanTimeout, timer)), true);
|
||||
}
|
||||
break;
|
||||
case STATE_BALANCE_VERIFY:
|
||||
|
|
|
@ -106,11 +106,18 @@ void OLED::drawLogo(e_logo logo) {
|
|||
}
|
||||
}
|
||||
|
||||
void OLED::drawStatusText(const String& status, const String& statusRightAligned) {
|
||||
u8g2.setFont(u8g2_font_bpixel_te);
|
||||
void OLED::drawStatusText(const String& status, const String& statusRightAligned, bool japan) {
|
||||
if (japan)
|
||||
u8g2.setFont(u8g2_font_b12_t_japanese2);
|
||||
else
|
||||
u8g2.setFont(u8g2_font_bpixel_te);
|
||||
|
||||
u8g2.drawUTF8(0, 61, status.c_str());
|
||||
|
||||
if (!statusRightAligned.isEmpty()) {
|
||||
if (japan)
|
||||
u8g2.setFont(u8g2_font_bpixel_te);
|
||||
|
||||
int textWidth = u8g2.getUTF8Width(statusRightAligned.c_str());
|
||||
u8g2.drawUTF8(126 - textWidth, 61, statusRightAligned.c_str());
|
||||
}
|
||||
|
@ -123,7 +130,7 @@ void OLED::drawFullScreenText(const String& textTop, const String& textBottom) {
|
|||
u8g2.drawUTF8((127-u8g2.getUTF8Width(textBottom.c_str()))/2, 45, textBottom.c_str());
|
||||
}
|
||||
|
||||
void OLED::updateOLED(e_state state, const String& statusText, const String& statusTextRightAligned) {
|
||||
void OLED::updateOLED(e_state state, const String& statusText, const String& statusTextRightAligned, bool japan) {
|
||||
u8g2.clearBuffer();
|
||||
|
||||
switch (state) {
|
||||
|
@ -157,7 +164,7 @@ void OLED::updateOLED(e_state state, const String& statusText, const String& sta
|
|||
break;
|
||||
}
|
||||
|
||||
drawStatusText(statusText, statusTextRightAligned);
|
||||
drawStatusText(statusText, statusTextRightAligned, japan);
|
||||
u8g2.sendBuffer();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ PN532Reader::PN532Reader(uint8_t ss) {
|
|||
}
|
||||
|
||||
void PN532Reader::begin() {
|
||||
timer = millis();
|
||||
pn532->begin();
|
||||
irq = 0;
|
||||
mode = PN532_MIFARE_ISO14443A;
|
||||
|
@ -51,7 +52,7 @@ bool PN532Reader::isNewCardPresent() {
|
|||
return true;
|
||||
|
||||
if (toggleMode) {
|
||||
if (millis() - timer > 500) {
|
||||
if (millis() - timer > 250) {
|
||||
cycleMode();
|
||||
timer = millis();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue