init: initial commit
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
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
This commit is contained in:
22
tests/test_vibration.py
Normal file
22
tests/test_vibration.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user