mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Security+ 2.0 custom buttons
This commit is contained in:
@@ -83,6 +83,25 @@ const SubGhzProtocol subghz_protocol_secplus_v2 = {
|
||||
.encoder = &subghz_protocol_secplus_v2_encoder,
|
||||
};
|
||||
|
||||
static uint8_t sc_btn_temp_id;
|
||||
static uint8_t sc_btn_temp_id_original;
|
||||
|
||||
void secplus2_set_btn(uint8_t b) {
|
||||
sc_btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t secplus2_get_original_btn() {
|
||||
return sc_btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t secplus2_get_custom_btn() {
|
||||
return sc_btn_temp_id;
|
||||
}
|
||||
|
||||
void secplus2_reset_original_btn() {
|
||||
sc_btn_temp_id_original = 0;
|
||||
}
|
||||
|
||||
void* subghz_protocol_encoder_secplus_v2_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderSecPlus_v2* instance = malloc(sizeof(SubGhzProtocolEncoderSecPlus_v2));
|
||||
@@ -338,6 +357,11 @@ static void
|
||||
instance->btn = 0;
|
||||
instance->serial = 0;
|
||||
}
|
||||
|
||||
// Save original button for later use
|
||||
if(sc_btn_temp_id_original == 0) {
|
||||
sc_btn_temp_id_original = instance->btn;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,6 +397,72 @@ static uint64_t subghz_protocol_secplus_v2_encode_half(uint8_t roll_array[], uin
|
||||
*/
|
||||
|
||||
static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* instance) {
|
||||
// Save original button for later use
|
||||
if(sc_btn_temp_id_original == 0) {
|
||||
sc_btn_temp_id_original = instance->generic.btn;
|
||||
}
|
||||
|
||||
// Set custom button
|
||||
if(sc_btn_temp_id == 1) {
|
||||
switch(sc_btn_temp_id_original) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
if(sc_btn_temp_id == 2) {
|
||||
switch(sc_btn_temp_id_original) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
if(sc_btn_temp_id == 3) {
|
||||
switch(sc_btn_temp_id_original) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
if((sc_btn_temp_id == 0) && (sc_btn_temp_id_original != 0)) {
|
||||
instance->generic.btn = sc_btn_temp_id_original;
|
||||
}
|
||||
uint32_t fixed_1[1] = {instance->generic.btn << 12 | instance->generic.serial >> 20};
|
||||
uint32_t fixed_2[1] = {instance->generic.serial & 0xFFFFF};
|
||||
uint8_t rolling_digits[18] = {0};
|
||||
|
||||
Reference in New Issue
Block a user