diff --git a/examples/UnitUnified/UnitFinger/Capture/main/Capture.cpp b/examples/UnitUnified/UnitFinger/Capture/main/Capture.cpp index 22dd1f4..fccf290 100644 --- a/examples/UnitUnified/UnitFinger/Capture/main/Capture.cpp +++ b/examples/UnitUnified/UnitFinger/Capture/main/Capture.cpp @@ -15,7 +15,9 @@ // Choose one define symbol to match the unit you are using // ************************************************************* #if !defined(USING_UNIT_FINGER) && !defined(USING_HAT_FINGER) +// For UnitFinger (U008) // #define USING_UNIT_FINGER +// For HatFinger (U074) // #define USING_HAT_FINGER #endif // ************************************************************* @@ -39,7 +41,7 @@ void make_sprite8(LGFX_Sprite& s, const std::vector& v, const uint16_t { // Make 8bit grayscale sprite image for (int y = 0; y < hgt; ++y) { - for (int x = 0; x < wid; x += 2) { + for (int x = 0; x < wid; ++x) { s.writePixel(x, y, v[y * wid + x]); } } @@ -57,11 +59,41 @@ void make_sprite4(LGFX_Sprite& s, const std::vector& v, const uint16_t } } +#if defined(USING_HAT_FINGER) +struct UartPins { + int rx; // SCL pin of Hat connector + int tx; // SDA pin of Hat connector +}; + +UartPins get_hat_uart_pins(const m5::board_t board) +{ + switch (board) { + case m5::board_t::board_M5StickC: + case m5::board_t::board_M5StickCPlus: + case m5::board_t::board_M5StickCPlus2: + return {26, 0}; + case m5::board_t::board_M5StickS3: + return {0, 8}; + case m5::board_t::board_M5StackCoreInk: + return {26, 25}; + default: + return {-1, -1}; + } +} +#endif + } // namespace void setup() { - M5.begin(); + auto m5cfg = M5.config(); +#if defined(USING_HAT_FINGER) + m5cfg.pmic_button = false; // Disable BtnPWR + m5cfg.internal_imu = false; // Disable internal IMU + m5cfg.internal_rtc = false; // Disable internal RTC +#endif + M5.begin(m5cfg); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -69,18 +101,32 @@ void setup() } #if defined(USING_HAT_FINGER) - auto pin_num_in = 26; - auto pin_num_out = 0; + const auto pins = get_hat_uart_pins(M5.getBoard()); + M5_LOGI("getHatPin: RX:%d TX:%d", pins.rx, pins.tx); + if (pins.rx < 0 || pins.tx < 0) { + M5_LOGE("No Hat port on this board"); + lcd.fillScreen(TFT_RED); + while (true) { + m5::utility::delay(10000); + } + } + auto pin_num_in = pins.rx; + auto pin_num_out = pins.tx; #else auto pin_num_in = M5.getPin(m5::pin_name_t::port_c_rxd); auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); -#endif if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); } +#endif M5_LOGI("getPin: %d,%d", pin_num_in, pin_num_out); // clang-format off @@ -99,13 +145,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); // @@ -128,10 +174,9 @@ void loop() static bool raw{}; M5.update(); - auto touch = M5.Touch.getDetail(); Units.update(); - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { lcd.fillScreen(TFT_DARKGREEN); M5.Speaker.tone(1500, 20); diff --git a/examples/UnitUnified/UnitFinger/Characteristic/main/Characteristic.cpp b/examples/UnitUnified/UnitFinger/Characteristic/main/Characteristic.cpp index b3197b9..6894807 100644 --- a/examples/UnitUnified/UnitFinger/Characteristic/main/Characteristic.cpp +++ b/examples/UnitUnified/UnitFinger/Characteristic/main/Characteristic.cpp @@ -15,7 +15,9 @@ // Choose one define symbol to match the unit you are using // ************************************************************* #if !defined(USING_UNIT_FINGER) && !defined(USING_HAT_FINGER) +// For UnitFinger (U008) // #define USING_UNIT_FINGER +// For HatFinger (U074) // #define USING_HAT_FINGER #endif // ************************************************************* @@ -35,11 +37,41 @@ m5::unit::HatFinger unit; #endif uint16_t target_user_id{}; +#if defined(USING_HAT_FINGER) +struct UartPins { + int rx; + int tx; +}; + +UartPins get_hat_uart_pins(const m5::board_t board) +{ + switch (board) { + case m5::board_t::board_M5StickC: + case m5::board_t::board_M5StickCPlus: + case m5::board_t::board_M5StickCPlus2: + return {26, 0}; + case m5::board_t::board_M5StickS3: + return {0, 8}; + case m5::board_t::board_M5StackCoreInk: + return {26, 25}; + default: + return {-1, -1}; + } +} +#endif + } // namespace void setup() { - M5.begin(); + auto m5cfg = M5.config(); +#if defined(USING_HAT_FINGER) + m5cfg.pmic_button = false; + m5cfg.internal_imu = false; + m5cfg.internal_rtc = false; +#endif + M5.begin(m5cfg); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -47,18 +79,32 @@ void setup() } #if defined(USING_HAT_FINGER) - auto pin_num_in = 26; - auto pin_num_out = 0; + const auto pins = get_hat_uart_pins(M5.getBoard()); + M5_LOGI("getHatPin: RX:%d TX:%d", pins.rx, pins.tx); + if (pins.rx < 0 || pins.tx < 0) { + M5_LOGE("No Hat port on this board"); + lcd.fillScreen(TFT_RED); + while (true) { + m5::utility::delay(10000); + } + } + auto pin_num_in = pins.rx; + auto pin_num_out = pins.tx; #else auto pin_num_in = M5.getPin(m5::pin_name_t::port_c_rxd); auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); -#endif if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); } +#endif M5_LOGI("getPin: %d,%d", pin_num_in, pin_num_out); // clang-format off @@ -77,13 +123,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); lcd.fillScreen(TFT_DARKGREEN); @@ -95,18 +141,17 @@ void setup() void loop() { M5.update(); - auto touch = M5.Touch.getDetail(); Units.update(); // Compare, identify, verify - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { M5.Speaker.tone(1500, 20); lcd.drawString("Try scan", 0, 0); M5.Log.printf("Try scan for compare\n"); uint8_t characteristic[193]{}; if (unit.scanCharacteristic(characteristic)) { - M5.Log.printf("SACN OK\n"); + M5.Log.printf("SCAN OK\n"); m5::utility::log::dump(characteristic, 193, false); } else { M5_LOGE("Failed to scan"); @@ -149,12 +194,12 @@ void loop() } // Register - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { uint8_t characteristic[193]{}; lcd.drawString("Try scan ", 0, 0); M5.Log.printf("Try scan for register\n"); if (unit.scanCharacteristic(characteristic)) { - M5.Log.printf("SACN OK\n"); + M5.Log.printf("SCAN OK\n"); m5::utility::log::dump(characteristic, 193, false); } else { M5_LOGE("Failed to scan"); diff --git a/examples/UnitUnified/UnitFinger/PlotToSerial/main/PlotToSerial.cpp b/examples/UnitUnified/UnitFinger/PlotToSerial/main/PlotToSerial.cpp index 1513d21..ad2109c 100644 --- a/examples/UnitUnified/UnitFinger/PlotToSerial/main/PlotToSerial.cpp +++ b/examples/UnitUnified/UnitFinger/PlotToSerial/main/PlotToSerial.cpp @@ -15,7 +15,9 @@ // Choose one define symbol to match the unit you are using // ************************************************************* #if !defined(USING_UNIT_FINGER) && !defined(USING_HAT_FINGER) +// For UnitFinger (U008) // #define USING_UNIT_FINGER +// For HatFinger (U074) // #define USING_HAT_FINGER #endif // ************************************************************* @@ -37,6 +39,29 @@ m5::unit::HatFinger unit; uint16_t target_user_id{}; +#if defined(USING_HAT_FINGER) +struct UartPins { + int rx; // SCL pin of Hat connector + int tx; // SDA pin of Hat connector +}; + +UartPins get_hat_uart_pins(const m5::board_t board) +{ + switch (board) { + case m5::board_t::board_M5StickC: + case m5::board_t::board_M5StickCPlus: + case m5::board_t::board_M5StickCPlus2: + return {26, 0}; + case m5::board_t::board_M5StickS3: + return {0, 8}; + case m5::board_t::board_M5StackCoreInk: + return {26, 25}; + default: + return {-1, -1}; + } +} +#endif + void print_all_users() { std::vector v{}; @@ -53,7 +78,14 @@ void print_all_users() void setup() { - M5.begin(); + auto m5cfg = M5.config(); +#if defined(USING_HAT_FINGER) + m5cfg.pmic_button = false; // Disable BtnPWR + m5cfg.internal_imu = false; // Disable internal IMU + m5cfg.internal_rtc = false; // Disable internal RTC +#endif + M5.begin(m5cfg); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -61,18 +93,32 @@ void setup() } #if defined(USING_HAT_FINGER) - auto pin_num_in = 26; - auto pin_num_out = 0; + const auto pins = get_hat_uart_pins(M5.getBoard()); + M5_LOGI("getHatPin: RX:%d TX:%d", pins.rx, pins.tx); + if (pins.rx < 0 || pins.tx < 0) { + M5_LOGE("No Hat port on this board"); + lcd.fillScreen(TFT_RED); + while (true) { + m5::utility::delay(10000); + } + } + auto pin_num_in = pins.rx; + auto pin_num_out = pins.tx; #else auto pin_num_in = M5.getPin(m5::pin_name_t::port_c_rxd); auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); -#endif if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); } +#endif M5_LOGI("getPin: %d,%d", pin_num_in, pin_num_out); // clang-format off @@ -97,13 +143,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); { @@ -138,11 +184,10 @@ void setup() void loop() { M5.update(); - auto touch = M5.Touch.getDetail(); Units.update(); // Register finger - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { lcd.fillScreen(TFT_DARKGREEN); M5.Speaker.tone(2500, 20); lcd.drawString("Try register", 0, 0); @@ -162,7 +207,7 @@ void loop() } // Identify and verify finger - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { uint16_t id{}; uint8_t per{}; M5.Speaker.tone(1500, 20); diff --git a/examples/UnitUnified/UnitFinger/User/main/User.cpp b/examples/UnitUnified/UnitFinger/User/main/User.cpp index bcb3d81..e7545ef 100644 --- a/examples/UnitUnified/UnitFinger/User/main/User.cpp +++ b/examples/UnitUnified/UnitFinger/User/main/User.cpp @@ -15,6 +15,13 @@ using namespace m5::unit::fpc1xxx; +#if !defined(USING_UNIT_FINGER) && !defined(USING_HAT_FINGER) +// For UnitFinger (U008) +// #define USING_UNIT_FINGER +// For HatFinger (U074) +// #define USING_HAT_FINGER +#endif + namespace { auto& lcd = M5.Display; @@ -78,12 +85,11 @@ int select_menu() for (;;) { M5.update(); Units.update(); - auto touch = M5.Touch.getDetail(); - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { cur_menu = (cur_menu + 1) % 5; show_menu(); - } else if (M5.BtnA.wasClicked() || touch.wasClicked()) { + } else if (M5.BtnA.wasClicked()) { if (cur_menu == 0) { if (++cur_user > 150) { cur_user = 1; @@ -101,21 +107,50 @@ bool select_yesno() for (;;) { M5.update(); Units.update(); - auto touch = M5.Touch.getDetail(); - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { return false; } - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { return true; } } } +#if defined(USING_HAT_FINGER) +struct UartPins { + int rx; + int tx; +}; + +UartPins get_hat_uart_pins(const m5::board_t board) +{ + switch (board) { + case m5::board_t::board_M5StickC: + case m5::board_t::board_M5StickCPlus: + case m5::board_t::board_M5StickCPlus2: + return {26, 0}; + case m5::board_t::board_M5StickS3: + return {0, 8}; + case m5::board_t::board_M5StackCoreInk: + return {26, 25}; + default: + return {-1, -1}; + } +} +#endif + } // namespace void setup() { - M5.begin(); + auto m5cfg = M5.config(); +#if defined(USING_HAT_FINGER) + m5cfg.pmic_button = false; + m5cfg.internal_imu = false; + m5cfg.internal_rtc = false; +#endif + M5.begin(m5cfg); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -123,18 +158,32 @@ void setup() } #if defined(USING_HAT_FINGER) - auto pin_num_in = 26; - auto pin_num_out = 0; + const auto pins = get_hat_uart_pins(M5.getBoard()); + M5_LOGI("getHatPin: RX:%d TX:%d", pins.rx, pins.tx); + if (pins.rx < 0 || pins.tx < 0) { + M5_LOGE("No Hat port on this board"); + lcd.fillScreen(TFT_RED); + while (true) { + m5::utility::delay(10000); + } + } + auto pin_num_in = pins.rx; + auto pin_num_out = pins.tx; #else auto pin_num_in = M5.getPin(m5::pin_name_t::port_c_rxd); auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); -#endif if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); } +#endif M5_LOGI("getPin: %d,%d", pin_num_in, pin_num_out); // clang-format off @@ -153,13 +202,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); { @@ -173,7 +222,7 @@ void setup() M5.Log.printf("=== %s information ===\n", unit.deviceName()); M5.Log.printf(" Mode: %s\n", - mode == Mode::ProhibitDuplicate ? "Prohibity duplicate" : "Allow duplicate"); + mode == Mode::ProhibitDuplicate ? "Prohibit duplicate" : "Allow duplicate"); M5.Log.printf(" Comparison Lv: %u\n", clv); M5.Log.printf(" Timeout: %u\n", timeout); M5.Log.printf("Registered user: %u\n", user_count); diff --git a/examples/UnitUnified/UnitFinger2/Automatic/main/Automatic.cpp b/examples/UnitUnified/UnitFinger2/Automatic/main/Automatic.cpp index e7695ef..6dfa328 100644 --- a/examples/UnitUnified/UnitFinger2/Automatic/main/Automatic.cpp +++ b/examples/UnitUnified/UnitFinger2/Automatic/main/Automatic.cpp @@ -81,7 +81,7 @@ void auto_enroll() uint16_t page{0xFFFF}; if (!(highlow == false ? unit.findLowestAvailablePage(page) : unit.findHighestAvailablePage(page)) || page == 0xFFFF) { - M5_LOGE("Failed or Invalild page"); + M5_LOGE("Failed or Invalid page"); return; } @@ -108,12 +108,13 @@ void auto_enroll() } lcd.fillScreen(TFT_DARKGREEN); } else { - M5_LIB_LOGE("Failed to wakeup"); + M5_LOGE("Failed to wakeup"); } } bool callback_identify(const uint16_t call_times, const ConfirmCode confirm, const AutoIdentifyStage stage) { + lcd.startWrite(); lcd.setCursor(0, 0); lcd.printf("IDENTIFY:%02u [%02X]", (uint8_t)stage, (uint8_t)confirm); lcd.endWrite(); @@ -152,6 +153,7 @@ void auto_identify() void setup() { M5.begin(); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -162,6 +164,11 @@ void setup() auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); @@ -183,13 +190,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); lcd.fillScreen(TFT_DARKGREEN); @@ -201,17 +208,16 @@ void setup() void loop() { M5.update(); - auto touch = M5.Touch.getDetail(); Units.update(); // Identify - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { M5.Speaker.tone(2000, 20); auto_identify(); } // Register - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { M5.Speaker.tone(4000, 20); auto_enroll(); } diff --git a/examples/UnitUnified/UnitFinger2/Capture/main/Capture.cpp b/examples/UnitUnified/UnitFinger2/Capture/main/Capture.cpp index 96e9338..58a97f3 100644 --- a/examples/UnitUnified/UnitFinger2/Capture/main/Capture.cpp +++ b/examples/UnitUnified/UnitFinger2/Capture/main/Capture.cpp @@ -37,6 +37,7 @@ void make_sprite4(LGFX_Sprite& s, const std::vector& v, const uint16_t void setup() { M5.begin(); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -47,6 +48,11 @@ void setup() auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); @@ -68,13 +74,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); lcd.fillScreen(TFT_DARKGREEN); lcd.setFont(&fonts::AsciiFont8x16); @@ -90,10 +96,9 @@ void setup() void loop() { M5.update(); - auto touch = M5.Touch.getDetail(); Units.update(); - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { lcd.fillScreen(TFT_DARKGREEN); M5.Speaker.tone(2500, 20); lcd.setCursor(0, 0); diff --git a/examples/UnitUnified/UnitFinger2/PlotToSerial/main/PlotToSerial.cpp b/examples/UnitUnified/UnitFinger2/PlotToSerial/main/PlotToSerial.cpp index dfe0986..95d5609 100644 --- a/examples/UnitUnified/UnitFinger2/PlotToSerial/main/PlotToSerial.cpp +++ b/examples/UnitUnified/UnitFinger2/PlotToSerial/main/PlotToSerial.cpp @@ -49,7 +49,7 @@ void register_finger() uint16_t page{0xFFFF}; if (!(highlow == false ? unit.findLowestAvailablePage(page) : unit.findHighestAvailablePage(page)) || page == 0xFFFF) { - M5_LOGE("Failed or Invalild page"); + M5_LOGE("Failed or Invalid page"); return; } M5.Log.printf("Try register to %u\n", page); @@ -129,7 +129,7 @@ void match_finger(const uint16_t page) if (unit.match(matched, score)) { M5.Log.printf("<1:1>%u %s, Score:%u\n", page, matched ? "Matched" : "Unmatched", score); } else { - M5_LOGE("Failed to macth"); + M5_LOGE("Failed to match"); } } else { M5_LOGE("Failed to any function"); @@ -145,7 +145,7 @@ uint16_t search_finger() bool matched{}; uint16_t page{}; uint16_t score{}; - if (unit.search(matched, page, score, 1 /* bufer id */)) { + if (unit.search(matched, page, score, 1 /* buffer id */)) { M5.Log.printf("<1:N> %s Page:%u Score:%u\n", matched ? "Found" : "Not found", page, score); return matched ? page : 0xFFFF; } else { @@ -161,7 +161,7 @@ uint16_t search_finger() uint16_t search_now_finger() { bool detected{}; - // seachNow is performed on the last generated characteristic + // searchNow is performed on the last generated characteristic if (unit.capture(detected) && detected && unit.generateCharacteristic(2)) { bool matched{}; uint16_t page{}; @@ -183,6 +183,7 @@ uint16_t search_now_finger() void setup() { M5.begin(); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -193,6 +194,11 @@ void setup() auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); @@ -214,13 +220,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); lcd.fillScreen(TFT_DARKGREEN); @@ -232,11 +238,10 @@ void setup() void loop() { M5.update(); - auto touch = M5.Touch.getDetail(); Units.update(); // Search,Match - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { M5.Speaker.tone(2000, 20); auto page = search_finger(); if (page != 0xFFFF) { @@ -248,7 +253,7 @@ void loop() } // Register - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { M5.Speaker.tone(4000, 20); register_finger(); lcd.fillScreen(TFT_DARKGREEN); diff --git a/examples/UnitUnified/UnitFinger2/User/main/User.cpp b/examples/UnitUnified/UnitFinger2/User/main/User.cpp index abd9034..fab694a 100644 --- a/examples/UnitUnified/UnitFinger2/User/main/User.cpp +++ b/examples/UnitUnified/UnitFinger2/User/main/User.cpp @@ -13,7 +13,7 @@ #include #include -using namespace m5::unit::fpc1xxx; +using namespace m5::unit::finger2; extern const uint8_t template_data[]; // template_data.cpp extern const size_t template_data_size; // template_data.cpp @@ -94,12 +94,11 @@ int select_menu() for (;;) { M5.update(); Units.update(); - auto touch = M5.Touch.getDetail(); - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { cur_menu = (cur_menu + 1) % 5; show_menu(); - } else if (M5.BtnA.wasClicked() || touch.wasClicked()) { + } else if (M5.BtnA.wasClicked()) { if (cur_menu == 0) { if (++cur_user > 99) { cur_user = 0; @@ -117,11 +116,10 @@ bool select_yesno() for (;;) { M5.update(); Units.update(); - auto touch = M5.Touch.getDetail(); - if (M5.BtnA.wasHold() || touch.wasHold()) { + if (M5.BtnA.wasHold()) { return false; } - if (M5.BtnA.wasClicked() || touch.wasClicked()) { + if (M5.BtnA.wasClicked()) { return true; } } @@ -132,6 +130,7 @@ bool select_yesno() void setup() { M5.begin(); + M5.setTouchButtonHeightByRatio(100); // The screen shall be in landscape mode if (lcd.height() > lcd.width()) { @@ -142,6 +141,11 @@ void setup() auto pin_num_out = M5.getPin(m5::pin_name_t::port_c_txd); if (pin_num_in < 0 || pin_num_out < 0) { M5_LOGW("PortC is not available"); + // NanoC6: Ex_I2C.setPort() registers m5gfx::i2c on GROVE pins; + // Wire.end() alone won't release it, causing dual-driver conflict on uart_driver_install + if (M5.getBoard() == m5::board_t::board_M5NanoC6) { + M5.Ex_I2C.release(); + } Wire.end(); pin_num_in = M5.getPin(m5::pin_name_t::port_a_pin1); pin_num_out = M5.getPin(m5::pin_name_t::port_a_pin2); @@ -163,13 +167,13 @@ void setup() if (!Units.add(unit, s) || !Units.begin()) { M5_LOGE("Failed to begin"); - lcd.clear(TFT_RED); + lcd.fillScreen(TFT_RED); while (true) { m5::utility::delay(10000); } } - M5_LOGI("M5UnitUnified has been begun"); + M5_LOGI("M5UnitUnified initialized"); M5_LOGI("%s", Units.debugInfo().c_str()); lcd.fillScreen(TFT_DARKGREEN); @@ -217,7 +221,7 @@ void loop() if (select_yesno()) { if (unit.wakeup() && unit.clear()) { M5.Log.printf("==> All users deleted\n"); - cur_user = 1; + cur_user = 0; } else { M5_LOGE("Failed to clear"); }