mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
SubGhz custom btn improved code readability some "if" optimization
This commit is contained in:
@@ -76,8 +76,8 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
|||||||
} else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
|
} else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
|
||||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||||
subghz_txrx_stop(subghz->txrx);
|
subghz_txrx_stop(subghz->txrx);
|
||||||
if(subghz_custom_btn_get() != 0) {
|
if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
|
||||||
subghz_custom_btn_set(0);
|
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
|
||||||
uint8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
uint8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
||||||
furi_hal_subghz_set_rolling_counter_mult(0);
|
furi_hal_subghz_set_rolling_counter_mult(0);
|
||||||
// Calling restore!
|
// Calling restore!
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
if(can_be_sent && event->key == InputKeyOk && event->type == InputTypePress) {
|
if(can_be_sent && event->key == InputKeyOk && event->type == InputTypePress) {
|
||||||
subghz_custom_btn_set(0);
|
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_transmitter->view,
|
subghz_transmitter->view,
|
||||||
SubGhzViewTransmitterModel * model,
|
SubGhzViewTransmitterModel * model,
|
||||||
@@ -157,14 +157,14 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
|||||||
|
|
||||||
// Temp Buttons (UP)
|
// Temp Buttons (UP)
|
||||||
if(can_be_sent && event->key == InputKeyUp && event->type == InputTypePress) {
|
if(can_be_sent && event->key == InputKeyUp && event->type == InputTypePress) {
|
||||||
subghz_custom_btn_set(1);
|
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_UP);
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_transmitter->view,
|
subghz_transmitter->view,
|
||||||
SubGhzViewTransmitterModel * model,
|
SubGhzViewTransmitterModel * model,
|
||||||
{
|
{
|
||||||
furi_string_reset(model->temp_button_id);
|
furi_string_reset(model->temp_button_id);
|
||||||
if(subghz_custom_btn_get_original() != 0) {
|
if(subghz_custom_btn_get_original() != 0) {
|
||||||
if(subghz_custom_btn_get() == 1) {
|
if(subghz_custom_btn_get() == SUBGHZ_CUSTOM_BTN_UP) {
|
||||||
furi_string_printf(
|
furi_string_printf(
|
||||||
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
||||||
model->draw_temp_button = true;
|
model->draw_temp_button = true;
|
||||||
@@ -182,14 +182,14 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
|||||||
}
|
}
|
||||||
// Down
|
// Down
|
||||||
if(can_be_sent && event->key == InputKeyDown && event->type == InputTypePress) {
|
if(can_be_sent && event->key == InputKeyDown && event->type == InputTypePress) {
|
||||||
subghz_custom_btn_set(2);
|
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_DOWN);
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_transmitter->view,
|
subghz_transmitter->view,
|
||||||
SubGhzViewTransmitterModel * model,
|
SubGhzViewTransmitterModel * model,
|
||||||
{
|
{
|
||||||
furi_string_reset(model->temp_button_id);
|
furi_string_reset(model->temp_button_id);
|
||||||
if(subghz_custom_btn_get_original() != 0) {
|
if(subghz_custom_btn_get_original() != 0) {
|
||||||
if(subghz_custom_btn_get() == 2) {
|
if(subghz_custom_btn_get() == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||||
furi_string_printf(
|
furi_string_printf(
|
||||||
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
||||||
model->draw_temp_button = true;
|
model->draw_temp_button = true;
|
||||||
@@ -207,14 +207,14 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
|||||||
}
|
}
|
||||||
// Left
|
// Left
|
||||||
if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypePress) {
|
if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypePress) {
|
||||||
subghz_custom_btn_set(3);
|
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_LEFT);
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_transmitter->view,
|
subghz_transmitter->view,
|
||||||
SubGhzViewTransmitterModel * model,
|
SubGhzViewTransmitterModel * model,
|
||||||
{
|
{
|
||||||
furi_string_reset(model->temp_button_id);
|
furi_string_reset(model->temp_button_id);
|
||||||
if(subghz_custom_btn_get_original() != 0) {
|
if(subghz_custom_btn_get_original() != 0) {
|
||||||
if(subghz_custom_btn_get() == 3) {
|
if(subghz_custom_btn_get() == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||||
furi_string_printf(
|
furi_string_printf(
|
||||||
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
||||||
model->draw_temp_button = true;
|
model->draw_temp_button = true;
|
||||||
@@ -232,14 +232,14 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
|||||||
}
|
}
|
||||||
// Right
|
// Right
|
||||||
if(can_be_sent && event->key == InputKeyRight && event->type == InputTypePress) {
|
if(can_be_sent && event->key == InputKeyRight && event->type == InputTypePress) {
|
||||||
subghz_custom_btn_set(4);
|
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_RIGHT);
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_transmitter->view,
|
subghz_transmitter->view,
|
||||||
SubGhzViewTransmitterModel * model,
|
SubGhzViewTransmitterModel * model,
|
||||||
{
|
{
|
||||||
furi_string_reset(model->temp_button_id);
|
furi_string_reset(model->temp_button_id);
|
||||||
if(subghz_custom_btn_get_original() != 0) {
|
if(subghz_custom_btn_get_original() != 0) {
|
||||||
if(subghz_custom_btn_get() == 4) {
|
if(subghz_custom_btn_get() == SUBGHZ_CUSTOM_BTN_RIGHT) {
|
||||||
furi_string_printf(
|
furi_string_printf(
|
||||||
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
||||||
model->draw_temp_button = true;
|
model->draw_temp_button = true;
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ bool subghz_remote_key_load(
|
|||||||
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
subghz_custom_btn_set(0);
|
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
|
||||||
keeloq_reset_original_btn();
|
keeloq_reset_original_btn();
|
||||||
subghz_custom_btns_reset();
|
subghz_custom_btns_reset();
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "custom_btn.h"
|
#include "custom_btn.h"
|
||||||
|
|
||||||
static uint8_t custom_btn_id = 0;
|
static uint8_t custom_btn_id = SUBGHZ_CUSTOM_BTN_OK;
|
||||||
static uint8_t custom_btn_original = 0;
|
static uint8_t custom_btn_original = 0;
|
||||||
static uint8_t custom_btn_max_btns = 0;
|
static uint8_t custom_btn_max_btns = 0;
|
||||||
|
|
||||||
void subghz_custom_btn_set(uint8_t b) {
|
void subghz_custom_btn_set(uint8_t btn_id) {
|
||||||
if(b > custom_btn_max_btns) {
|
if(btn_id > custom_btn_max_btns) {
|
||||||
custom_btn_id = 0;
|
custom_btn_id = SUBGHZ_CUSTOM_BTN_OK;
|
||||||
} else {
|
} else {
|
||||||
custom_btn_id = b;
|
custom_btn_id = btn_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,8 +16,8 @@ uint8_t subghz_custom_btn_get() {
|
|||||||
return custom_btn_id;
|
return custom_btn_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_custom_btn_set_original(uint8_t b) {
|
void subghz_custom_btn_set_original(uint8_t btn_code) {
|
||||||
custom_btn_original = b;
|
custom_btn_original = btn_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t subghz_custom_btn_get_original() {
|
uint8_t subghz_custom_btn_get_original() {
|
||||||
|
|||||||
@@ -4,11 +4,18 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
void subghz_custom_btn_set(uint8_t b);
|
// Default btn ID
|
||||||
|
#define SUBGHZ_CUSTOM_BTN_OK (0U)
|
||||||
|
#define SUBGHZ_CUSTOM_BTN_UP (1U)
|
||||||
|
#define SUBGHZ_CUSTOM_BTN_DOWN (2U)
|
||||||
|
#define SUBGHZ_CUSTOM_BTN_LEFT (3U)
|
||||||
|
#define SUBGHZ_CUSTOM_BTN_RIGHT (4U)
|
||||||
|
|
||||||
|
void subghz_custom_btn_set(uint8_t btn_id);
|
||||||
|
|
||||||
uint8_t subghz_custom_btn_get();
|
uint8_t subghz_custom_btn_get();
|
||||||
|
|
||||||
void subghz_custom_btn_set_original(uint8_t b);
|
void subghz_custom_btn_set_original(uint8_t btn_code);
|
||||||
|
|
||||||
uint8_t subghz_custom_btn_get_original();
|
uint8_t subghz_custom_btn_get_original();
|
||||||
|
|
||||||
|
|||||||
@@ -334,11 +334,15 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
uint8_t original_btn_code = subghz_custom_btn_get_original();
|
||||||
|
|
||||||
// Set custom button
|
// Set custom button
|
||||||
if(custom_btn_id == 1) {
|
// Basic set | 0x11 | 0x22 | 0xFF | 0x44 | 0x33 |
|
||||||
switch(original_btn_num) {
|
if((custom_btn_id == SUBGHZ_CUSTOM_BTN_OK) && (original_btn_code != 0)) {
|
||||||
|
// Restore original button code
|
||||||
|
btn = original_btn_code;
|
||||||
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_UP) {
|
||||||
|
switch(original_btn_code) {
|
||||||
case 0x11:
|
case 0x11:
|
||||||
btn = 0x22;
|
btn = 0x22;
|
||||||
break;
|
break;
|
||||||
@@ -358,9 +362,8 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||||
if(custom_btn_id == 2) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x11:
|
case 0x11:
|
||||||
btn = 0x44;
|
btn = 0x44;
|
||||||
break;
|
break;
|
||||||
@@ -380,9 +383,8 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||||
if(custom_btn_id == 3) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x11:
|
case 0x11:
|
||||||
btn = 0x33;
|
btn = 0x33;
|
||||||
break;
|
break;
|
||||||
@@ -402,9 +404,8 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_RIGHT) {
|
||||||
if(custom_btn_id == 4) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x11:
|
case 0x11:
|
||||||
btn = 0xFF;
|
btn = 0xFF;
|
||||||
break;
|
break;
|
||||||
@@ -426,9 +427,6 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
|
||||||
btn = original_btn_num;
|
|
||||||
}
|
|
||||||
// Gen new key
|
// Gen new key
|
||||||
if(!subghz_protocol_alutech_at_4n_gen_data(instance, btn)) {
|
if(!subghz_protocol_alutech_at_4n_gen_data(instance, btn)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -397,10 +397,15 @@ static bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
uint8_t original_btn_code = subghz_custom_btn_get_original();
|
||||||
|
|
||||||
// Set custom button
|
// Set custom button
|
||||||
if(custom_btn_id == 1) {
|
// Basic set | 0x1 | 0x2 | 0x4 | 0x8 | 0xA or Special Learning Code |
|
||||||
switch(original_btn_num) {
|
if((custom_btn_id == SUBGHZ_CUSTOM_BTN_OK) && (original_btn_code != 0)) {
|
||||||
|
// Restore original button code
|
||||||
|
btn = original_btn_code;
|
||||||
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_UP) {
|
||||||
|
switch(original_btn_code) {
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x2;
|
btn = 0x2;
|
||||||
break;
|
break;
|
||||||
@@ -424,9 +429,8 @@ static bool
|
|||||||
btn = 0x1;
|
btn = 0x1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||||
if(custom_btn_id == 2) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x4;
|
btn = 0x4;
|
||||||
break;
|
break;
|
||||||
@@ -450,9 +454,8 @@ static bool
|
|||||||
btn = 0x4;
|
btn = 0x4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||||
if(custom_btn_id == 3) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x8;
|
btn = 0x8;
|
||||||
break;
|
break;
|
||||||
@@ -476,9 +479,8 @@ static bool
|
|||||||
btn = 0x8;
|
btn = 0x8;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_RIGHT) {
|
||||||
if(custom_btn_id == 4) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = klq_last_custom_btn;
|
btn = klq_last_custom_btn;
|
||||||
break;
|
break;
|
||||||
@@ -503,11 +505,8 @@ static bool
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
|
||||||
btn = original_btn_num;
|
|
||||||
}
|
|
||||||
// Generate new key
|
// Generate new key
|
||||||
|
|
||||||
if(subghz_protocol_keeloq_gen_data(instance, btn, true)) {
|
if(subghz_protocol_keeloq_gen_data(instance, btn, true)) {
|
||||||
// OK
|
// OK
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -136,11 +136,15 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
uint8_t original_btn_code = subghz_custom_btn_get_original();
|
||||||
|
|
||||||
// Set custom button
|
// Set custom button
|
||||||
if(custom_btn_id == 1) {
|
// Basic set | 0x1 | 0x2 | 0x4 | 0x8 |
|
||||||
switch(original_btn_num) {
|
if((custom_btn_id == SUBGHZ_CUSTOM_BTN_OK) && (original_btn_code != 0)) {
|
||||||
|
// Restore original button code
|
||||||
|
btn = original_btn_code;
|
||||||
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_UP) {
|
||||||
|
switch(original_btn_code) {
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x2;
|
btn = 0x2;
|
||||||
break;
|
break;
|
||||||
@@ -157,9 +161,8 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||||
if(custom_btn_id == 2) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x4;
|
btn = 0x4;
|
||||||
break;
|
break;
|
||||||
@@ -176,9 +179,8 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||||
if(custom_btn_id == 3) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x8;
|
btn = 0x8;
|
||||||
break;
|
break;
|
||||||
@@ -197,10 +199,6 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
|
||||||
btn = original_btn_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size_upload = ((instance->generic.data_count_bit * 2) + ((37 + 2 + 2) * 2) * 16);
|
size_t size_upload = ((instance->generic.data_count_bit * 2) + ((37 + 2 + 2) * 2) * 16);
|
||||||
if(size_upload > instance->encoder.size_upload) {
|
if(size_upload > instance->encoder.size_upload) {
|
||||||
FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer.");
|
FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer.");
|
||||||
|
|||||||
@@ -387,11 +387,15 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
uint8_t original_btn_code = subghz_custom_btn_get_original();
|
||||||
|
|
||||||
// Set custom button
|
// Set custom button
|
||||||
if(custom_btn_id == 1) {
|
// Basic set | 0x68 | 0x80 | 0x81 | 0xE2 |
|
||||||
switch(original_btn_num) {
|
if((custom_btn_id == SUBGHZ_CUSTOM_BTN_OK) && (original_btn_code != 0)) {
|
||||||
|
// Restore original button code
|
||||||
|
instance->generic.btn = original_btn_code;
|
||||||
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_UP) {
|
||||||
|
switch(original_btn_code) {
|
||||||
case 0x68:
|
case 0x68:
|
||||||
instance->generic.btn = 0x80;
|
instance->generic.btn = 0x80;
|
||||||
break;
|
break;
|
||||||
@@ -408,9 +412,8 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||||
if(custom_btn_id == 2) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x68:
|
case 0x68:
|
||||||
instance->generic.btn = 0x81;
|
instance->generic.btn = 0x81;
|
||||||
break;
|
break;
|
||||||
@@ -427,9 +430,8 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||||
if(custom_btn_id == 3) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x68:
|
case 0x68:
|
||||||
instance->generic.btn = 0xE2;
|
instance->generic.btn = 0xE2;
|
||||||
break;
|
break;
|
||||||
@@ -447,9 +449,7 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
|
||||||
instance->generic.btn = original_btn_num;
|
|
||||||
}
|
|
||||||
uint32_t fixed_1[1] = {instance->generic.btn << 12 | instance->generic.serial >> 20};
|
uint32_t fixed_1[1] = {instance->generic.btn << 12 | instance->generic.serial >> 20};
|
||||||
uint32_t fixed_2[1] = {instance->generic.serial & 0xFFFFF};
|
uint32_t fixed_2[1] = {instance->generic.serial & 0xFFFFF};
|
||||||
uint8_t rolling_digits[18] = {0};
|
uint8_t rolling_digits[18] = {0};
|
||||||
|
|||||||
@@ -116,11 +116,15 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
uint8_t original_btn_code = subghz_custom_btn_get_original();
|
||||||
|
|
||||||
// Set custom button
|
// Set custom button
|
||||||
if(custom_btn_id == 1) {
|
// Basic set | 0x1 | 0x2 | 0x4 | 0x8 |
|
||||||
switch(original_btn_num) {
|
if((custom_btn_id == SUBGHZ_CUSTOM_BTN_OK) && (original_btn_code != 0)) {
|
||||||
|
// Restore original button code
|
||||||
|
btn = original_btn_code;
|
||||||
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_UP) {
|
||||||
|
switch(original_btn_code) {
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x2;
|
btn = 0x2;
|
||||||
break;
|
break;
|
||||||
@@ -137,9 +141,8 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||||
if(custom_btn_id == 2) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x4;
|
btn = 0x4;
|
||||||
break;
|
break;
|
||||||
@@ -156,9 +159,8 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||||
if(custom_btn_id == 3) {
|
switch(original_btn_code) {
|
||||||
switch(original_btn_num) {
|
|
||||||
case 0x1:
|
case 0x1:
|
||||||
btn = 0x8;
|
btn = 0x8;
|
||||||
break;
|
break;
|
||||||
@@ -177,10 +179,6 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
|
||||||
btn = original_btn_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(instance->generic.cnt < 0xFFFF) {
|
if(instance->generic.cnt < 0xFFFF) {
|
||||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) >= 0xFFFF) {
|
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) >= 0xFFFF) {
|
||||||
instance->generic.cnt = 0;
|
instance->generic.cnt = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user