feat(radio): optional key lock feature (#7383)

This commit is contained in:
3djc
2026-07-16 18:54:50 +10:00
committed by GitHub
parent 640fc189e7
commit e184cf3976
111 changed files with 750 additions and 66 deletions
+1
View File
@@ -95,6 +95,7 @@ def generate_from_template(json_filename, template_filename, target):
imu=hw_def.imu,
rotenc=hw_def.rotenc,
haptic=hw_def.haptic,
key_lock_combo=hw_def.key_lock_combo,
)
try:
+11
View File
@@ -0,0 +1,11 @@
//
// WARNING: DO NOT EDIT THIS FILE
// This file has been generated from the target's JSON hardware description
//
#pragma once
{% if key_lock_combo %}
#define KEYS_LOCK_KEY1 {{ key_lock_combo[0] }}
#define KEYS_LOCK_KEY2 {{ key_lock_combo[1] }}
{% endif %}
+24
View File
@@ -423,6 +423,30 @@ class HardwareDefinition(BaseModel):
imu: Optional[IMU] = None
rotenc: Optional[RotEnc] = None
haptic: Optional[Haptic] = None
key_lock_combo: Optional[List[KeyEnum]] = None
@model_validator(mode="after")
def check_key_lock_combo(self: "HardwareDefinition") -> "HardwareDefinition":
if self.key_lock_combo is None:
return self
if len(self.key_lock_combo) != 2:
raise PydanticCustomError(
"KeyLockComboError",
"'key_lock_combo' must list exactly 2 keys",
)
if self.key_lock_combo[0] == self.key_lock_combo[1]:
raise PydanticCustomError(
"KeyLockComboError",
"'key_lock_combo' entries must be distinct",
)
defined = {k.key for k in self.keys}
for k in self.key_lock_combo:
if k not in defined:
raise PydanticCustomError(
"KeyLockComboError",
f"'key_lock_combo' references {k} which is not in 'keys'",
)
return self
@staticmethod
def from_json(data: Union[str, bytes, bytearray]) -> "HardwareDefinition":