[FL-2279] IR doxygen, rename irda -> infrared (#1010)

* IR: Doxygen docs, some rename
* Rename irda -> infrared
* Rollback collateral renames

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Albert Kharisov
2022-02-25 19:22:58 +04:00
committed by GitHub
parent c42cce3c6c
commit 052237f8c9
159 changed files with 6387 additions and 5622 deletions

View File

@@ -0,0 +1,72 @@
#include "infrared.h"
#include "infrared_protocol_defs_i.h"
#include <stdbool.h>
#include <stdint.h>
#include <furi.h>
#include "../infrared_i.h"
InfraredMessage* infrared_decoder_samsung32_check_ready(void* ctx) {
return infrared_common_decoder_check_ready(ctx);
}
bool infrared_decoder_samsung32_interpret(InfraredCommonDecoder* decoder) {
furi_assert(decoder);
bool result = false;
uint8_t address1 = decoder->data[0];
uint8_t address2 = decoder->data[1];
uint8_t command = decoder->data[2];
uint8_t command_inverse = decoder->data[3];
if((address1 == address2) && (command == (uint8_t)~command_inverse)) {
decoder->message.command = command;
decoder->message.address = address1;
decoder->message.protocol = InfraredProtocolSamsung32;
decoder->message.repeat = false;
result = true;
}
return result;
}
// timings start from Space (delay between message and repeat)
InfraredStatus infrared_decoder_samsung32_decode_repeat(InfraredCommonDecoder* decoder) {
furi_assert(decoder);
float preamble_tolerance = decoder->protocol->timings.preamble_tolerance;
uint32_t bit_tolerance = decoder->protocol->timings.bit_tolerance;
InfraredStatus status = InfraredStatusError;
if(decoder->timings_cnt < 6) return InfraredStatusOk;
if((decoder->timings[0] > INFRARED_SAMSUNG_REPEAT_PAUSE_MIN) &&
(decoder->timings[0] < INFRARED_SAMSUNG_REPEAT_PAUSE_MAX) &&
MATCH_TIMING(decoder->timings[1], INFRARED_SAMSUNG_REPEAT_MARK, preamble_tolerance) &&
MATCH_TIMING(decoder->timings[2], INFRARED_SAMSUNG_REPEAT_SPACE, preamble_tolerance) &&
MATCH_TIMING(decoder->timings[3], decoder->protocol->timings.bit1_mark, bit_tolerance) &&
MATCH_TIMING(decoder->timings[4], decoder->protocol->timings.bit1_space, bit_tolerance) &&
MATCH_TIMING(decoder->timings[5], decoder->protocol->timings.bit1_mark, bit_tolerance)) {
status = InfraredStatusReady;
decoder->timings_cnt = 0;
} else {
status = InfraredStatusError;
}
return status;
}
void* infrared_decoder_samsung32_alloc(void) {
return infrared_common_decoder_alloc(&protocol_samsung32);
}
InfraredMessage* infrared_decoder_samsung32_decode(void* decoder, bool level, uint32_t duration) {
return infrared_common_decode(decoder, level, duration);
}
void infrared_decoder_samsung32_free(void* decoder) {
infrared_common_decoder_free(decoder);
}
void infrared_decoder_samsung32_reset(void* decoder) {
infrared_common_decoder_reset(decoder);
}

View File

@@ -0,0 +1,71 @@
#include "furi/check.h"
#include "common/infrared_common_i.h"
#include <stdint.h>
#include "../infrared_i.h"
#include "infrared_protocol_defs_i.h"
#include <furi.h>
static const uint32_t repeat_timings[] = {
INFRARED_SAMSUNG_REPEAT_PAUSE2,
INFRARED_SAMSUNG_REPEAT_MARK,
INFRARED_SAMSUNG_REPEAT_SPACE,
INFRARED_SAMSUNG_BIT1_MARK,
INFRARED_SAMSUNG_BIT1_SPACE,
INFRARED_SAMSUNG_BIT1_MARK,
};
void infrared_encoder_samsung32_reset(void* encoder_ptr, const InfraredMessage* message) {
furi_assert(encoder_ptr);
InfraredCommonEncoder* encoder = encoder_ptr;
infrared_common_encoder_reset(encoder);
uint8_t address = message->address;
uint8_t command = message->command;
uint8_t command_inverse = ~command;
uint32_t* data = (void*)encoder->data;
*data |= address;
*data |= address << 8;
*data |= command << 16;
*data |= command_inverse << 24;
encoder->bits_to_encode = encoder->protocol->databit_len[0];
}
InfraredStatus infrared_encoder_samsung32_encode_repeat(
InfraredCommonEncoder* encoder,
uint32_t* duration,
bool* level) {
furi_assert(encoder);
/* space + 2 timings preambule + payload + stop bit */
uint32_t timings_encoded_up_to_repeat = 1 + 2 + encoder->bits_encoded * 2 + 1;
uint32_t repeat_cnt = encoder->timings_encoded - timings_encoded_up_to_repeat;
furi_assert(encoder->timings_encoded >= timings_encoded_up_to_repeat);
if(repeat_cnt > 0)
*duration = repeat_timings[repeat_cnt % COUNT_OF(repeat_timings)];
else
*duration = INFRARED_SAMSUNG_REPEAT_PAUSE1;
*level = repeat_cnt % 2;
++encoder->timings_encoded;
bool done = (!((repeat_cnt + 1) % COUNT_OF(repeat_timings)));
return done ? InfraredStatusDone : InfraredStatusOk;
}
void* infrared_encoder_samsung32_alloc(void) {
return infrared_common_encoder_alloc(&protocol_samsung32);
}
void infrared_encoder_samsung32_free(void* encoder_ptr) {
infrared_common_encoder_free(encoder_ptr);
}
InfraredStatus
infrared_encoder_samsung32_encode(void* encoder_ptr, uint32_t* duration, bool* level) {
return infrared_common_encode(encoder_ptr, duration, level);
}

View File

@@ -0,0 +1,17 @@
#include "../infrared_i.h"
#include "infrared_protocol_defs_i.h"
static const InfraredProtocolSpecification infrared_samsung32_protocol_specification = {
.name = "Samsung32",
.address_length = 8,
.command_length = 8,
.frequency = INFRARED_COMMON_CARRIER_FREQUENCY,
.duty_cycle = INFRARED_COMMON_DUTY_CYCLE,
};
const InfraredProtocolSpecification* infrared_samsung32_get_spec(InfraredProtocol protocol) {
if(protocol == InfraredProtocolSamsung32)
return &infrared_samsung32_protocol_specification;
else
return NULL;
}