[FL-1250, FL-1252, FL-1323, FL-1324] New IRDA Application (part 1) (#497)

* Add new IrdaApp (half ready), add ButtonMenu

* Fix NEC's extension

* clang-format

* Fix leak

* Add submenu optional header

* IRDA: add Edit button

* clang-format

* IrdaApp: Fix scene flow

* Add IRDA NEC extended protocol

* IRDA: Add address/command length

Co-authored-by: SG <who.just.the.doctor@gmail.com>
This commit is contained in:
Albert Kharisov
2021-06-02 18:16:05 +03:00
committed by GitHub
parent d040515f84
commit 31c31db479
62 changed files with 2568 additions and 375 deletions

View File

@@ -3,9 +3,12 @@
#include <furi.h>
#include "../irda_i.h"
static bool interpret_nec(IrdaCommonDecoder* decoder);
static bool interpret_necext(IrdaCommonDecoder* decoder);
static DecodeStatus decode_repeat_nec(IrdaCommonDecoder* decoder);
static const IrdaCommonProtocolSpec protocol_nec = {
{
IRDA_NEC_PREAMBULE_MARK,
@@ -23,15 +26,33 @@ static const IrdaCommonProtocolSpec protocol_nec = {
decode_repeat_nec,
};
static const IrdaCommonProtocolSpec protocol_necext = {
{
IRDA_NEC_PREAMBULE_MARK,
IRDA_NEC_PREAMBULE_SPACE,
IRDA_NEC_BIT1_MARK,
IRDA_NEC_BIT1_SPACE,
IRDA_NEC_BIT0_MARK,
IRDA_NEC_BIT0_SPACE,
IRDA_NEC_PREAMBLE_TOLERANCE,
IRDA_NEC_BIT_TOLERANCE,
},
32,
irda_common_decode_pdwm,
interpret_necext,
decode_repeat_nec,
};
static bool interpret_nec(IrdaCommonDecoder* decoder) {
furi_assert(decoder);
bool result = false;
uint16_t address = decoder->data[0] | (decoder->data[1] << 8);
uint8_t address = decoder->data[0];
uint8_t address_inverse = decoder->data[1];
uint8_t command = decoder->data[2];
uint8_t command_inverse = decoder->data[3];
if((command == (uint8_t)~command_inverse)) {
if ((command == (uint8_t) ~command_inverse) && (address == (uint8_t) ~address_inverse)) {
decoder->message.command = command;
decoder->message.address = address;
decoder->message.repeat = false;
@@ -41,6 +62,24 @@ static bool interpret_nec(IrdaCommonDecoder* decoder) {
return result;
}
// Some NEC's extensions allow 16 bit address
static bool interpret_necext(IrdaCommonDecoder* decoder) {
furi_assert(decoder);
bool result = false;
uint8_t command = decoder->data[2];
uint8_t command_inverse = decoder->data[3];
if(command == (uint8_t)~command_inverse) {
decoder->message.command = command;
decoder->message.address = decoder->data[0] | (decoder->data[1] << 8);
decoder->message.repeat = false;
result = true;
}
return result;
}
// timings start from Space (delay between message and repeat)
static DecodeStatus decode_repeat_nec(IrdaCommonDecoder* decoder) {
furi_assert(decoder);
@@ -69,6 +108,10 @@ void* irda_decoder_nec_alloc(void) {
return irda_common_decoder_alloc(&protocol_nec);
}
void* irda_decoder_necext_alloc(void) {
return irda_common_decoder_alloc(&protocol_necext);
}
IrdaMessage* irda_decoder_nec_decode(void* decoder, bool level, uint32_t duration) {
return irda_common_decode(decoder, level, duration);
}
@@ -76,3 +119,8 @@ IrdaMessage* irda_decoder_nec_decode(void* decoder, bool level, uint32_t duratio
void irda_decoder_nec_free(void* decoder) {
irda_common_decoder_free(decoder);
}
void irda_decoder_nec_reset(void* decoder) {
irda_common_decoder_reset(decoder);
}