Skip to content

Commit

Permalink
Replace ear moves with sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Mar 3, 2024
1 parent dc4bf57 commit 249ebcb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 9 deletions.
50 changes: 46 additions & 4 deletions lib/Backend/ActionRegistry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,52 @@ class ActionRegistry {
CommandAction("SOS", "LEDSOS", [DeviceType.tail], ActionCategory.glowtip, null, "66164945-840f-4302-b27c-e7a7623bf475"),
CommandAction("Beacon", "LEDBEA", [DeviceType.tail], ActionCategory.glowtip, null, "4955a936-7703-4ce6-8d4a-b18857c0ea0a"),
CommandAction("Flame", "LEDFLA", [DeviceType.tail], ActionCategory.glowtip, null, "e46566b4-1071-4866-815b-1aefbf06b573"),
CommandAction("Left Twist", "LETWIST", [DeviceType.ears], ActionCategory.ears, "LETWIST END", "0d5a9dfa-38f2-4b09-9be1-cd36236a03b0"),
CommandAction("Right Twist", "RITWIST", [DeviceType.ears], ActionCategory.ears, "RITWIST END", "9a6be63e-36f5-4f50-88b6-7adf2680aa5c"),
CommandAction("Both Twist", "BOTWIST", [DeviceType.ears], ActionCategory.ears, "BOTWIST END", "2bc43e6c-65e7-4a35-834e-b2c31b8f83fe"),
CommandAction("Home Ears", "EARHOME", [DeviceType.ears], ActionCategory.ears, "EARHOME END", "cdd2e0ac-97a2-41d7-9ece-8d4dce4829d7")
//CommandAction("Left Twist", "LETWIST", [DeviceType.ears], ActionCategory.ears, "LETWIST END", "0d5a9dfa-38f2-4b09-9be1-cd36236a03b0"),
//CommandAction("Right Twist", "RITWIST", [DeviceType.ears], ActionCategory.ears, "RITWIST END", "9a6be63e-36f5-4f50-88b6-7adf2680aa5c"),
//CommandAction("Both Twist", "BOTWIST", [DeviceType.ears], ActionCategory.ears, "BOTWIST END", "2bc43e6c-65e7-4a35-834e-b2c31b8f83fe"),
//CommandAction("Home Ears", "EARHOME", [DeviceType.ears], ActionCategory.ears, "EARHOME END", "cdd2e0ac-97a2-41d7-9ece-8d4dce4829d7"),
MoveList.builtIn(
"Both Twist",
[DeviceType.ears],
ActionCategory.ears,
"d8384bcf-31ed-4b5d-a25a-da3a2f96e406",
[
Move.move(128, 128, Speed.slow, EasingType.cubic),
Move.delay(1),
Move.move(0, 0, Speed.slow, EasingType.cubic),
Move.delay(1),
Move.move(128, 128, Speed.slow, EasingType.cubic),
Move.delay(1),
],
),
MoveList.builtIn(
"Left Twist",
[DeviceType.ears],
ActionCategory.ears,
"0d5a9dfa-38f2-4b09-9be1-cd36236a03b0",
[
Move.move(128, 0, Speed.slow, EasingType.cubic),
Move.delay(1),
Move.move(0, 0, Speed.slow, EasingType.cubic),
Move.delay(1),
Move.move(128, 0, Speed.slow, EasingType.cubic),
Move.delay(1),
],
),
MoveList.builtIn(
"Left Twist",
[DeviceType.ears],
ActionCategory.ears,
"9a6be63e-36f5-4f50-88b6-7adf2680aa5c",
[
Move.move(0, 128, Speed.slow, EasingType.cubic),
Move.delay(1),
Move.move(0, 0, Speed.slow, EasingType.cubic),
Move.delay(1),
Move.move(0, 128, Speed.slow, EasingType.cubic),
Move.delay(1),
],
),
};
}

Expand Down
20 changes: 15 additions & 5 deletions lib/Backend/moveLists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ class Move {

Move();

Move.move(this.leftServo, this.rightServo, this.speed, this.easingType);

Move.delay(this.time) {
moveType = MoveType.delay;
}

Move.home() {
moveType = MoveType.home;
}

@override
String toString() {
switch (moveType) {
Expand Down Expand Up @@ -155,6 +165,8 @@ class MoveList extends BaseAction {
MoveList(super.name, super.deviceCategory, super.actionCategory, super.uuid) {
super.actionCategory = ActionCategory.sequence;
}

MoveList.builtIn(super.name, super.deviceCategory, super.actionCategory, super.uuid, this.moves);
}

@Riverpod(keepAlive: true)
Expand Down Expand Up @@ -192,11 +204,9 @@ Future<void> runAction(BaseAction action, BaseStatefulDevice device) async {
Flogger.i("Starting MoveList ${moveList.name}.");
// add final home move
List<Move> newMoveList = List.from(moveList.moves); //prevent home move from being added to original MoveList
if (moveList.homeAtEnd) {
Move move = Move();
move.moveType = MoveType.home;
//newMoveList.add(move);
}
Move move = Move.home();
newMoveList.add(move);

//TODO: Merge move commands into 1 large command
for (Move element in newMoveList) {
//run move command
Expand Down

0 comments on commit 249ebcb

Please sign in to comment.