From 65a41b3d93a0caa64510d3db69123836ceae686c Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Mon, 11 May 2020 08:42:01 +0200 Subject: [PATCH] Refactored function --- main/main.ino | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main/main.ino b/main/main.ino index 73acfad..f265dc7 100644 --- a/main/main.ino +++ b/main/main.ino @@ -29,8 +29,13 @@ NewRemoteTransmitter transmitter(ritter_group_address, pin_ritter); DHT dht(pin_tmp, DHT11); IRrecv irrecv(pin_ir_reciever); -String getDecodeType(decode_results *results){ - switch(results->decode_type){ +/** + * Associative Arrays aren't possible in C++ because of Memory. + * For this reason it's necessary to implement the function like this. + * If you get the return value "UNKNOWN", adapt the return values to the ones in decode_type_t defined in IRremoteESP8266.h + **/ +String getDecodeType(decode_type_t decode_type){ + switch(decode_type){ case NEC: return String("NEC"); case SONY: @@ -44,7 +49,7 @@ String getDecodeType(decode_results *results){ case RCMM: return String("RCMM"); case PANASONIC: - return String("PANASONIC" + results->address + HEX); + return String("PANASONIC"); case LG: return String("LG"); case JVC: @@ -59,7 +64,7 @@ String getDecodeType(decode_results *results){ void dump(decode_results *results) { uint16_t count = results->rawlen; - Serial.print(getDecodeType(results)); + Serial.print(getDecodeType(results->decode_type)); serialPrintUint64(results->value, 16); Serial.print(" ("); Serial.print(results->bits, DEC);