Compare commits
3 Commits
b4a774b2b9
...
fa1122b32c
| Author | SHA1 | Date | |
|---|---|---|---|
| fa1122b32c | |||
| f9232df233 | |||
| 20c943b73c |
2
main.py
2
main.py
@@ -22,7 +22,7 @@ if __name__ == "__main__":
|
||||
positions = parser.get_positions()
|
||||
|
||||
if args.visualize:
|
||||
screen_dimensions = (1024*1.5, 1024*1.5 * HEIGHT_MM/WIDTH_MM)
|
||||
screen_dimensions = (1024*1.5, 1024*1.5 * args.height/args.width)
|
||||
visualizer = Visualizer(positions, screen_dimensions, (args.width, args.height))
|
||||
visualizer.visualize()
|
||||
|
||||
|
||||
18
port-finder.py
Executable file
18
port-finder.py
Executable file
@@ -0,0 +1,18 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import serial.tools.list_ports
|
||||
from serial.tools.list_ports_common import ListPortInfo
|
||||
|
||||
if __name__ == "__main__":
|
||||
ports = serial.tools.list_ports.comports()
|
||||
for port in ports:
|
||||
if port.interface and port.interface.startswith("CircuitPython CDC2"): # CDC2 is the data-port
|
||||
print(f"Port: {port.device}")
|
||||
print(f" Description: {port.description}")
|
||||
print(f" Manufacturer: {port.manufacturer}")
|
||||
print(f" VID: {port.vid}")
|
||||
print(f" PID: {port.pid}")
|
||||
print(f" Serial Number: {port.serial_number}")
|
||||
print(f" Location: {port.location}")
|
||||
print(f" Interface: {port.interface}")
|
||||
print()
|
||||
@@ -9,8 +9,7 @@ class PWMDriver():
|
||||
|
||||
def _init_pwm(self) -> None:
|
||||
from serial import Serial
|
||||
pass
|
||||
#self.serial = Serial(self.port, self.baudrate)
|
||||
self.serial = Serial(self.port, self.baudrate)
|
||||
|
||||
def _send_position(self, pos : tuple[float, float, float]) -> None:
|
||||
x, y, z = pos
|
||||
@@ -22,14 +21,11 @@ class PWMDriver():
|
||||
|
||||
# Send PWM values to the serial port
|
||||
print(f"Sending PWM values: X={pwm_x:<5}, Y={pwm_y:<5}, Pen={pen}")
|
||||
#self.serial.write(f"{pwm_x},{pwm_y},{pen}\n".encode())
|
||||
self.serial.write(f"{pwm_x},{pwm_y},{pen}\n".encode())
|
||||
|
||||
def _position_reached(self) -> bool:
|
||||
# Check if the position has been reached
|
||||
from time import sleep
|
||||
sleep(0.5)
|
||||
return True
|
||||
# return self.serial.readline().decode().strip() == "OK"
|
||||
return self.serial.readline().decode().strip() == "OK"
|
||||
|
||||
def _wait_for_position(self) -> None:
|
||||
# Wait until the position is reached
|
||||
|
||||
Reference in New Issue
Block a user