Files
muse2040/tests/test_vibration.py
may ecf1730b93
Some checks failed
CI Checks / Building (macOS-latest, stable) (push) Has been cancelled
CI Checks / Building (true, macOS-latest, nightly) (push) Has been cancelled
CI Checks / Building (true, ubuntu-latest, nightly) (push) Has been cancelled
CI Checks / Building (true, windows-latest, nightly) (push) Has been cancelled
CI Checks / Building (ubuntu-latest, stable) (push) Has been cancelled
CI Checks / Building (windows-latest, stable) (push) Has been cancelled
CI Checks / Linting (push) Has been cancelled
CI Checks / Formatting (push) Has been cancelled
init: initial commit
2025-12-18 17:40:03 +10:00

22 lines
623 B
Python

import os
import serial
import struct
import time
conn = serial.Serial("COM3" if os.name == "nt" else "/dev/ttyACM0")
def change(channel, intensity):
return struct.pack("B", (channel << 2) + intensity)
try:
print("Blinking (1sec intervals)... [Press ^C to exit]\x1b[?25l")
while True:
print("\r\x1b[32m- vibrating -\x1b[0m", end="", flush=True)
conn.write(change(0, 1))
time.sleep(1)
print("\r\x1b[35m- sleeping - \x1b[0m", end="", flush=True)
conn.write(change(0, 0))
time.sleep(1)
except KeyboardInterrupt:
conn.write(change(0, 0))
print("\x1b[?25h")