[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

@@ -12,6 +12,7 @@ struct IrdaHandler {
typedef struct {
IrdaAlloc alloc;
IrdaDecode decode;
IrdaReset reset;
IrdaFree free;
} IrdaDecoders;
@@ -24,6 +25,8 @@ typedef struct {
const char* name;
IrdaDecoders decoder;
IrdaEncoders encoder;
uint8_t address_length;
uint8_t command_length;
} IrdaProtocolImplementation;
@@ -35,9 +38,12 @@ static const IrdaProtocolImplementation irda_protocols[] = {
.decoder = {
.alloc = irda_decoder_samsung32_alloc,
.decode = irda_decoder_samsung32_decode,
.reset = irda_decoder_samsung32_reset,
.free = irda_decoder_samsung32_free},
.encoder = {
.encode = irda_encoder_samsung32_encode}
.encode = irda_encoder_samsung32_encode},
.address_length = 2,
.command_length = 2,
},
// #1
{ .protocol = IrdaProtocolNEC,
@@ -45,9 +51,25 @@ static const IrdaProtocolImplementation irda_protocols[] = {
.decoder = {
.alloc = irda_decoder_nec_alloc,
.decode = irda_decoder_nec_decode,
.reset = irda_decoder_nec_reset,
.free = irda_decoder_nec_free},
.encoder = {
.encode = irda_encoder_nec_encode}
.encode = irda_encoder_nec_encode},
.address_length = 2,
.command_length = 2,
},
// #2
{ .protocol = IrdaProtocolNECext,
.name = "NECext",
.decoder = {
.alloc = irda_decoder_necext_alloc,
.decode = irda_decoder_nec_decode,
.reset = irda_decoder_nec_reset,
.free = irda_decoder_nec_free},
.encoder = {
.encode = irda_encoder_necext_encode},
.address_length = 4,
.command_length = 2,
},
};
@@ -93,6 +115,12 @@ void irda_free_decoder(IrdaHandler* handler) {
free(handler);
}
void irda_reset_decoder(IrdaHandler* handler) {
for (int i = 0; i < COUNT_OF(irda_protocols); ++i) {
irda_protocols[i].decoder.reset(handler->ctx[i]);
}
}
void irda_send(const IrdaMessage* message, int times) {
furi_assert(message);
@@ -109,3 +137,11 @@ const char* irda_get_protocol_name(IrdaProtocol protocol) {
return irda_protocols[protocol].name;
}
uint8_t irda_get_protocol_address_length(IrdaProtocol protocol) {
return irda_protocols[protocol].address_length;
}
uint8_t irda_get_protocol_command_length(IrdaProtocol protocol) {
return irda_protocols[protocol].command_length;
}