[FL-3078] Per protocol signal repeat count (#2293)
* Better Infrared protocol file structure * Rename InfraredProtocolSpec to InfraredProtocolVariant * Slightly better names * Add repeat count field to protocol variant description * Repeat the signal the appropriate number of times when brute-forcing * Repeat the signal the appropriate number of times when sending via worker * Better signal count logic in infrared_transmit * Better variable names * Convert some raw signals to messages in tv.ir Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
#include "infrared.h"
|
||||
#include "infrared_protocol_defs_i.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi.h>
|
||||
#include "../infrared_i.h"
|
||||
#include "infrared_protocol_samsung_i.h"
|
||||
#include <core/check.h>
|
||||
|
||||
InfraredMessage* infrared_decoder_samsung32_check_ready(void* ctx) {
|
||||
return infrared_common_decoder_check_ready(ctx);
|
||||
@@ -57,7 +53,7 @@ InfraredStatus infrared_decoder_samsung32_decode_repeat(InfraredCommonDecoder* d
|
||||
}
|
||||
|
||||
void* infrared_decoder_samsung32_alloc(void) {
|
||||
return infrared_common_decoder_alloc(&protocol_samsung32);
|
||||
return infrared_common_decoder_alloc(&infrared_protocol_samsung32);
|
||||
}
|
||||
|
||||
InfraredMessage* infrared_decoder_samsung32_decode(void* decoder, bool level, uint32_t duration) {
|
||||
|
@@ -1,9 +1,7 @@
|
||||
#include "infrared_protocol_samsung_i.h"
|
||||
|
||||
#include <core/check.h>
|
||||
#include "common/infrared_common_i.h"
|
||||
#include <stdint.h>
|
||||
#include "../infrared_i.h"
|
||||
#include "infrared_protocol_defs_i.h"
|
||||
#include <furi.h>
|
||||
#include <core/common_defines.h>
|
||||
|
||||
static const uint32_t repeat_timings[] = {
|
||||
INFRARED_SAMSUNG_REPEAT_PAUSE2,
|
||||
@@ -58,7 +56,7 @@ InfraredStatus infrared_encoder_samsung32_encode_repeat(
|
||||
}
|
||||
|
||||
void* infrared_encoder_samsung32_alloc(void) {
|
||||
return infrared_common_encoder_alloc(&protocol_samsung32);
|
||||
return infrared_common_encoder_alloc(&infrared_protocol_samsung32);
|
||||
}
|
||||
|
||||
void infrared_encoder_samsung32_free(void* encoder_ptr) {
|
||||
|
@@ -0,0 +1,40 @@
|
||||
#include "infrared_protocol_samsung_i.h"
|
||||
|
||||
const InfraredCommonProtocolSpec infrared_protocol_samsung32 = {
|
||||
.timings =
|
||||
{
|
||||
.preamble_mark = INFRARED_SAMSUNG_PREAMBLE_MARK,
|
||||
.preamble_space = INFRARED_SAMSUNG_PREAMBLE_SPACE,
|
||||
.bit1_mark = INFRARED_SAMSUNG_BIT1_MARK,
|
||||
.bit1_space = INFRARED_SAMSUNG_BIT1_SPACE,
|
||||
.bit0_mark = INFRARED_SAMSUNG_BIT0_MARK,
|
||||
.bit0_space = INFRARED_SAMSUNG_BIT0_SPACE,
|
||||
.preamble_tolerance = INFRARED_SAMSUNG_PREAMBLE_TOLERANCE,
|
||||
.bit_tolerance = INFRARED_SAMSUNG_BIT_TOLERANCE,
|
||||
.silence_time = INFRARED_SAMSUNG_SILENCE,
|
||||
.min_split_time = INFRARED_SAMSUNG_MIN_SPLIT_TIME,
|
||||
},
|
||||
.databit_len[0] = 32,
|
||||
.no_stop_bit = false,
|
||||
.decode = infrared_common_decode_pdwm,
|
||||
.encode = infrared_common_encode_pdwm,
|
||||
.interpret = infrared_decoder_samsung32_interpret,
|
||||
.decode_repeat = infrared_decoder_samsung32_decode_repeat,
|
||||
.encode_repeat = infrared_encoder_samsung32_encode_repeat,
|
||||
};
|
||||
|
||||
static const InfraredProtocolVariant infrared_protocol_variant_samsung32 = {
|
||||
.name = "Samsung32",
|
||||
.address_length = 8,
|
||||
.command_length = 8,
|
||||
.frequency = INFRARED_COMMON_CARRIER_FREQUENCY,
|
||||
.duty_cycle = INFRARED_COMMON_DUTY_CYCLE,
|
||||
.repeat_count = INFRARED_SAMSUNG_REPEAT_COUNT_MIN,
|
||||
};
|
||||
|
||||
const InfraredProtocolVariant* infrared_protocol_samsung32_get_variant(InfraredProtocol protocol) {
|
||||
if(protocol == InfraredProtocolSamsung32)
|
||||
return &infrared_protocol_variant_samsung32;
|
||||
else
|
||||
return NULL;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "../infrared_i.h"
|
||||
|
||||
/***************************************************************************************************
|
||||
* SAMSUNG32 protocol description
|
||||
* https://www.mikrocontroller.net/articles/IRMP_-_english#SAMSUNG
|
||||
****************************************************************************************************
|
||||
* Preamble Preamble Pulse Distance/Width Pause Preamble Preamble Bit1 Stop
|
||||
* mark space Modulation repeat repeat bit
|
||||
* mark space
|
||||
*
|
||||
* 4500 4500 32 bit + stop bit 40000/100000 4500 4500
|
||||
* __________ _ _ _ _ _ _ _ _ _ _ _ ___________ _ _
|
||||
* _ __________ __ _ __ __ __ _ _ __ __ _ ________________ ____________ ____ ___
|
||||
*
|
||||
***************************************************************************************************/
|
||||
|
||||
void* infrared_decoder_samsung32_alloc(void);
|
||||
void infrared_decoder_samsung32_reset(void* decoder);
|
||||
void infrared_decoder_samsung32_free(void* decoder);
|
||||
InfraredMessage* infrared_decoder_samsung32_check_ready(void* ctx);
|
||||
InfraredMessage* infrared_decoder_samsung32_decode(void* decoder, bool level, uint32_t duration);
|
||||
|
||||
InfraredStatus
|
||||
infrared_encoder_samsung32_encode(void* encoder_ptr, uint32_t* duration, bool* level);
|
||||
void infrared_encoder_samsung32_reset(void* encoder_ptr, const InfraredMessage* message);
|
||||
void* infrared_encoder_samsung32_alloc(void);
|
||||
void infrared_encoder_samsung32_free(void* encoder_ptr);
|
||||
|
||||
const InfraredProtocolVariant* infrared_protocol_samsung32_get_variant(InfraredProtocol protocol);
|
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_MARK 4500
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_SPACE 4500
|
||||
#define INFRARED_SAMSUNG_BIT1_MARK 550
|
||||
#define INFRARED_SAMSUNG_BIT1_SPACE 1650
|
||||
#define INFRARED_SAMSUNG_BIT0_MARK 550
|
||||
#define INFRARED_SAMSUNG_BIT0_SPACE 550
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE_MIN 30000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE_MAX 140000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE1 46000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE2 97000
|
||||
#define INFRARED_SAMSUNG_REPEAT_COUNT_MIN 1
|
||||
/* Samsung silence have to be greater than REPEAT MAX
|
||||
* otherwise there can be problems during unit tests parsing
|
||||
* of some data. Real tolerances we don't know, but in real life
|
||||
* silence time should be greater than max repeat time. This is
|
||||
* because of similar preambule timings for repeat and first messages. */
|
||||
#define INFRARED_SAMSUNG_MIN_SPLIT_TIME 5000
|
||||
#define INFRARED_SAMSUNG_SILENCE 145000
|
||||
#define INFRARED_SAMSUNG_REPEAT_MARK 4500
|
||||
#define INFRARED_SAMSUNG_REPEAT_SPACE 4500
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_SAMSUNG_BIT_TOLERANCE 120 // us
|
||||
|
||||
bool infrared_decoder_samsung32_interpret(InfraredCommonDecoder* decoder);
|
||||
InfraredStatus infrared_decoder_samsung32_decode_repeat(InfraredCommonDecoder* decoder);
|
||||
InfraredStatus infrared_encoder_samsung32_encode_repeat(
|
||||
InfraredCommonEncoder* encoder,
|
||||
uint32_t* duration,
|
||||
bool* level);
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_samsung32;
|
@@ -1,17 +0,0 @@
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user