Fancy output displays
This commit is contained in:
31
autopon.py
31
autopon.py
@@ -49,10 +49,22 @@ def main():
|
|||||||
"R": "45"
|
"R": "45"
|
||||||
}
|
}
|
||||||
drummapping = {
|
drummapping = {
|
||||||
"U": '\033[32mCHAKA\033[0m',
|
"U": {
|
||||||
"D": '\033[33mDON\033[0m',
|
"string": "CHAKA",
|
||||||
"L": '\033[31mPATA\033[0m',
|
"color": 32
|
||||||
"R": '\033[34mPON\033[0m'
|
},
|
||||||
|
"D": {
|
||||||
|
"string": "DON",
|
||||||
|
"color": 33
|
||||||
|
},
|
||||||
|
"L": {
|
||||||
|
"string": "PATA",
|
||||||
|
"color": 31
|
||||||
|
},
|
||||||
|
"R": {
|
||||||
|
"string": "PON",
|
||||||
|
"color": 34
|
||||||
|
},
|
||||||
}
|
}
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Play a sequence of Patapon commands on repeat"
|
description="Play a sequence of Patapon commands on repeat"
|
||||||
@@ -88,6 +100,12 @@ def main():
|
|||||||
remaining_iterations = args.iterations
|
remaining_iterations = args.iterations
|
||||||
lastbeat = 0
|
lastbeat = 0
|
||||||
|
|
||||||
|
# Get a ghost string to use for fancy input display stuffs
|
||||||
|
ghoststring="\033[37m"
|
||||||
|
for i, key in enumerate(sequence):
|
||||||
|
ghoststring += drummapping.get(key,{}).get('string',' ')
|
||||||
|
ghoststring+="\033[0m"
|
||||||
|
|
||||||
# Wait for user confirmation
|
# Wait for user confirmation
|
||||||
input("Press enter on-beat to sync up with Patapon...")
|
input("Press enter on-beat to sync up with Patapon...")
|
||||||
synctime = time.perf_counter() + startup_delay
|
synctime = time.perf_counter() + startup_delay
|
||||||
@@ -95,6 +113,7 @@ def main():
|
|||||||
# Play da notes
|
# Play da notes
|
||||||
try:
|
try:
|
||||||
while remaining_iterations > 0:
|
while remaining_iterations > 0:
|
||||||
|
print(ghoststring, end="\r", flush=True)
|
||||||
for i, key in enumerate(sequence):
|
for i, key in enumerate(sequence):
|
||||||
while time.perf_counter() < synctime + lastbeat:
|
while time.perf_counter() < synctime + lastbeat:
|
||||||
pass
|
pass
|
||||||
@@ -103,11 +122,11 @@ def main():
|
|||||||
if button != '-':
|
if button != '-':
|
||||||
if not args.dry_run:
|
if not args.dry_run:
|
||||||
ydotool(key=button, delay=args.key_delay, multiplier=args.bpm)
|
ydotool(key=button, delay=args.key_delay, multiplier=args.bpm)
|
||||||
print(drummapping.get(key, '-'), end="", flush=True)
|
print(f"\033[{drummapping.get(key,{}).get('color',0)}m{drummapping.get(key,{}).get('string','-')}\033[0m", end="", flush=True)
|
||||||
else:
|
else:
|
||||||
print(" ", end="", flush=True)
|
print(" ", end="", flush=True)
|
||||||
remaining_iterations -= 1
|
remaining_iterations -= 1
|
||||||
print(f"~ ({remaining_iterations} remaining)")
|
print(f"~ ({remaining_iterations} remaining)" + " " * len(str(args.iterations)), end="\r")
|
||||||
except KeyboardInterrupt as e:
|
except KeyboardInterrupt as e:
|
||||||
print("Interrupt")
|
print("Interrupt")
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user