Merge branch 'develop'

This commit is contained in:
GOB
2026-05-14 15:24:21 +09:00
30 changed files with 482 additions and 493 deletions
+8 -5
View File
@@ -9,14 +9,17 @@
This example is shared with M5Unit-RFID This example is shared with M5Unit-RFID
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#include "main/Detect.cpp" #include "main/Detect.cpp"
@@ -13,22 +13,24 @@
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h> #include <Wire.h>
#include <M5HAL.hpp> // For NessoN1
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#if defined(USING_UNIT_RFID2) #if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#include <M5UnitUnifiedRFID.h> #include <M5UnitUnifiedRFID.h>
#endif #endif
@@ -46,9 +48,12 @@ m5::unit::UnitNFC unit{}; // I2C
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI) m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
#elif defined(USING_UNIT_RFID2) #elif defined(USING_UNIT_RFID2)
#pragma message "Choose UnitRFID2" #pragma message "Choose UnitRFID2"
m5::unit::UnitRFID2 unit{}; // UnitRFID2 (M5Unit-RFID) m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C)
#else #else
#error Choose unit please! #error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
m5::nfc::NFCLayerA nfc_a{unit}; m5::nfc::NFCLayerA nfc_a{unit};
} // namespace } // namespace
@@ -63,25 +68,26 @@ void setup()
lcd.setRotation(1); lcd.setRotation(1);
} }
#if defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port.
// Wire is used by M5Unified In_I2C for internal devices.
// Reconfiguring Wire to GROVE pins breaks In_I2C.
// Solution: Use SoftwareI2C via M5HAL (bit-banging) for the GROVE port.
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on the same I2C_NUM_0.
// Solution: Use M5.Ex_I2C directly instead of Arduino Wire.
auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
#if defined(USING_M5DIAL_BUILTIN_WS1850S) #if defined(USING_M5DIAL_BUILTIN_WS1850S)
// M5Dial builtin WS1850S: small loop antenna; reduce RxGain to 33dB to mitigate
// reflection interference (default 48dB causes unstable WUPA on Builtin).
{
auto cfg = unit.config();
cfg.receiver_gain = m5::unit::mfrc522::ReceiverGain::dB33;
unit.config(cfg);
}
// M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563) // M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563)
M5_LOGI("Using M5.In_I2C for builtin WS1850S"); M5_LOGI("Using M5.In_I2C for builtin WS1850S");
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
#else
// NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register #elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// polling latency too high for MFRC522/WS1850S RF timing requirements. // External I2C unit (GROVE port).
// Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable) // NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
if (board == m5::board_t::board_M5NanoC6) { // Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
// NanoC6: Use M5.Ex_I2C (m5::I2C_Class, not Arduino Wire) // NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
} else { } else {
@@ -92,14 +98,7 @@ void setup()
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
unit_ready = Units.add(unit, Wire) && Units.begin(); unit_ready = Units.add(unit, Wire) && Units.begin();
} }
#endif // USING_M5DIAL_BUILTIN_WS1850S
if (!unit_ready) {
M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
if (!SPI.bus()) { if (!SPI.bus()) {
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk); auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
@@ -108,16 +107,17 @@ void setup()
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso); M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */); SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
} }
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1}; SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
if (!Units.add(unit, SPI, settings) || !Units.begin()) { unit_ready = Units.add(unit, SPI, settings) && Units.begin();
#endif
if (!unit_ready) {
M5_LOGE("Failed to begin"); M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED); lcd.fillScreen(TFT_RED);
while (true) { while (true) {
m5::utility::delay(10000); m5::utility::delay(10000);
} }
} }
#endif
M5_LOGI("M5UnitUnified initialized"); M5_LOGI("M5UnitUnified initialized");
M5_LOGI("%s", Units.debugInfo().c_str()); M5_LOGI("%s", Units.debugInfo().c_str());
+8 -5
View File
@@ -9,14 +9,17 @@
This example is shared with M5Unit-RFID This example is shared with M5Unit-RFID
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#include "main/Dump.cpp" #include "main/Dump.cpp"
+34 -27
View File
@@ -13,22 +13,24 @@
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h> #include <Wire.h>
#include <M5HAL.hpp> // For NessoN1
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#if defined(USING_UNIT_RFID2) #if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#include <M5UnitUnifiedRFID.h> #include <M5UnitUnifiedRFID.h>
#endif #endif
@@ -48,9 +50,12 @@ m5::unit::UnitNFC unit{}; // I2C
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI) m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
#elif defined(USING_UNIT_RFID2) #elif defined(USING_UNIT_RFID2)
#pragma message "Choose UnitRFID2" #pragma message "Choose UnitRFID2"
m5::unit::UnitRFID2 unit{}; // UnitRFID2 (M5Unit-RFID) m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C)
#else #else
#error Choose unit please! #error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
m5::nfc::NFCLayerA nfc_a{unit}; m5::nfc::NFCLayerA nfc_a{unit};
@@ -69,18 +74,26 @@ void setup()
lcd.setRotation(1); lcd.setRotation(1);
} }
#if defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
#if defined(USING_M5DIAL_BUILTIN_WS1850S) #if defined(USING_M5DIAL_BUILTIN_WS1850S)
// M5Dial builtin WS1850S: small loop antenna; reduce RxGain to 33dB to mitigate
// reflection interference (default 48dB causes unstable WUPA on Builtin).
{
auto cfg = unit.config();
cfg.receiver_gain = m5::unit::mfrc522::ReceiverGain::dB33;
unit.config(cfg);
}
// M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563) // M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563)
M5_LOGI("Using M5.In_I2C for builtin WS1850S"); M5_LOGI("Using M5.In_I2C for builtin WS1850S");
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
#else
// NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register #elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// polling latency too high for MFRC522/WS1850S RF timing requirements. // External I2C unit (GROVE port).
// Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable) // NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
if (board == m5::board_t::board_M5NanoC6) { // Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
} else { } else {
@@ -91,14 +104,7 @@ void setup()
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
unit_ready = Units.add(unit, Wire) && Units.begin(); unit_ready = Units.add(unit, Wire) && Units.begin();
} }
#endif // USING_M5DIAL_BUILTIN_WS1850S
if (!unit_ready) {
M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
if (!SPI.bus()) { if (!SPI.bus()) {
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk); auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
@@ -107,16 +113,17 @@ void setup()
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso); M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */); SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
} }
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1}; SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
if (!Units.add(unit, SPI, settings) || !Units.begin()) { unit_ready = Units.add(unit, SPI, settings) && Units.begin();
#endif
if (!unit_ready) {
M5_LOGE("Failed to begin"); M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED); lcd.fillScreen(TFT_RED);
while (true) { while (true) {
m5::utility::delay(10000); m5::utility::delay(10000);
} }
} }
#endif
M5_LOGI("M5UnitUnified initialized"); M5_LOGI("M5UnitUnified initialized");
M5_LOGI("%s", Units.debugInfo().c_str()); M5_LOGI("%s", Units.debugInfo().c_str());
@@ -8,12 +8,14 @@
NFC-A Emulation mode NFC-A Emulation mode
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit you are using
// NOTE: Emulation is supported ONLY on UnitNFC (ST25R3916) and CapCC1101NFC (ST25R3916).
// UnitRFID2 (WS1850S) and M5Dial Builtin (WS1850S) do NOT support emulation.
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101)
// For UnitNFC // For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
#endif #endif
#include "main/Emulation.cpp" #include "main/Emulation.cpp"
@@ -12,20 +12,21 @@
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h> #include <Wire.h>
#include <M5HAL.hpp> // For NessoN1
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit you are using
// NOTE: Emulation is supported ONLY on UnitNFC (ST25R3916) and CapCC1101NFC (ST25R3916).
// UnitRFID2 (WS1850S) and M5Dial Builtin (WS1850S) do NOT support emulation.
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101)
// For UnitNFC // For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
#endif #endif
#if defined(USING_UNIT_RFID2) #if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#error UnitRFID2 does NOT support emulation #error Emulation is NOT supported on UnitRFID2 / M5Dial Builtin (WS1850S). Use UnitNFC or CapCC1101NFC.
#endif #endif
using namespace m5::nfc; using namespace m5::nfc;
@@ -177,7 +178,7 @@ void setup()
auto board = M5.getBoard(); auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
// NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register // NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register
// polling latency too high for MFRC522/WS1850S RF timing requirements. // polling latency too high for ST25R3916 RF timing requirements.
// Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable) // Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable)
if (board == m5::board_t::board_M5NanoC6) { if (board == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
+8 -5
View File
@@ -9,14 +9,17 @@
This example is shared with M5Unit-RFID This example is shared with M5Unit-RFID
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#include "main/NDEF.cpp" #include "main/NDEF.cpp"
+38 -31
View File
@@ -13,23 +13,25 @@
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h> #include <Wire.h>
#include <M5HAL.hpp> // For NessoN1
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#if defined(USING_UNIT_RFID2) #if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#include <M5UnitUnifiedRFID.h> #include <M5UnitUnifiedRFID.h>
#endif #endif
@@ -50,9 +52,12 @@ m5::unit::UnitNFC unit{}; // I2C
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI) m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
#elif defined(USING_UNIT_RFID2) #elif defined(USING_UNIT_RFID2)
#pragma message "Choose UnitRFID2" #pragma message "Choose UnitRFID2"
m5::unit::UnitRFID2 unit{}; // UnitRFID2 (M5Unit-RFID) m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C)
#else #else
#error Choose unit please! #error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
m5::nfc::NFCLayerA nfc_a{unit}; m5::nfc::NFCLayerA nfc_a{unit};
@@ -138,7 +143,7 @@ void read_ndef()
return; return;
} }
TLV msg; TLV msg{};
// Read NDEF message TLV // Read NDEF message TLV
if (!nfc_a.ndefRead(msg)) { if (!nfc_a.ndefRead(msg)) {
M5_LOGE("Failed to read"); M5_LOGE("Failed to read");
@@ -152,9 +157,9 @@ void read_ndef()
for (auto&& r : msg.records()) { for (auto&& r : msg.records()) {
switch (r.tnf()) { switch (r.tnf()) {
case TNF::Wellknown: { case TNF::Wellknown: {
auto s = r.payloadAsString().c_str(); const auto payload = r.payloadAsString();
M5.Log.printf("SZ:%3u TNF:%u T:%s [%s]\n", r.payloadSize(), r.tnf(), r.type(), s); M5.Log.printf("SZ:%3u TNF:%u T:%s [%s]\n", r.payloadSize(), r.tnf(), r.type(), payload.c_str());
lcd.printf("T:%s [%s]\n", r.type(), s); lcd.printf("T:%s [%s]\n", r.type(), payload.c_str());
} break; } break;
default: default:
M5.Log.printf("SZ:%3u TNF:%u T:%s\n", r.payloadSize(), r.tnf(), r.type()); M5.Log.printf("SZ:%3u TNF:%u T:%s\n", r.payloadSize(), r.tnf(), r.type());
@@ -264,18 +269,26 @@ void setup()
lcd.setRotation(1); lcd.setRotation(1);
} }
#if defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
#if defined(USING_M5DIAL_BUILTIN_WS1850S) #if defined(USING_M5DIAL_BUILTIN_WS1850S)
// M5Dial builtin WS1850S: small loop antenna; reduce RxGain to 33dB to mitigate
// reflection interference (default 48dB causes unstable WUPA on Builtin).
{
auto cfg = unit.config();
cfg.receiver_gain = m5::unit::mfrc522::ReceiverGain::dB33;
unit.config(cfg);
}
// M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563) // M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563)
M5_LOGI("Using M5.In_I2C for builtin WS1850S"); M5_LOGI("Using M5.In_I2C for builtin WS1850S");
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
#else
// NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register #elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// polling latency too high for MFRC522/WS1850S RF timing requirements. // External I2C unit (GROVE port).
// Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable) // NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
if (board == m5::board_t::board_M5NanoC6) { // Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
} else { } else {
@@ -286,14 +299,7 @@ void setup()
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
unit_ready = Units.add(unit, Wire) && Units.begin(); unit_ready = Units.add(unit, Wire) && Units.begin();
} }
#endif // USING_M5DIAL_BUILTIN_WS1850S
if (!unit_ready) {
M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
if (!SPI.bus()) { if (!SPI.bus()) {
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk); auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
@@ -302,16 +308,17 @@ void setup()
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso); M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */); SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
} }
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1}; SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
if (!Units.add(unit, SPI, settings) || !Units.begin()) { unit_ready = Units.add(unit, SPI, settings) && Units.begin();
#endif
if (!unit_ready) {
M5_LOGE("Failed to begin"); M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED); lcd.fillScreen(TFT_RED);
while (true) { while (true) {
m5::utility::delay(10000); m5::utility::delay(10000);
} }
} }
#endif
M5_LOGI("M5UnitUnified initialized"); M5_LOGI("M5UnitUnified initialized");
M5_LOGI("%s", Units.debugInfo().c_str()); M5_LOGI("%s", Units.debugInfo().c_str());
@@ -9,14 +9,17 @@
This example is shared with M5Unit-RFID This example is shared with M5Unit-RFID
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#include "main/ReadWrite.cpp" #include "main/ReadWrite.cpp"
@@ -18,22 +18,24 @@
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h> #include <Wire.h>
#include <M5HAL.hpp> // For NessoN1
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#if defined(USING_UNIT_RFID2) #if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#include <M5UnitUnifiedRFID.h> #include <M5UnitUnifiedRFID.h>
#endif #endif
@@ -53,9 +55,12 @@ m5::unit::UnitNFC unit{}; // I2C
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI) m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
#elif defined(USING_UNIT_RFID2) #elif defined(USING_UNIT_RFID2)
#pragma message "Choose UnitRFID2" #pragma message "Choose UnitRFID2"
m5::unit::UnitRFID2 unit{}; // UnitRFID2 (M5Unit-RFID) m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C)
#else #else
#error Choose unit please! #error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
m5::nfc::NFCLayerA nfc_a{unit}; m5::nfc::NFCLayerA nfc_a{unit};
@@ -187,30 +192,32 @@ void read_all_user_area()
// Using read/write for all // Using read/write for all
bool read_write(const uint8_t sblock, const char* msg) bool read_write(const uint8_t sblock, const char* msg)
{ {
auto ops = select_rw_ops(); auto ops = select_rw_ops();
auto len = strlen(msg); auto len = strlen(msg);
uint8_t buf[(strlen(msg) + 15) / 16 * 16]{}; const size_t buf_size = ((len + 15) / 16) * 16;
uint16_t rx_len = sizeof(buf); std::vector<uint8_t> buf(buf_size, 0);
uint16_t rx_len = static_cast<uint16_t>(buf.size());
// Write // Write
M5.Log.printf("================================ WRITE %s %u len:%zu\n", ops.label, sblock, sizeof(buf)); M5.Log.printf("================================ WRITE %s %u len:%zu\n", ops.label, sblock, buf.size());
if (ops.write(sblock, (const uint8_t*)msg, len)) { if (ops.write(sblock, (const uint8_t*)msg, len)) {
lcd.fillScreen(TFT_ORANGE); lcd.fillScreen(TFT_ORANGE);
ops.dump_block(sblock); ops.dump_block(sblock);
// Verify // Verify
if (ops.read(buf, rx_len, sblock)) { if (ops.read(buf.data(), rx_len, sblock)) {
lcd.fillScreen(TFT_BLUE); lcd.fillScreen(TFT_BLUE);
M5.Log.printf("================================ VERIFY:%s\n", memcmp(buf, msg, len) == 0 ? "OK" : "NG"); M5.Log.printf("================================ VERIFY:%s\n",
if (memcmp(buf, msg, len)) { memcmp(buf.data(), msg, len) == 0 ? "OK" : "NG");
m5::utility::log::dump(buf, rx_len, false); if (memcmp(buf.data(), msg, len)) {
m5::utility::log::dump(buf.data(), rx_len, false);
M5_LOGE("VERIFY NG!!"); M5_LOGE("VERIFY NG!!");
} }
// Clear // Clear
memset(buf, 0, sizeof(buf)); std::fill(buf.begin(), buf.end(), 0);
lcd.fillScreen(TFT_MAGENTA); lcd.fillScreen(TFT_MAGENTA);
if (ops.write(sblock, buf, sizeof(buf))) { if (ops.write(sblock, buf.data(), buf.size())) {
M5.Log.printf("================================ CLEAR\n"); M5.Log.printf("================================ CLEAR\n");
ops.dump_block(sblock); ops.dump_block(sblock);
return true; return true;
@@ -652,18 +659,26 @@ void setup()
lcd.setRotation(1); lcd.setRotation(1);
} }
#if defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
#if defined(USING_M5DIAL_BUILTIN_WS1850S) #if defined(USING_M5DIAL_BUILTIN_WS1850S)
// M5Dial builtin WS1850S: small loop antenna; reduce RxGain to 33dB to mitigate
// reflection interference (default 48dB causes unstable WUPA on Builtin).
{
auto cfg = unit.config();
cfg.receiver_gain = m5::unit::mfrc522::ReceiverGain::dB33;
unit.config(cfg);
}
// M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563) // M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563)
M5_LOGI("Using M5.In_I2C for builtin WS1850S"); M5_LOGI("Using M5.In_I2C for builtin WS1850S");
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
#else
// NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register #elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// polling latency too high for MFRC522/WS1850S RF timing requirements. // External I2C unit (GROVE port).
// Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable) // NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
if (board == m5::board_t::board_M5NanoC6) { // Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
} else { } else {
@@ -674,14 +689,7 @@ void setup()
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
unit_ready = Units.add(unit, Wire) && Units.begin(); unit_ready = Units.add(unit, Wire) && Units.begin();
} }
#endif // USING_M5DIAL_BUILTIN_WS1850S
if (!unit_ready) {
M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
if (!SPI.bus()) { if (!SPI.bus()) {
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk); auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
@@ -690,16 +698,17 @@ void setup()
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso); M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */); SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
} }
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1}; SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
if (!Units.add(unit, SPI, settings) || !Units.begin()) { unit_ready = Units.add(unit, SPI, settings) && Units.begin();
#endif
if (!unit_ready) {
M5_LOGE("Failed to begin"); M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED); lcd.fillScreen(TFT_RED);
while (true) { while (true) {
m5::utility::delay(10000); m5::utility::delay(10000);
} }
} }
#endif
M5_LOGI("M5UnitUnified initialized"); M5_LOGI("M5UnitUnified initialized");
M5_LOGI("%s", Units.debugInfo().c_str()); M5_LOGI("%s", Units.debugInfo().c_str());
@@ -716,7 +725,7 @@ void loop()
bool held = M5.BtnA.wasHold(); bool held = M5.BtnA.wasHold();
if (clicked || held) { if (clicked || held) {
PICC picc; PICC picc{};
if (nfc_a.detect(picc)) { if (nfc_a.detect(picc)) {
lcd.fillScreen(TFT_DARKGREEN); lcd.fillScreen(TFT_DARKGREEN);
if (nfc_a.identify(picc) && nfc_a.reactivate(picc)) { if (nfc_a.identify(picc) && nfc_a.reactivate(picc)) {
@@ -9,14 +9,17 @@
This example is shared with M5Unit-RFID This example is shared with M5Unit-RFID
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#include "main/ValueBlock.cpp" #include "main/ValueBlock.cpp"
@@ -13,22 +13,24 @@
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h> #include <Wire.h>
#include <M5HAL.hpp> // For NessoN1
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 // For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2 // #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (internal I2C)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#if defined(USING_UNIT_RFID2) #if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#include <M5UnitUnifiedRFID.h> #include <M5UnitUnifiedRFID.h>
#endif #endif
@@ -48,9 +50,12 @@ m5::unit::UnitNFC unit{}; // I2C
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI) m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
#elif defined(USING_UNIT_RFID2) #elif defined(USING_UNIT_RFID2)
#pragma message "Choose UnitRFID2" #pragma message "Choose UnitRFID2"
m5::unit::UnitRFID2 unit{}; // UnitRFID2 (M5Unit-RFID) m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C)
#else #else
#error Choose unit please! #error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
m5::nfc::NFCLayerA nfc_a{unit}; m5::nfc::NFCLayerA nfc_a{unit};
@@ -430,18 +435,26 @@ void setup()
lcd.setRotation(1); lcd.setRotation(1);
} }
#if defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
#if defined(USING_M5DIAL_BUILTIN_WS1850S) #if defined(USING_M5DIAL_BUILTIN_WS1850S)
// M5Dial builtin WS1850S: small loop antenna; reduce RxGain to 33dB to mitigate
// reflection interference (default 48dB causes unstable WUPA on Builtin).
{
auto cfg = unit.config();
cfg.receiver_gain = m5::unit::mfrc522::ReceiverGain::dB33;
unit.config(cfg);
}
// M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563) // M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563)
M5_LOGI("Using M5.In_I2C for builtin WS1850S"); M5_LOGI("Using M5.In_I2C for builtin WS1850S");
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
#else
// NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register #elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// polling latency too high for MFRC522/WS1850S RF timing requirements. // External I2C unit (GROVE port).
// Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable) // NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
if (board == m5::board_t::board_M5NanoC6) { // Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
} else { } else {
@@ -452,14 +465,7 @@ void setup()
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
unit_ready = Units.add(unit, Wire) && Units.begin(); unit_ready = Units.add(unit, Wire) && Units.begin();
} }
#endif // USING_M5DIAL_BUILTIN_WS1850S
if (!unit_ready) {
M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
if (!SPI.bus()) { if (!SPI.bus()) {
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk); auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
@@ -468,16 +474,17 @@ void setup()
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso); M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */); SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
} }
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1}; SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
if (!Units.add(unit, SPI, settings) || !Units.begin()) { unit_ready = Units.add(unit, SPI, settings) && Units.begin();
#endif
if (!unit_ready) {
M5_LOGE("Failed to begin"); M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED); lcd.fillScreen(TFT_RED);
while (true) { while (true) {
m5::utility::delay(10000); m5::utility::delay(10000);
} }
} }
#endif
M5_LOGI("M5UnitUnified initialized"); M5_LOGI("M5UnitUnified initialized");
M5_LOGI("%s", Units.debugInfo().c_str()); M5_LOGI("%s", Units.debugInfo().c_str());
+11 -5
View File
@@ -4,16 +4,22 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* /*
Example using M5UnitUnified for ST25R3916 Example using M5UnitUnified for M5Unit-NFC/RFID
Detect NFC-B PICC Detect NFC-B PICC
This example is shared with M5Unit-RFID
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (NOT SUPPORTED for NFC-B; use UnitRFID2)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#include "main/Detect.cpp" #include "main/Detect.cpp"
@@ -4,23 +4,39 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* /*
Example using M5UnitUnified for M5Cardputer-ADV with CapCC1101 Example using M5UnitUnified for M5Unit-NFC/RFID
Detect NFC-B PICC Detect NFC-B PICC
This example is shared with M5Unit-RFID
*/ */
#include <M5Unified.h> #include <M5Unified.h>
#include <M5UnitUnified.h> #include <M5UnitUnified.h>
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h>
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (NOT SUPPORTED for NFC-B; use UnitRFID2 instead)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif
#if defined(USING_M5DIAL_BUILTIN_WS1850S)
#error NFC-B is not supported on M5Dial Builtin (small antenna physical limit). \
Use USING_UNIT_RFID2 with external Unit-RFID2 instead.
#endif
#if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#include <M5UnitUnifiedRFID.h>
#endif #endif
using namespace m5::nfc; using namespace m5::nfc;
@@ -36,8 +52,14 @@ m5::unit::UnitNFC unit{}; // I2C
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
#pragma message "Choose CapCC1101NFC" #pragma message "Choose CapCC1101NFC"
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI) m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
#elif defined(USING_UNIT_RFID2)
#pragma message "Choose UnitRFID2"
m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C; NOT supported for NFC-B)
#else #else
#error Choose unit please! #error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
m5::nfc::NFCLayerB nfc_b{unit}; m5::nfc::NFCLayerB nfc_b{unit};
} // namespace } // namespace
@@ -47,15 +69,24 @@ void setup()
M5.begin(); M5.begin();
M5.setTouchButtonHeightByRatio(100); M5.setTouchButtonHeightByRatio(100);
// Select NFC-B mode via config() (applied at begin())
auto cfg = unit.config(); auto cfg = unit.config();
cfg.mode = NFC::B; cfg.mode = NFC::B;
unit.config(cfg); unit.config(cfg);
#if defined(USING_UNIT_NFC)
auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
// NessoN1: SoftwareI2C too slow for NFC RF timing -> use port_a (Wire) via else branch
if (board == m5::board_t::board_M5NanoC6) { #if defined(USING_M5DIAL_BUILTIN_WS1850S)
// Unreachable: gated by #error above. Kept for structural consistency.
M5_LOGI("Using M5.In_I2C for builtin WS1850S");
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
#elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// External I2C unit (GROVE port).
// NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
// Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
} else { } else {
@@ -66,13 +97,7 @@ void setup()
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
unit_ready = Units.add(unit, Wire) && Units.begin(); unit_ready = Units.add(unit, Wire) && Units.begin();
} }
if (!unit_ready) {
M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
if (!SPI.bus()) { if (!SPI.bus()) {
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk); auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
@@ -81,16 +106,18 @@ void setup()
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso); M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */); SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
} }
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1}; SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
if (!Units.add(unit, SPI, settings) || !Units.begin()) { unit_ready = Units.add(unit, SPI, settings) && Units.begin();
#endif
if (!unit_ready) {
M5_LOGE("Failed to begin"); M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED); lcd.fillScreen(TFT_RED);
while (true) { while (true) {
m5::utility::delay(10000); m5::utility::delay(10000);
} }
} }
#endif
M5_LOGI("M5UnitUnified initialized"); M5_LOGI("M5UnitUnified initialized");
M5_LOGI("%s", Units.debugInfo().c_str()); M5_LOGI("%s", Units.debugInfo().c_str());
@@ -4,16 +4,22 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* /*
Example using M5UnitUnified for ST25R3916 Example using M5UnitUnified for M5Unit-NFC/RFID
JapanIDCard example JapanIDCard example (read Mynumber Ticket Information Input Assistant AP)
This example is shared with M5Unit-RFID
*/ */
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (NOT SUPPORTED for NFC-B; use UnitRFID2)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
#include "main/JapanIDCard.cpp" #include "main/JapanIDCard.cpp"
@@ -4,23 +4,39 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* /*
Example using M5UnitUnified for ST25R3916 Example using M5UnitUnified for M5Unit-NFC/RFID
JapanIDCard example JapanIDCard example (read Mynumber Ticket Information Input Assistant AP)
This example is shared with M5Unit-RFID
*/ */
#include <M5Unified.h> #include <M5Unified.h>
#include <M5UnitUnified.h> #include <M5UnitUnified.h>
#include <M5UnitUnifiedNFC.h> #include <M5UnitUnifiedNFC.h>
#include <M5Utility.h> #include <M5Utility.h>
#include <Wire.h>
#include <vector> #include <vector>
// ************************************************************* // *************************************************************
// Choose one define symbol to match the unit you are using // Choose ONE define symbol to match the unit/board you are using
// ************************************************************* // *************************************************************
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) #if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
// For UnitNFC !defined(USING_M5DIAL_BUILTIN_WS1850S)
// For UnitNFC (ST25R3916, I2C)
// #define USING_UNIT_NFC // #define USING_UNIT_NFC
// For CapNFC // For CapCC1101NFC (ST25R3916, SPI)
// #define USING_CAP_CC1101 // #define USING_CAP_CC1101
// For UnitRFID2 (WS1850S external, I2C GROVE)
// #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (NOT SUPPORTED for NFC-B; use UnitRFID2 instead)
// #define USING_M5DIAL_BUILTIN_WS1850S
#endif
#if defined(USING_M5DIAL_BUILTIN_WS1850S)
#error NFC-B is not supported on M5Dial Builtin (small antenna physical limit). \
Use USING_UNIT_RFID2 with external Unit-RFID2 instead.
#endif
#if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
#include <M5UnitUnifiedRFID.h>
#endif #endif
using namespace m5::nfc; using namespace m5::nfc;
@@ -36,8 +52,14 @@ m5::unit::UnitNFC unit{}; // I2C
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
#pragma message "Choose CapCC1101NFC" #pragma message "Choose CapCC1101NFC"
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI) m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
#elif defined(USING_UNIT_RFID2)
#pragma message "Choose UnitRFID2"
m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C; NOT supported for NFC-B)
#else #else
#error Choose unit please! #error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
#endif #endif
m5::nfc::NFCLayerB nfc_b{unit}; m5::nfc::NFCLayerB nfc_b{unit};
@@ -60,10 +82,17 @@ void dump()
} }
// ******************************************** // ********************************************
// // Password (YOU MUST CHANGE IT!) as string // Password (YOU MUST CHANGE IT!) as string
// ********************************************
constexpr char pass[] = "XXXX"; constexpr char pass[] = "XXXX";
if (!fs.verifyGlobal((uint8_t*)pass, 4)) { // ********************************************
if (strcmp(pass, "XXXX") == 0) {
M5_LOGE(
"PIN is placeholder \"XXXX\". Edit the source before running. (Repeated wrong verifies will LOCK the "
"card!)");
return;
}
if (!fs.verifyGlobal(reinterpret_cast<const uint8_t*>(pass), 4)) {
M5_LOGE("Failed to verify"); M5_LOGE("Failed to verify");
return; return;
} }
@@ -80,8 +109,13 @@ void dump()
M5_LOGE("Failed to readBinary"); M5_LOGE("Failed to readBinary");
return; return;
} }
// buf[0] == size if (buf.empty()) {
if (!fs.readBinary(buf, 0, buf[0])) { M5_LOGE("Empty length response");
return;
}
const uint8_t file_size = buf[0];
M5_LOGI("readBinary size = %u", file_size);
if (!fs.readBinary(buf, 0, file_size)) {
M5_LOGE("Failed to readBinary"); M5_LOGE("Failed to readBinary");
return; return;
} }
@@ -95,15 +129,24 @@ void setup()
M5.begin(); M5.begin();
M5.setTouchButtonHeightByRatio(100); M5.setTouchButtonHeightByRatio(100);
// Select NFC-B mode via config() (applied at begin())
auto cfg = unit.config(); auto cfg = unit.config();
cfg.mode = NFC::B; cfg.mode = NFC::B;
unit.config(cfg); unit.config(cfg);
#if defined(USING_UNIT_NFC)
auto board = M5.getBoard();
bool unit_ready{}; bool unit_ready{};
// NessoN1: SoftwareI2C too slow for NFC RF timing -> use port_a (Wire) via else branch
if (board == m5::board_t::board_M5NanoC6) { #if defined(USING_M5DIAL_BUILTIN_WS1850S)
// Unreachable: gated by #error above. Kept for structural consistency.
M5_LOGI("Using M5.In_I2C for builtin WS1850S");
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
#elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
// External I2C unit (GROVE port).
// NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
// Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
M5_LOGI("Using M5.Ex_I2C"); M5_LOGI("Using M5.Ex_I2C");
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin(); unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
} else { } else {
@@ -114,13 +157,7 @@ void setup()
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
unit_ready = Units.add(unit, Wire) && Units.begin(); unit_ready = Units.add(unit, Wire) && Units.begin();
} }
if (!unit_ready) {
M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}
#elif defined(USING_CAP_CC1101) #elif defined(USING_CAP_CC1101)
if (!SPI.bus()) { if (!SPI.bus()) {
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk); auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
@@ -129,16 +166,18 @@ void setup()
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso); M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */); SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
} }
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1}; SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
if (!Units.add(unit, SPI, settings) || !Units.begin()) { unit_ready = Units.add(unit, SPI, settings) && Units.begin();
#endif
if (!unit_ready) {
M5_LOGE("Failed to begin"); M5_LOGE("Failed to begin");
lcd.fillScreen(TFT_RED); lcd.fillScreen(TFT_RED);
while (true) { while (true) {
m5::utility::delay(10000); m5::utility::delay(10000);
} }
} }
#endif
M5_LOGI("M5UnitUnified initialized"); M5_LOGI("M5UnitUnified initialized");
M5_LOGI("%s", Units.debugInfo().c_str()); M5_LOGI("%s", Units.debugInfo().c_str());
@@ -44,10 +44,10 @@ m5::nfc::EmulationLayerF emu_f{unit};
PICC picc{}; PICC picc{};
constexpr Type type{Type::FeliCaLiteS}; constexpr Type type{Type::FeliCaLiteS};
// constexpr uint8_t IDm[8] = {0x01, 0x2E, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0}; // See also SONY speficication // constexpr uint8_t IDm[8] = {0x01, 0x2E, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0}; // See also SONY specification
// documents // documents
constexpr uint8_t IDm[8] = {0x01, 0x2E, 0x50, 0xE5, 0x3C, 0x4B, 0x4F, 0x29}; constexpr uint8_t IDm[8] = {0x01, 0x2E, 0x50, 0xE5, 0x3C, 0x4B, 0x4F, 0x29};
constexpr uint8_t PMm[8] = {0x00, 0xF1, 0x00, 0x00, 0x00, 0x01, 0x43, 0x00}; // See also SONY speficication documents constexpr uint8_t PMm[8] = {0x00, 0xF1, 0x00, 0x00, 0x00, 0x01, 0x43, 0x00}; // See also SONY specification documents
uint8_t picc_memory[] = { uint8_t picc_memory[] = {
0x10, 0x04, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x58, 0x00, 0x7B, // S_PAD0 0x10, 0x04, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x58, 0x00, 0x7B, // S_PAD0
0x91, 0x01, 0x0D, 0x55, 0x04, 0x6D, 0x35, 0x73, 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x63, 0x6F, 0x6D, // 1 0x91, 0x01, 0x0D, 0x55, 0x04, 0x6D, 0x35, 0x73, 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x63, 0x6F, 0x6D, // 1
@@ -95,8 +95,6 @@ constexpr const char* state_table[] = {"-", "O", "I", "R", "A", "H"};
void setup() void setup()
{ {
delay(1500);
M5.begin(); M5.begin();
M5.setTouchButtonHeightByRatio(100); M5.setTouchButtonHeightByRatio(100);
@@ -176,7 +176,7 @@ void dump_jtic()
auto dt1 = buf_to_tm(buf + 4, buf + 6); auto dt1 = buf_to_tm(buf + 4, buf + 6);
auto dt2 = buf_to_tm(buf + 4, buf + 14); auto dt2 = buf_to_tm(buf + 4, buf + 14);
M5.Log.printf( M5.Log.printf(
" [%2u]:Departure:%03u-%03u Arrival:%03u-%03u Expired:%04u/%03u/%02u Issuance:%02u:%02u:%02u " " [%2u]:Departure:%03u-%03u Arrival:%03u-%03u Expired:%04u/%02u/%02u Issuance:%02u:%02u:%02u "
"Amount:%u Gate:%03u-%03u %02u:%02u:%02u\n", // "Amount:%u Gate:%03u-%03u %02u:%02u:%02u\n", //
i, buf[0], buf[1], buf[2], buf[3], // Station code i, buf[0], buf[1], buf[2], buf[3], // Station code
dt1.tm_year + 1900, dt1.tm_mon + 1, dt1.tm_mday, // dt1.tm_year + 1900, dt1.tm_mon + 1, dt1.tm_mday, //
+3 -3
View File
@@ -60,9 +60,9 @@ void read_ndef()
for (auto&& r : msg.records()) { for (auto&& r : msg.records()) {
switch (r.tnf()) { switch (r.tnf()) {
case TNF::Wellknown: { case TNF::Wellknown: {
auto s = r.payloadAsString().c_str(); const auto payload = r.payloadAsString();
M5.Log.printf("SZ:%3u TNF:%u T:%s [%s]\n", r.payloadSize(), r.tnf(), r.type(), s); M5.Log.printf("SZ:%3u TNF:%u T:%s [%s]\n", r.payloadSize(), r.tnf(), r.type(), payload.c_str());
lcd.printf("T:%s [%s]\n", r.type(), s); lcd.printf("T:%s [%s]\n", r.type(), payload.c_str());
} break; } break;
default: default:
M5.Log.printf("SZ:%3u TNF:%u T:%s\n", r.payloadSize(), r.tnf(), r.type()); M5.Log.printf("SZ:%3u TNF:%u T:%s\n", r.payloadSize(), r.tnf(), r.type());
@@ -56,7 +56,7 @@ void subtract_register()
reg.regB(reg.regB() - 2); reg.regB(reg.regB() - 2);
reg.regC(reg.regC() - 3); reg.regC(reg.regC() - 3);
if (!nfc_f.write16(lite::REG, reg.reg, sizeof(reg.reg))) { if (!nfc_f.write16(lite::REG, reg.reg, sizeof(reg.reg))) {
M5_LOGE("Failed to read"); M5_LOGE("Failed to write");
return; return;
} }
if (!nfc_f.read16(reg.reg, lite::REG /* Same as lite_s::REG */)) { if (!nfc_f.read16(reg.reg, lite::REG /* Same as lite_s::REG */)) {

Some files were not shown because too many files have changed in this diff Show More