Skip to content

Commit

Permalink
Fix custom actions for tails and wings
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 9, 2024
1 parent 7d8df92 commit 388b2a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- Reload actions when glowtip is found
- Fix Custom Actions not working on tails and wings
23 changes: 20 additions & 3 deletions lib/Backend/move_lists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ Future<void> 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) {
Expand All @@ -230,11 +236,22 @@ Future<void> 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 {
Expand Down

0 comments on commit 388b2a6

Please sign in to comment.