Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/spooled'
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarize committed Jul 6, 2023
2 parents 7c01a57 + 912185e commit f08ecc1
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 19 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# galvoplotter
low level command system for ezcad2 lmc-controller galvo lasers

# Installing
galvo plotter can be installed with `pip`
`pip install galvoplotter`

# Dependencies
* pyusb

Expand Down Expand Up @@ -102,7 +106,7 @@ There are context managers for the `controller.marking()` and `controller.lighti
c.dwell(100)
controller.wait_for_machine_idle()
```
This would, for example, mark draw a square. During the use of the `marking()` context, our commands are executed in the `controller.marking_configuration()` it's restored to the `initial_configuration` on exit which will execute any list commands in the buffer.
This would, for example, fire the laser for 100ms in the center of the area. During the use of the `marking()` context, our commands are executed in the `controller.marking_configuration()` it's restored to the `initial_configuration` on exit which will execute any list commands in the buffer.


# Midlevel Commands
Expand Down
3 changes: 2 additions & 1 deletion examples/gpio_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Connection happens automatically at the first issue of realtime `write_port()` command.
"""

from galvo.controller import GalvoController
from pynput import keyboard

from galvo.controller import GalvoController

controller = GalvoController("default.json")


Expand Down
2 changes: 2 additions & 0 deletions examples/light_circle_abort.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"""

import math

from pynput import keyboard

from galvo.controller import GalvoController

controller = GalvoController("default.json")
Expand Down
3 changes: 1 addition & 2 deletions galvo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .controller import GalvoController
from .consts import *
from .controller import GalvoController


def generate_job(generator):
Expand All @@ -25,4 +25,3 @@ def job(c):
return True

return job

2 changes: 0 additions & 2 deletions galvo/consts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


listJumpTo = 0x8001
listEndOfList = 0x8002
listLaserOnPoint = 0x8003
Expand Down
12 changes: 6 additions & 6 deletions galvo/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
import time
from contextlib import contextmanager
from copy import copy
from .consts import *

from .consts import *
from .mock_connection import MockConnection
from .usb_connection import USBConnection


BUSY = 0x04
READY = 0x20

Expand Down Expand Up @@ -166,7 +165,8 @@ def __init__(
self._delay_end = None
if settings_file is not None:
import json
with open(settings_file, 'r') as fp:

with open(settings_file, "r") as fp:
self.__dict__.update(json.load(fp))

#######################
Expand Down Expand Up @@ -682,7 +682,7 @@ def wait_idle(self):
#######################

def wait_for_spooler_job_sent(self, job):
assert (threading.current_thread() is not self._spooler_thread)
assert threading.current_thread() is not self._spooler_thread
with self._spooler_lock:
if job not in self._queue:
# Waiting for job that does not exist.
Expand All @@ -694,7 +694,7 @@ def wait_for_machine_idle(self):
Block the current thread until system is idle
:return:
"""
assert(threading.current_thread() is not self._spooler_thread)
assert threading.current_thread() is not self._spooler_thread
self.wait_for_spooler_send()
self.wait_finished()

Expand All @@ -706,7 +706,7 @@ def wait_for_spooler_send(self):
:return:
"""
assert (threading.current_thread() is not self._spooler_thread)
assert threading.current_thread() is not self._spooler_thread
while self._queue:
with self._spooler_lock:
self._spooler_lock.wait()
Expand Down
3 changes: 1 addition & 2 deletions galvo/mock_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import random
import struct

from .consts import list_command_lookup
from .consts import single_command_lookup
from .consts import list_command_lookup, single_command_lookup


def _(data):
Expand Down
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[metadata]
name = Galvo Plotter
name = galvoplotter
version = 0.1.0
description = Galvo Plotter
long_description_content_type=text/markdown
long_description = file: README.md
classifiers =
Development Status :: 3 - Alpha
Development Status :: 4 - Beta
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Topic :: Utilities
keywords = ezcad2, galvo, laser
author = Tatarize
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from setuptools import setup

setup(
install_requires=[
"pyusb",
Expand Down
18 changes: 15 additions & 3 deletions test/test_api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
import time
import unittest

from galvo import GalvoController, generate_job

state = 0

__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))

__settings__ = os.path.join(__location__, 'test.json')
__settings__ = os.path.join(__location__, "test.json")


def infinite_lighting_job(c):
Expand Down Expand Up @@ -153,6 +153,18 @@ def test_mark_square(self):
c.wait_for_machine_idle()
print("test_mark_square: final line or test fail.")

def test_fire_center(self):
"""
Test for firing laser 100ms in center of lens.
:return:
"""
c = GalvoController(settings_file=__settings__)
with c.marking() as c:
c.set_frequency(25.4) # Set frequency to 25.4kHz
c.goto(0x8000, 0x8000)
c.dwell(100)
c.wait_for_machine_idle()

def test_grid_stops(self):
"""
Test for a grid of lit points.
Expand Down

0 comments on commit f08ecc1

Please sign in to comment.