mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
Change custom btn sending logic
This commit is contained in:
@@ -156,43 +156,46 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
||||
return true;
|
||||
} // Finish "OK" key processing
|
||||
|
||||
uint8_t temp_btn_id;
|
||||
if(event->key == InputKeyUp) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_UP;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_DOWN;
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_LEFT;
|
||||
} else if(event->key == InputKeyRight) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_RIGHT;
|
||||
} else {
|
||||
// Finish processing if the button is different
|
||||
return true;
|
||||
}
|
||||
if(subghz_custom_btn_is_allowed()) {
|
||||
uint8_t temp_btn_id;
|
||||
if(event->key == InputKeyUp) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_UP;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_DOWN;
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_LEFT;
|
||||
} else if(event->key == InputKeyRight) {
|
||||
temp_btn_id = SUBGHZ_CUSTOM_BTN_RIGHT;
|
||||
} else {
|
||||
// Finish processing if the button is different
|
||||
return true;
|
||||
}
|
||||
|
||||
if(event->type == InputTypePress) {
|
||||
subghz_custom_btn_set(temp_btn_id);
|
||||
with_view_model(
|
||||
subghz_transmitter->view,
|
||||
SubGhzViewTransmitterModel * model,
|
||||
{
|
||||
furi_string_reset(model->temp_button_id);
|
||||
if(subghz_custom_btn_get_original() != 0) {
|
||||
if(subghz_custom_btn_get() == temp_btn_id) {
|
||||
furi_string_printf(
|
||||
model->temp_button_id, "%01X", subghz_custom_btn_get_original());
|
||||
model->draw_temp_button = true;
|
||||
if(event->type == InputTypePress) {
|
||||
with_view_model(
|
||||
subghz_transmitter->view,
|
||||
SubGhzViewTransmitterModel * model,
|
||||
{
|
||||
furi_string_reset(model->temp_button_id);
|
||||
if(subghz_custom_btn_get_original() != 0) {
|
||||
if(subghz_custom_btn_set(temp_btn_id)) {
|
||||
furi_string_printf(
|
||||
model->temp_button_id,
|
||||
"%01X",
|
||||
subghz_custom_btn_get_original());
|
||||
model->draw_temp_button = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
true);
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
|
||||
return true;
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
|
||||
return true;
|
||||
},
|
||||
true);
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
|
||||
return true;
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,26.2,,
|
||||
Version,+,26.3,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@@ -2703,7 +2703,8 @@ Function,+,subghz_block_generic_get_preset_name,void,"const char*, FuriString*"
|
||||
Function,+,subghz_block_generic_serialize,SubGhzProtocolStatus,"SubGhzBlockGeneric*, FlipperFormat*, SubGhzRadioPreset*"
|
||||
Function,-,subghz_custom_btn_get,uint8_t,
|
||||
Function,-,subghz_custom_btn_get_original,uint8_t,
|
||||
Function,-,subghz_custom_btn_set,void,uint8_t
|
||||
Function,-,subghz_custom_btn_is_allowed,_Bool,
|
||||
Function,-,subghz_custom_btn_set,_Bool,uint8_t
|
||||
Function,-,subghz_custom_btn_set_max,void,uint8_t
|
||||
Function,-,subghz_custom_btn_set_original,void,uint8_t
|
||||
Function,-,subghz_custom_btns_reset,void,
|
||||
|
||||
|
@@ -4,11 +4,13 @@ static uint8_t custom_btn_id = SUBGHZ_CUSTOM_BTN_OK;
|
||||
static uint8_t custom_btn_original = 0;
|
||||
static uint8_t custom_btn_max_btns = 0;
|
||||
|
||||
void subghz_custom_btn_set(uint8_t btn_id) {
|
||||
bool subghz_custom_btn_set(uint8_t btn_id) {
|
||||
if(btn_id > custom_btn_max_btns) {
|
||||
custom_btn_id = SUBGHZ_CUSTOM_BTN_OK;
|
||||
return false;
|
||||
} else {
|
||||
custom_btn_id = btn_id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +33,8 @@ void subghz_custom_btn_set_max(uint8_t b) {
|
||||
void subghz_custom_btns_reset() {
|
||||
custom_btn_original = 0;
|
||||
custom_btn_max_btns = 0;
|
||||
}
|
||||
|
||||
bool subghz_custom_btn_is_allowed() {
|
||||
return custom_btn_max_btns != 0;
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
#define SUBGHZ_CUSTOM_BTN_LEFT (3U)
|
||||
#define SUBGHZ_CUSTOM_BTN_RIGHT (4U)
|
||||
|
||||
void subghz_custom_btn_set(uint8_t btn_id);
|
||||
bool subghz_custom_btn_set(uint8_t btn_id);
|
||||
|
||||
uint8_t subghz_custom_btn_get();
|
||||
|
||||
@@ -21,4 +21,6 @@ uint8_t subghz_custom_btn_get_original();
|
||||
|
||||
void subghz_custom_btn_set_max(uint8_t b);
|
||||
|
||||
void subghz_custom_btns_reset();
|
||||
void subghz_custom_btns_reset();
|
||||
|
||||
bool subghz_custom_btn_is_allowed();
|
||||
Reference in New Issue
Block a user