Files
esp32-fingerprint-safe/app/utils.h
2025-12-12 15:06:20 +01:00

27 lines
564 B
C++

#ifndef UTILS_H
#define UTILS_H
int hex2bytes(const char *str, uint8_t *bytes, int32_t length);
void bytes2hex(const uint8_t *bytes, int32_t length, char *str, int32_t strLength);
int Rssi2Quality(sint8 rssi);
class Debounce
{
static constexpr uint8_t UPPER = 0b10000000;
static constexpr uint8_t LOWER = 0b01111111;
public:
Debounce();
Debounce(bool signal);
void init(bool signal);
/* Return value:
* 0: no change
* -1: LOW/False (falling edge)
* 1: HIGH/True (rising edge)
*/
int8_t debounce(bool signal);
private:
uint8_t state;
};
#endif