From 388b2a6e595fe33dc21162563fbed8afe1020f9c Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Sun, 9 Jun 2024 14:24:46 -0400 Subject: [PATCH] Fix custom actions for tails and wings --- CHANGELOG.md | 3 ++- lib/Backend/move_lists.dart | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b443f8fe1..4beaaa4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,4 +33,5 @@ Theres so many improvements over our old app - heres the headlines ### V 1.0.3 - Changed trigger select button to be more visible -- Reload actions when glowtip is found \ No newline at end of file +- Reload actions when glowtip is found +- Fix Custom Actions not working on tails and wings \ No newline at end of file diff --git a/lib/Backend/move_lists.dart b/lib/Backend/move_lists.dart index 2eb06e5c8..dabb1d616 100644 --- a/lib/Backend/move_lists.dart +++ b/lib/Backend/move_lists.dart @@ -221,7 +221,13 @@ Future runAction(BaseAction action, BaseStatefulDevice device) async { plausible.event(name: "Run Sequence", props: {"Sequence Repeat": action.repeat.toInt().toString(), "Sequence Device Type": device.baseDeviceDefinition.deviceType.name, "Sequence Moves": action.moves.length.toString()}); if (action.moves.isNotEmpty && action.moves.length <= 5 && device.baseDeviceDefinition.deviceType != DeviceType.ears) { int preset = 1; //TODO: store - String cmd = "USERMOVE U${preset}P${action.moves.length}N${action.repeat.toInt()}H1"; + String cmd = "USERMOVE U${preset}P${action.moves.length}N${action.repeat.toInt() - 1}"; + String a = ''; + String b = ''; + String e = ''; + String f = ''; + String sl = ''; + String m = ''; for (int i = 0; i < action.moves.length; i++) { Move move = action.moves[i]; if (i == 0 && move.moveType == MoveType.delay) { @@ -230,11 +236,22 @@ Future runAction(BaseAction action, BaseStatefulDevice device) async { if (move.moveType == MoveType.delay) { if (i > 0 && action.moves[i + 1].moveType == MoveType.move) { Move prevMove = action.moves[i + 1]; - cmd = "$cmd E${prevMove.easingType.num}F${prevMove.easingType.num}A${prevMove.leftServo.round().clamp(0, 128) ~/ 16}B${prevMove.rightServo.round().clamp(0, 128) ~/ 16}S${move.time.toInt()}"; + e = '${e}E${prevMove.easingType.num}'; + f = '${f}F${prevMove.easingType.num}'; + a = '${a}A${prevMove.leftServo.round().clamp(0, 128) ~/ 16}'; + b = '${b}B${prevMove.rightServo.round().clamp(0, 128) ~/ 16}'; + sl = '${sl}S${move.speed.toInt()}'; + m = '${m}M${move.speed.toInt()}'; } } - cmd = "$cmd E${move.easingType.num}F${move.easingType.num}A${move.leftServo.round().clamp(0, 128) ~/ 16}B${move.rightServo.round().clamp(0, 128) ~/ 16}L${move.speed.toInt()}"; + e = '${e}E${move.easingType.num}'; + f = '${f}F${move.easingType.num}'; + a = '${a}A${move.leftServo.round().clamp(0, 128) ~/ 16}'; + b = '${b}B${move.rightServo.round().clamp(0, 128) ~/ 16}'; + sl = '${sl}L${move.speed.toInt()}'; + m = '${m}M${move.speed.toInt()}'; } + cmd = '$cmd $a $b $e $f $sl H1'; device.commandQueue.addCommand(BluetoothMessage(message: cmd, device: device, priority: Priority.normal, type: CommandType.move)); device.commandQueue.addCommand(BluetoothMessage(message: "TAILU$preset", device: device, priority: Priority.normal, responseMSG: "TAILU$preset END", type: CommandType.move)); } else {