mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Add long press command
This commit is contained in:
@@ -1318,9 +1318,12 @@ class HWButtonSettingsGet(DeviceRequiredUnit):
|
||||
print("")
|
||||
for button in button_list:
|
||||
resp = self.cmd.get_button_press_fun(button)
|
||||
resp_long = self.cmd.get_long_button_press_fun(button)
|
||||
button_fn = chameleon_cmd.ButtonPressFunction.from_int(resp.data[0])
|
||||
button_long_fn = chameleon_cmd.ButtonPressFunction.from_int(resp_long.data[0])
|
||||
print(f" - {colorama.Fore.GREEN}{button}{colorama.Style.RESET_ALL}: {button_fn}")
|
||||
print(f" usage: {button_fn.usage()}")
|
||||
print(f" long press usage: {button_long_fn.usage()}")
|
||||
print("")
|
||||
print(" - Successfully get button function from settings")
|
||||
|
||||
@@ -1330,6 +1333,7 @@ class HWButtonSettingsSet(DeviceRequiredUnit):
|
||||
|
||||
def args_parser(self) -> ArgumentParserNoExit:
|
||||
parser = ArgumentParserNoExit()
|
||||
parser.add_argument('-l', '--long', type=int, required=True, help="1 is Long or 0 Short", choices=[0, 1])
|
||||
parser.add_argument('-b', type=str, required=True,
|
||||
help="Change the function of the pressed button(?).",
|
||||
choices=chameleon_cmd.ButtonType.list_str())
|
||||
@@ -1344,5 +1348,9 @@ class HWButtonSettingsSet(DeviceRequiredUnit):
|
||||
def on_exec(self, args: argparse.Namespace):
|
||||
button = chameleon_cmd.ButtonType.from_str(args.b)
|
||||
function = chameleon_cmd.ButtonPressFunction.from_int(args.f)
|
||||
self.cmd.set_button_press_fun(button, function)
|
||||
long = args.l == 1
|
||||
if long:
|
||||
self.cmd.set_long_button_press_fun(button, function)
|
||||
else:
|
||||
self.cmd.set_button_press_fun(button, function)
|
||||
print(" - Successfully set button function to settings")
|
||||
|
||||
@@ -42,6 +42,9 @@ DATA_CMD_GET_BATTERY_INFO = 1025
|
||||
DATA_CMD_GET_BUTTON_PRESS_CONFIG = 1026
|
||||
DATA_CMD_SET_BUTTON_PRESS_CONFIG = 1027
|
||||
|
||||
DATA_CMD_GET_LONG_BUTTON_PRESS_CONFIG = 1028
|
||||
DATA_CMD_SET_LONG_BUTTON_PRESS_CONFIG = 1029
|
||||
|
||||
DATA_CMD_SCAN_14A_TAG = 2000
|
||||
DATA_CMD_MF1_SUPPORT_DETECT = 2001
|
||||
DATA_CMD_MF1_NT_LEVEL_DETECT = 2002
|
||||
@@ -769,6 +772,24 @@ class ChameleonCMD:
|
||||
bytearray([button, function])
|
||||
)
|
||||
|
||||
@expect_response(chameleon_status.Device.STATUS_DEVICE_SUCCESS)
|
||||
def get_long_button_press_fun(self, button: ButtonType):
|
||||
"""
|
||||
Get config of button press function
|
||||
"""
|
||||
return self.device.send_cmd_sync(DATA_CMD_GET_LONG_BUTTON_PRESS_CONFIG, 0x00, bytearray([button]))
|
||||
|
||||
@expect_response(chameleon_status.Device.STATUS_DEVICE_SUCCESS)
|
||||
def set_long_button_press_fun(self, button: ButtonType, function: ButtonPressFunction):
|
||||
"""
|
||||
Set config of button press function
|
||||
"""
|
||||
return self.device.send_cmd_sync(
|
||||
DATA_CMD_SET_LONG_BUTTON_PRESS_CONFIG,
|
||||
0x00,
|
||||
bytearray([button, function])
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# connect to chameleon
|
||||
dev = chameleon_com.ChameleonCom()
|
||||
|
||||
Reference in New Issue
Block a user