From de8617493fc07325834e802a3fb30eb0e5f3db74 Mon Sep 17 00:00:00 2001 From: Paludour Date: Tue, 25 Apr 2023 11:16:57 +0200 Subject: [PATCH 1/3] * Compatibility ProMicro --- src/sfm.cpp | 9 +++++++++ src/sfm.hpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/sfm.cpp b/src/sfm.cpp index 8ccb1df..a7c710f 100644 --- a/src/sfm.cpp +++ b/src/sfm.cpp @@ -28,6 +28,15 @@ SFM_Module::SFM_Module(uint8_t vccPin, uint8_t irqPin, uint8_t rxPin, uint8_t tx cmdBuffer[7] = 0xF5; sfmSerial.begin(115200, SERIAL_8N1, rx_pin, tx_pin); } +#elif defined(ARDUINO_AVR_PROMICRO16) +SFM_Module::SFM_Module(uint8_t vccPin, uint8_t irqPin, HardwareSerial &hs):sfmSerial(hs), vcc_pin(vccPin), irq_pin(irqPin){ + pinMode(irq_pin, INPUT); + pinMode(vcc_pin, OUTPUT); + digitalWrite(vcc_pin, HIGH); // Enable sensor vcc + cmdBuffer[0] = 0xF5; + cmdBuffer[7] = 0xF5; + sfmSerial.begin(115200); +} #else SFM_Module::SFM_Module(uint8_t vccPin, uint8_t irqPin, uint8_t rxPin, uint8_t txPin, uint8_t uartIndex):sfmSerial(rxPin, txPin), vcc_pin(vccPin), irq_pin(irqPin), rx_pin(rxPin), tx_pin(txPin){ pinMode(irq_pin, INPUT); diff --git a/src/sfm.hpp b/src/sfm.hpp index 9fd5bdf..27851e3 100644 --- a/src/sfm.hpp +++ b/src/sfm.hpp @@ -46,7 +46,11 @@ */ class SFM_Module{ public: +#if defined(ARDUINO_AVR_PROMICRO16) + SFM_Module(uint8_t vccPin, uint8_t irqPin, HardwareSerial &hs); +#else SFM_Module(uint8_t vccPin, uint8_t irqPin, uint8_t rxPin, uint8_t txPin, uint8_t uartIndex = 1); +#endif ~SFM_Module(); void enable(); void disable(); @@ -76,11 +80,11 @@ class SFM_Module{ uint8_t _getCheckSum(uint8_t *buffer); uint8_t _getDataPackage(String &package); uint8_t _getCmdReturn(uint8_t cmdType, uint8_t p1 = 0x00, uint8_t p2 = 0x00, uint8_t p3 = 0x00); - #if defined(ESP32) +#if defined(ESP32) || defined(ARDUINO_AVR_PROMICRO16) HardwareSerial sfmSerial; - #else +#else SoftwareSerial sfmSerial; - #endif +#endif uint8_t cmdBuffer[8] = {0}; uint8_t ackBuffer[8] = {0}; bool touched = false; @@ -88,8 +92,10 @@ class SFM_Module{ uint16_t userCount = 0; uint8_t vcc_pin; uint8_t irq_pin; +#if not defined(ARDUINO_AVR_PROMICRO16) uint8_t rx_pin; uint8_t tx_pin; +#endif }; #endif \ No newline at end of file From 98fabbebd3c861861fb6af089c09fd727755555c Mon Sep 17 00:00:00 2001 From: Paludour Date: Tue, 25 Apr 2023 11:24:42 +0200 Subject: [PATCH 2/3] * Test 1.0.2 => 1.0.3 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 7764b84..ff87cf7 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SFM-V1.7 -version=1.0.2 +version=1.0.3 author=Matrixchung maintainer=Matrixchung sentence=Interfacing to the SFM-V1.7 Fingerprint Sensor for ESP32 platform From a3cf4b8374c059425eb390412ffef41bbffd05cb Mon Sep 17 00:00:00 2001 From: Paludour Date: Fri, 28 Apr 2023 15:29:19 +0200 Subject: [PATCH 3/3] * Compatibility with ProMicro. --- src/sfm.cpp | 8 +++++++- src/sfm.hpp | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sfm.cpp b/src/sfm.cpp index a7c710f..c3ae3c0 100644 --- a/src/sfm.cpp +++ b/src/sfm.cpp @@ -35,7 +35,9 @@ SFM_Module::SFM_Module(uint8_t vccPin, uint8_t irqPin, HardwareSerial &hs):sfmSe digitalWrite(vcc_pin, HIGH); // Enable sensor vcc cmdBuffer[0] = 0xF5; cmdBuffer[7] = 0xF5; - sfmSerial.begin(115200); + sfmSerial.begin(115200, SERIAL_8N1); + while (!Serial1) + delay(100); } #else SFM_Module::SFM_Module(uint8_t vccPin, uint8_t irqPin, uint8_t rxPin, uint8_t txPin, uint8_t uartIndex):sfmSerial(rxPin, txPin), vcc_pin(vccPin), irq_pin(irqPin), rx_pin(rxPin), tx_pin(txPin){ @@ -209,7 +211,11 @@ uint8_t SFM_Module::sendCmd(uint8_t cmdType, uint8_t p1, uint8_t p2, uint8_t p3, } } } +#if defined(ARDUINO_AVR_PROMICRO16) + delay(2); +#else delay(1); +#endif } while(sfmSerial.available()) sfmSerial.read(); // flush buffer return SFM_ACK_SERIALTIMEOUT; diff --git a/src/sfm.hpp b/src/sfm.hpp index 27851e3..940f835 100644 --- a/src/sfm.hpp +++ b/src/sfm.hpp @@ -80,8 +80,10 @@ class SFM_Module{ uint8_t _getCheckSum(uint8_t *buffer); uint8_t _getDataPackage(String &package); uint8_t _getCmdReturn(uint8_t cmdType, uint8_t p1 = 0x00, uint8_t p2 = 0x00, uint8_t p3 = 0x00); -#if defined(ESP32) || defined(ARDUINO_AVR_PROMICRO16) +#if defined(ESP32) HardwareSerial sfmSerial; +#elif defined(ARDUINO_AVR_PROMICRO16) + HardwareSerial &sfmSerial; #else SoftwareSerial sfmSerial; #endif