mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
Infrared RCA Protocol + Update docs
Thanks to anonymous contributor for protocol implementation and testing
This commit is contained in:
37
lib/infrared/encoder_decoder/rca/infrared_encoder_rca.c
Normal file
37
lib/infrared/encoder_decoder/rca/infrared_encoder_rca.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "infrared_protocol_rca_i.h"
|
||||
|
||||
#include <core/check.h>
|
||||
|
||||
void infrared_encoder_rca_reset(void* encoder_ptr, const InfraredMessage* message) {
|
||||
furi_assert(encoder_ptr);
|
||||
furi_assert(message);
|
||||
|
||||
InfraredCommonEncoder* encoder = encoder_ptr;
|
||||
infrared_common_encoder_reset(encoder);
|
||||
|
||||
uint32_t* data = (void*)encoder->data;
|
||||
|
||||
uint8_t address = message->address;
|
||||
uint8_t address_inverse = ~address;
|
||||
uint8_t command = message->command;
|
||||
uint8_t command_inverse = ~command;
|
||||
|
||||
*data = address & 0xF;
|
||||
*data |= command << 4;
|
||||
*data |= (address_inverse & 0xF) << 12;
|
||||
*data |= command_inverse << 16;
|
||||
|
||||
encoder->bits_to_encode = encoder->protocol->databit_len[0];
|
||||
}
|
||||
|
||||
void* infrared_encoder_rca_alloc(void) {
|
||||
return infrared_common_encoder_alloc(&infrared_protocol_rca);
|
||||
}
|
||||
|
||||
void infrared_encoder_rca_free(void* encoder_ptr) {
|
||||
infrared_common_encoder_free(encoder_ptr);
|
||||
}
|
||||
|
||||
InfraredStatus infrared_encoder_rca_encode(void* encoder_ptr, uint32_t* duration, bool* level) {
|
||||
return infrared_common_encode(encoder_ptr, duration, level);
|
||||
}
|
||||
Reference in New Issue
Block a user