mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
SubGhz some changes
This commit is contained in:
@@ -375,6 +375,13 @@ static uint64_t subghz_protocol_secplus_v2_encode_half(uint8_t roll_array[], uin
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the button value for the current btn_id
|
||||
* Basic set | 0x68 | 0x80 | 0x81 | 0xE2 |
|
||||
* @return Button code
|
||||
*/
|
||||
static uint8_t subghz_protocol_secplus_v2_get_btn_code();
|
||||
|
||||
/**
|
||||
* Security+ 2.0 message encoding
|
||||
* @param instance SubGhzProtocolEncoderSecPlus_v2*
|
||||
@@ -386,69 +393,7 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
||||
subghz_custom_btn_set_original(instance->generic.btn);
|
||||
}
|
||||
|
||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||
uint8_t original_btn_code = subghz_custom_btn_get_original();
|
||||
|
||||
// Set custom button
|
||||
// Basic set | 0x68 | 0x80 | 0x81 | 0xE2 |
|
||||
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:
|
||||
instance->generic.btn = 0x80;
|
||||
break;
|
||||
case 0x80:
|
||||
instance->generic.btn = 0x68;
|
||||
break;
|
||||
case 0x81:
|
||||
instance->generic.btn = 0x80;
|
||||
break;
|
||||
case 0xE2:
|
||||
instance->generic.btn = 0x80;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||
switch(original_btn_code) {
|
||||
case 0x68:
|
||||
instance->generic.btn = 0x81;
|
||||
break;
|
||||
case 0x80:
|
||||
instance->generic.btn = 0x81;
|
||||
break;
|
||||
case 0x81:
|
||||
instance->generic.btn = 0x68;
|
||||
break;
|
||||
case 0xE2:
|
||||
instance->generic.btn = 0x81;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||
switch(original_btn_code) {
|
||||
case 0x68:
|
||||
instance->generic.btn = 0xE2;
|
||||
break;
|
||||
case 0x80:
|
||||
instance->generic.btn = 0xE2;
|
||||
break;
|
||||
case 0x81:
|
||||
instance->generic.btn = 0xE2;
|
||||
break;
|
||||
case 0xE2:
|
||||
instance->generic.btn = 0x68;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
instance->generic.btn = subghz_protocol_secplus_v2_get_btn_code();
|
||||
|
||||
uint32_t fixed_1[1] = {instance->generic.btn << 12 | instance->generic.serial >> 20};
|
||||
uint32_t fixed_2[1] = {instance->generic.serial & 0xFFFFF};
|
||||
@@ -888,6 +833,74 @@ SubGhzProtocolStatus
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint8_t subghz_protocol_secplus_v2_get_btn_code() {
|
||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||
uint8_t original_btn_code = subghz_custom_btn_get_original();
|
||||
uint8_t btn = original_btn_code;
|
||||
|
||||
// Set custom button
|
||||
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 0x68:
|
||||
btn = 0x80;
|
||||
break;
|
||||
case 0x80:
|
||||
btn = 0x68;
|
||||
break;
|
||||
case 0x81:
|
||||
btn = 0x80;
|
||||
break;
|
||||
case 0xE2:
|
||||
btn = 0x80;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||
switch(original_btn_code) {
|
||||
case 0x68:
|
||||
btn = 0x81;
|
||||
break;
|
||||
case 0x80:
|
||||
btn = 0x81;
|
||||
break;
|
||||
case 0x81:
|
||||
btn = 0x68;
|
||||
break;
|
||||
case 0xE2:
|
||||
btn = 0x81;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||
switch(original_btn_code) {
|
||||
case 0x68:
|
||||
btn = 0xE2;
|
||||
break;
|
||||
case 0x80:
|
||||
btn = 0xE2;
|
||||
break;
|
||||
case 0x81:
|
||||
btn = 0xE2;
|
||||
break;
|
||||
case 0xE2:
|
||||
btn = 0x68;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_secplus_v2_get_string(void* context, FuriString* output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderSecPlus_v2* instance = context;
|
||||
|
||||
Reference in New Issue
Block a user