[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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user