mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
princeton add support for different button coding type [ci skip]
This commit is contained in:
@@ -134,9 +134,21 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) {
|
|||||||
case 0xF:
|
case 0xF:
|
||||||
btn = 0x2;
|
btn = 0x2;
|
||||||
break;
|
break;
|
||||||
|
// Second encoding type
|
||||||
|
case 0x30:
|
||||||
|
btn = 0xC0;
|
||||||
|
break;
|
||||||
|
case 0xC0:
|
||||||
|
btn = 0x30;
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
btn = 0xC0;
|
||||||
|
break;
|
||||||
|
case 0x0C:
|
||||||
|
btn = 0xC0;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
btn = 0x2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) {
|
||||||
@@ -156,9 +168,21 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) {
|
|||||||
case 0xF:
|
case 0xF:
|
||||||
btn = 0x1;
|
btn = 0x1;
|
||||||
break;
|
break;
|
||||||
|
// Second encoding type
|
||||||
|
case 0x30:
|
||||||
|
btn = 0x03;
|
||||||
|
break;
|
||||||
|
case 0xC0:
|
||||||
|
btn = 0x03;
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
btn = 0x30;
|
||||||
|
break;
|
||||||
|
case 0x0C:
|
||||||
|
btn = 0x03;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
btn = 0x1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) {
|
||||||
@@ -178,9 +202,21 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) {
|
|||||||
case 0xF:
|
case 0xF:
|
||||||
btn = 0x4;
|
btn = 0x4;
|
||||||
break;
|
break;
|
||||||
|
// Second encoding type
|
||||||
|
case 0x30:
|
||||||
|
btn = 0x0C;
|
||||||
|
break;
|
||||||
|
case 0xC0:
|
||||||
|
btn = 0x0C;
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
btn = 0x0C;
|
||||||
|
break;
|
||||||
|
case 0x0C:
|
||||||
|
btn = 0x30;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
btn = 0x4;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_RIGHT) {
|
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_RIGHT) {
|
||||||
@@ -202,7 +238,6 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
btn = 0x8;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,8 +258,15 @@ static bool
|
|||||||
instance->generic.btn = subghz_protocol_princeton_get_btn_code();
|
instance->generic.btn = subghz_protocol_princeton_get_btn_code();
|
||||||
|
|
||||||
// Reconstruction of the data
|
// Reconstruction of the data
|
||||||
instance->generic.data =
|
// If we have 8bit button code move serial to left by 8 bits (and 4 if 4 bits)
|
||||||
((uint64_t)instance->generic.serial << 4 | (uint64_t)instance->generic.btn);
|
if(instance->generic.btn == 0x30 || instance->generic.btn == 0xC0 ||
|
||||||
|
instance->generic.btn == 0x03 || instance->generic.btn == 0x0C) {
|
||||||
|
instance->generic.data =
|
||||||
|
((uint64_t)instance->generic.serial << 8 | (uint64_t)instance->generic.btn);
|
||||||
|
} else {
|
||||||
|
instance->generic.data =
|
||||||
|
((uint64_t)instance->generic.serial << 4 | (uint64_t)instance->generic.btn);
|
||||||
|
}
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
size_t size_upload = (instance->generic.data_count_bit * 2) + 2;
|
size_t size_upload = (instance->generic.data_count_bit * 2) + 2;
|
||||||
@@ -264,8 +306,17 @@ static bool
|
|||||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||||
*/
|
*/
|
||||||
static void subghz_protocol_princeton_check_remote_controller(SubGhzBlockGeneric* instance) {
|
static void subghz_protocol_princeton_check_remote_controller(SubGhzBlockGeneric* instance) {
|
||||||
instance->serial = instance->data >> 4;
|
// Parse button modes for second encoding type (and serial is smaller)
|
||||||
instance->btn = instance->data & 0xF;
|
// Button code is 8bit and has fixed values of one of these
|
||||||
|
// Exclude button code for each type from serial number before parsing
|
||||||
|
if((instance->data & 0xFF) == 0x30 || (instance->data & 0xFF) == 0xC0 ||
|
||||||
|
(instance->data & 0xFF) == 0x03 || (instance->data & 0xFF) == 0x0C) {
|
||||||
|
instance->serial = instance->data >> 8;
|
||||||
|
instance->btn = instance->data & 0xFF;
|
||||||
|
} else {
|
||||||
|
instance->serial = instance->data >> 4;
|
||||||
|
instance->btn = instance->data & 0xF;
|
||||||
|
}
|
||||||
|
|
||||||
// Save original button for later use
|
// Save original button for later use
|
||||||
if(subghz_custom_btn_get_original() == 0) {
|
if(subghz_custom_btn_get_original() == 0) {
|
||||||
@@ -533,19 +584,38 @@ void subghz_protocol_decoder_princeton_get_string(void* context, FuriString* out
|
|||||||
uint32_t data_rev = subghz_protocol_blocks_reverse_key(
|
uint32_t data_rev = subghz_protocol_blocks_reverse_key(
|
||||||
instance->generic.data, instance->generic.data_count_bit);
|
instance->generic.data, instance->generic.data_count_bit);
|
||||||
|
|
||||||
furi_string_cat_printf(
|
if(instance->generic.btn == 0x30 || instance->generic.btn == 0xC0 ||
|
||||||
output,
|
instance->generic.btn == 0x03 || instance->generic.btn == 0x0C) {
|
||||||
"%s %dbit\r\n"
|
furi_string_cat_printf(
|
||||||
"Key:0x%08lX\r\n"
|
output,
|
||||||
"Yek:0x%08lX\r\n"
|
"%s %dbit\r\n"
|
||||||
"Sn:0x%05lX Btn:%01X\r\n"
|
"Key:0x%08lX\r\n"
|
||||||
"Te:%luus GT:Te*%lu\r\n",
|
"Yek:0x%08lX\r\n"
|
||||||
instance->generic.protocol_name,
|
"Sn:0x%05lX Btn:%02X (8b)\r\n"
|
||||||
instance->generic.data_count_bit,
|
"Te:%luus GT:Te*%lu\r\n",
|
||||||
(uint32_t)(instance->generic.data & 0xFFFFFF),
|
instance->generic.protocol_name,
|
||||||
data_rev,
|
instance->generic.data_count_bit,
|
||||||
instance->generic.serial,
|
(uint32_t)(instance->generic.data & 0xFFFFFF),
|
||||||
instance->generic.btn,
|
data_rev,
|
||||||
instance->te,
|
instance->generic.serial,
|
||||||
instance->guard_time);
|
instance->generic.btn,
|
||||||
|
instance->te,
|
||||||
|
instance->guard_time);
|
||||||
|
} else {
|
||||||
|
furi_string_cat_printf(
|
||||||
|
output,
|
||||||
|
"%s %dbit\r\n"
|
||||||
|
"Key:0x%08lX\r\n"
|
||||||
|
"Yek:0x%08lX\r\n"
|
||||||
|
"Sn:0x%05lX Btn:%01X (4b)\r\n"
|
||||||
|
"Te:%luus GT:Te*%lu\r\n",
|
||||||
|
instance->generic.protocol_name,
|
||||||
|
instance->generic.data_count_bit,
|
||||||
|
(uint32_t)(instance->generic.data & 0xFFFFFF),
|
||||||
|
data_rev,
|
||||||
|
instance->generic.serial,
|
||||||
|
instance->generic.btn,
|
||||||
|
instance->te,
|
||||||
|
instance->guard_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user