btn_is_available = true

This commit is contained in:
Dmitry422
2026-02-02 01:22:39 +07:00
parent 0eae6030b0
commit 1d32d1de5c
61 changed files with 675 additions and 332 deletions

View File

@@ -17,7 +17,7 @@ void subghz_block_generic_global_counter_override_set(uint32_t counter) {
bool subghz_block_generic_global_counter_override_get(uint32_t* counter) {
// if override flag was enabled then return succes TRUE and return overrided counter, else return success = FALSE
// we cut counter bit length to available protocol bits length by the logical AND function
// we cut counter bits length to available protocol bits length by the logical AND function
if(subghz_block_generic_global.cnt_need_override) {
*counter = subghz_block_generic_global.new_cnt &
((0xFFFFFFFF >> (32 - subghz_block_generic_global.cnt_length_bit)));
@@ -28,9 +28,30 @@ bool subghz_block_generic_global_counter_override_get(uint32_t* counter) {
}
}
void subghz_block_generic_global_button_override_set(uint8_t button) {
subghz_block_generic_global.new_btn = button; // set global variable
subghz_block_generic_global.btn_need_override = true; // set flag for protocols
}
bool subghz_block_generic_global_button_override_get(uint8_t* button) {
// if override flag was enabled then return succes TRUE and return overrided button, else return success = FALSE
// we cut button bits length to available protocol bits length by the logical AND function
if(subghz_block_generic_global.btn_need_override) {
*button = subghz_block_generic_global.new_btn &
((0xFF >> (8 - subghz_block_generic_global.btn_length_bit)));
subghz_block_generic_global.btn_need_override = false;
return true;
} else {
return false;
}
}
void subghz_block_generic_global_reset(void* p) {
UNUSED(p);
// dont reset endless_tx, its used in protocols yield function to undless TX
bool tmp = subghz_block_generic_global.endless_tx;
memset(&subghz_block_generic_global, 0, sizeof(subghz_block_generic_global));
subghz_block_generic_global.endless_tx = tmp;
}
void subghz_block_generic_get_preset_name(const char* preset_name, FuriString* preset_str) {

View File

@@ -30,35 +30,49 @@ struct SubGhzBlockGeneric {
typedef struct SubGhzBlockGenericGlobal SubGhzBlockGenericGlobal;
struct SubGhzBlockGenericGlobal {
uint32_t current_cnt; // global counter value;
uint32_t new_cnt; // global counter value;
uint32_t current_cnt; // current counter value;
uint32_t new_cnt; // new counter value;
bool cnt_need_override; // flag for protocols to override signals counter inside of protocols
uint8_t cnt_length_bit; // counter length in bytes (used in counter editor giu)
uint8_t cnt_length_bit; // counter length in bits (used in counter editor giu)
bool cnt_is_available; // is there counter available for protocol (used in counter editor giu)
uint8_t current_btn; // global counter value;
uint8_t new_btn; // global counter value;
bool btn_need_override; // flag for protocols to override signals counter inside of protocols
bool btn_is_available; // is there counter available for protocol (used in counter editor giu)
uint8_t current_btn; // current button value;
uint8_t new_btn; // new button value;
bool btn_need_override; // flag for protocols to override button inside of protocols
uint8_t btn_length_bit; // button length in bits (used in counter editor giu)
bool btn_is_available; // is there button available for protocol (used in button editor giu)
bool endless_tx; // used for endless/breakless transmission in subghz protols (when user not release OK button)
bool endless_tx; // used for endless/breakless transmission in subghz protols yield function (when user hold OK button)
};
extern SubGhzBlockGenericGlobal subghz_block_generic_global; //global structure for subghz
/**
* Setup SubGhzBlockGenericGlobal.cnt and cnt_need_override flag to be used in protocols;
* Setup new_cnt and cnt_need_override flag to be used in protocols;
* @param counter new counter value;
*/
void subghz_block_generic_global_counter_override_set(uint32_t counter);
/**
* Return true if incomming variable was overrided by SubGhzBlockGenericGlobal.cnt
* Return true if incomming variable was overrided by new_cnt
* else return false and not change incomming variable
* @param counter pointer to counter variable that must be changed
*/
bool subghz_block_generic_global_counter_override_get(uint32_t* counter);
/**
* Setup new_btn and btn_need_override flag to be used in protocols;
* @param button new button value;
*/
void subghz_block_generic_global_button_override_set(uint8_t button);
/**
* Return true if incomming variable was overrided by new_btn
* else return false and not change incomming variable
* @param button pointer to counter variable that must be changed
*/
bool subghz_block_generic_global_button_override_get(uint8_t* button);
/**
* Reset subghz_block_generic global structure;
*/