From 9d71aea6221dfb1e75a4e9a7b5fac50479fc1756 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:24:36 +0100 Subject: [PATCH] Make fingerprint error messages optional Make fingerprint error messages optional saving 0k4 code space --- tasmota/my_user_config.h | 3 ++- tasmota/xsns_79_as608.ino | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 2e4798142..90c1a009d 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -655,7 +655,8 @@ #define USE_TASMOTA_CLIENT_SERIAL_SPEED 57600 // Depends on the sketch that is running on the Uno/Pro Mini //#define USE_OPENTHERM // Add support for OpenTherm (+15k code) //#define USE_MIEL_HVAC // Add support for Mitsubishi Electric HVAC serial interface (+5k code) -//#define USE_AS608 // Add support for AS608 optical and R503 capacitive fingerprint sensor (+3k4 code) +//#define USE_AS608 // Add support for AS608 optical and R503 capacitive fingerprint sensor (+3k code) +// #define USE_AS608_MESSAGES // Add verbose error messages (+0k4 code) // -- Power monitoring sensors -------------------- #define USE_ENERGY_MARGIN_DETECTION // Add support for Energy Margin detection (+1k6 code) diff --git a/tasmota/xsns_79_as608.ino b/tasmota/xsns_79_as608.ino index be942e881..f4e7d3939 100644 --- a/tasmota/xsns_79_as608.ino +++ b/tasmota/xsns_79_as608.ino @@ -22,10 +22,16 @@ * AS608 optical and R503 capacitive Fingerprint sensor * * Uses Adafruit-Fingerprint-sensor-library with TasmotaSerial + * + * Changes made to Adafruit_Fingerprint.h and Adafruit_Fingerprint.cpp: + * - Replace SoftwareSerial with TasmotaSerial + * - Add defined(ESP32) where also defined(ESP8266) \*********************************************************************************************/ #define XSNS_79 79 +//#define USE_AS608_MESSAGES + #define D_JSON_FPRINT "FPrint" #define D_PRFX_FP "Fp" @@ -37,6 +43,7 @@ const char kAs608Commands[] PROGMEM = D_PRFX_FP "|" D_CMND_FP_ENROLL "|" D_CMND_ void (*const As608Commands[])(void) PROGMEM = { &CmndFpEnroll, &CmndFpDelete, &CmndFpCount }; +#ifdef USE_AS608_MESSAGES const char kAs608Messages[] PROGMEM = D_DONE "|" D_FP_PACKETRECIEVEERR "|" D_FP_NOFINGER "|" D_FP_IMAGEFAIL "|" D_FP_UNKNOWNERROR "|" D_FP_IMAGEMESS "|" D_FP_FEATUREFAIL "|" D_FP_NOMATCH "|" D_FP_NOTFOUND "|" D_FP_ENROLLMISMATCH "|" D_FP_BADLOCATION "|" D_FP_DBRANGEFAIL "|" D_FP_UPLOADFEATUREFAIL "|" D_FP_PACKETRESPONSEFAIL "|" @@ -44,6 +51,9 @@ const char kAs608Messages[] PROGMEM = D_FP_ADDRCODE "|" D_FP_PASSVERIFY; const uint8_t As608Reference[] PROGMEM = { 0, 1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 4, 17, 4, 18, 4, 4, 19, 4, 20, 4, 4, 4, 4, 4, 21, 22 }; +#else +const char kAs608Messages[] PROGMEM = D_DONE "|" D_FP_UNKNOWNERROR "|" D_FP_NOFINGER; +#endif #include #include @@ -58,8 +68,13 @@ struct AS608 { } As608; char* As608Message(char* response, uint32_t index) { +#ifdef USE_AS608_MESSAGES if (index > sizeof(As608Reference)) { index = 4; } uint32_t i = pgm_read_byte(&As608Reference[index]); +#else + if (index > 2) { index = 1; } + uint32_t i = index; +#endif return GetTextIndexed(response, TOPSZ, i, kAs608Messages); }