Skip to content

Commit

Permalink
feat: enable start plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
necusjz committed Dec 1, 2023
1 parent 9a1488d commit 96f143f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/splatbot/cli.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#!/usr/bin/env python
import click

from .macro import generate_macro
from .start import start_plotting

@click.group(help="Automate drawing detailed plaza posts in Splatoon.")

@click.group(help="Automate plotting detailed posts in Splatoon wirelessly.")
def main():
pass


@main.command(help="Generate macros representing the actual drawing process.")
@main.command(help="Generate the macro represents the actual plotting process.")
@click.option(
"--input", "-i", required=True, metavar="PATH",
help="Path to a 320x120 horizontal image to serve as plaza post."
help="Path to a 320x120 horizontal image to serve as a post."
)
def macro(args):
pass
def macro(input):
generate_macro(input)


@main.command(help="Start drawing and display the current progress.")
@main.command(help="Start plotting the post and display the current progress.")
@click.option(
"--input", "-i", required=True, metavar="PATH",
help="Path to macros simulate the button order from controller."
help="Path to the macro that simulates the sequence of buttons."
)
def start(args):
pass
def start(input):
start_plotting(input)


if __name__ == "__main__":
Expand Down
28 changes: 28 additions & 0 deletions src/splatbot/start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from .controller import Button
from .controller import Controller


command_map = {
"u": Button.DPAD_UP,
"d": Button.DPAD_DOWN,
"l": Button.DPAD_LEFT,
"r": Button.DPAD_RIGHT,
"a": Button.A,
"b": Button.B,
"x": Button.X,
"y": Button.Y
}


def start_plotting(macro_path):
with open(macro_path, "r", encoding="utf-8") as fp:
commands = fp.readlines()

print("Navigate to Change Grip/Order menu on your Nintendo Switch.")

with Controller(press_ms=700, delay_ms=7000) as ctl:
print("Connected!")
input("Press <enter> key to start plotting...")

buttons = [command_map[cmd.strip()] for cmd in commands]
ctl.macro(buttons)

0 comments on commit 96f143f

Please sign in to comment.