Skip to content

Commit

Permalink
Merge pull request #7 from lhofinger/master
Browse files Browse the repository at this point in the history
Compatibility with Pro Micro - 5V/16MHz
  • Loading branch information
Matrixchung authored May 1, 2023
2 parents 260c44e + a3cf4b8 commit 96612f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SFM-V1.7
version=1.0.2
version=1.0.3
author=Matrixchung <[email protected]>
maintainer=Matrixchung <[email protected]>
sentence=Interfacing to the SFM-V1.7 Fingerprint Sensor for ESP32 platform
Expand Down
15 changes: 15 additions & 0 deletions src/sfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ 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, 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){
pinMode(irq_pin, INPUT);
Expand Down Expand Up @@ -200,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;
Expand Down
14 changes: 11 additions & 3 deletions src/sfm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -76,20 +80,24 @@ 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)
HardwareSerial sfmSerial;
#else
#elif defined(ARDUINO_AVR_PROMICRO16)
HardwareSerial &sfmSerial;
#else
SoftwareSerial sfmSerial;
#endif
#endif
uint8_t cmdBuffer[8] = {0};
uint8_t ackBuffer[8] = {0};
bool touched = false;
String uuid = "";
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

0 comments on commit 96612f1

Please sign in to comment.