Change custom btn sending logic

This commit is contained in:
gid9798
2023-05-14 01:34:43 +03:00
parent 71f48ea39e
commit d87df3e6c2
4 changed files with 52 additions and 40 deletions

View File

@@ -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;
}

View File

@@ -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();