SubGhz: add protocol MegaCode (#1204)
* SubGhz: add protocol MegaCode * SubGhz: check for guard time injection at the end of buffer * SubGhz: rollback samples counting in trasmitter * SubGhz: fix subghz_file_encoder_worker incorrect pulse sequence * Input: tune debounce interval * SubGhz: fix spelling in subghz_file_encoder_worker_add_level_duration Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@ struct SubGhzFileEncoderWorker {
|
||||
volatile bool worker_running;
|
||||
volatile bool worker_stoping;
|
||||
bool level;
|
||||
int32_t duration;
|
||||
string_t str_data;
|
||||
string_t file_path;
|
||||
|
||||
@@ -37,25 +36,21 @@ void subghz_file_encoder_worker_callback_end(
|
||||
instance->context_end = context_end;
|
||||
}
|
||||
|
||||
void subghz_file_encoder_worker_add_livel_duration(
|
||||
void subghz_file_encoder_worker_add_level_duration(
|
||||
SubGhzFileEncoderWorker* instance,
|
||||
int32_t duration) {
|
||||
bool res = true;
|
||||
if(duration < 0 && !instance->level) {
|
||||
instance->duration += duration;
|
||||
res = false;
|
||||
} else if(duration > 0 && instance->level) {
|
||||
instance->duration += duration;
|
||||
res = false;
|
||||
} else if(duration == 0) {
|
||||
instance->duration = 0;
|
||||
}
|
||||
|
||||
if(res) {
|
||||
instance->level = !instance->level;
|
||||
instance->duration += duration;
|
||||
xStreamBufferSend(instance->stream, &instance->duration, sizeof(int32_t), 10);
|
||||
instance->duration = 0;
|
||||
xStreamBufferSend(instance->stream, &duration, sizeof(int32_t), 100);
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Invalid level in the stream");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +75,7 @@ bool subghz_file_encoder_worker_data_parse(
|
||||
ind_start))) { //check that there is still an element in the line and that it has not gone beyond the line
|
||||
str1 = strchr(str1, ' ');
|
||||
str1 += 1; //if found, shift the pointer by next element per line
|
||||
subghz_file_encoder_worker_add_livel_duration(instance, atoi(str1));
|
||||
subghz_file_encoder_worker_add_level_duration(instance, atoi(str1));
|
||||
}
|
||||
res = true;
|
||||
}
|
||||
@@ -152,14 +147,14 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
|
||||
string_get_cstr(instance->str_data),
|
||||
strlen(string_get_cstr(instance->str_data)))) {
|
||||
//to stop DMA correctly
|
||||
subghz_file_encoder_worker_add_livel_duration(instance, LEVEL_DURATION_RESET);
|
||||
subghz_file_encoder_worker_add_livel_duration(instance, LEVEL_DURATION_RESET);
|
||||
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
|
||||
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
subghz_file_encoder_worker_add_livel_duration(instance, LEVEL_DURATION_RESET);
|
||||
subghz_file_encoder_worker_add_livel_duration(instance, LEVEL_DURATION_RESET);
|
||||
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
|
||||
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user