### Marking a Square with GalvoController Source: https://github.com/meerk40t/galvoplotter/blob/main/README.md This example demonstrates how to use the `GalvoController` to quickly mark a square pattern on the laser bed. It utilizes the `marking()` context manager for sequential commands without needing the spooler, and concludes by waiting for the machine to become idle. ```python controller = GalvoController(settings_file=".json") with controller.marking() as c: c.goto(0x5000, 0x5000) c.mark(0x5000, 0xA000) c.mark(0xA000, 0xA000) c.mark(0x5000, 0xA000) c.mark(0x5000, 0x5000) controller.wait_for_machine_idle() ``` -------------------------------- ### Using GalvoController Marking Context Manager Source: https://github.com/meerk40t/galvoplotter/blob/main/README.md This Python snippet demonstrates the use of the `controller.marking()` context manager. It automatically sets the controller to the marking configuration for the duration of the `with` block and restores it to the initial configuration upon exit, ensuring proper execution of buffered commands. ```python controller = GalvoController(settings_file=".json") with controller.marking() as c: c.goto(0x8000, 0x8000) c.dwell(100) controller.wait_for_machine_idle() ``` -------------------------------- ### GalvoController Helper Commands API Source: https://github.com/meerk40t/galvoplotter/blob/main/README.md API documentation for mid-level helper commands on the GalvoController. These include realtime movement commands and hybrid commands that behave differently based on the current laser configuration (realtime in 'initial', list-sequential in 'lighting' or 'marking'). ```APIDOC GalvoController Helper Commands: Realtime: .jog(x: int, y: int) Description: Performs a realtime goto (goto_xy) with correct distance calculations to avoid head popping sounds. Hybrid: .light_on() Description: Turns the redlight on. Sends a realtime GPIO change in 'initial_configuration', otherwise a list-sequential GPIO change. .light_off() Description: Turns the redlight off. Sends a realtime GPIO change in 'initial_configuration', otherwise a list-sequential GPIO change. ``` -------------------------------- ### GalvoController Plotlike Commands API Source: https://github.com/meerk40t/galvoplotter/blob/main/README.md API documentation for the mid-level plot-like commands available on the GalvoController. These commands are used to send positional data and laser firing instructions, often with specific speed settings. ```APIDOC GalvoController Plotlike Commands: .mark(x: int, y: int) Description: Fires the laser with given parameters to the specified location. .goto(x: int, y: int) Description: Moves to a location regardless of the redlight state. .light(x: int, y: int) Description: Moves to a location using the outline redlight. .dark(x: int, y: int) Description: Moves to a location without the redlight being turned on. .dwell(time_in_ms: int) Description: Fires the laser at the current position for the specified time. .wait(time_in_ms: int) Description: Waits without the laser firing at the current position for the specified time. ``` -------------------------------- ### API Reference: Galvoplotter Wait Commands Source: https://github.com/meerk40t/galvoplotter/blob/main/README.md This section details various wait commands available in Galvoplotter to block the current thread until specific events related to the laser machine's state or job spooler have occurred. These commands are crucial for synchronizing operations with the hardware's status. ```APIDOC Wait Commands: wait_for_spooler_job_sent(job) Description: Blocks until the specified job is sent. Parameters: job: The job object to wait for. wait_for_machine_idle() Description: Blocks until the machine is idle, spooler has fully sent, and laser gives a finished status. wait_for_spooler_send() Description: Blocks until all jobs in the spooler are sent (they may still be buffered in the laser). wait_finished() Description: Blocks until the controller is finished. wait_ready() Description: Waits until the device status is flagged 'ready' and can accept additional packets. wait_idle() Description: Waits until the device status is not flagged as 'busy' and is no longer doing work. Note: If an infinite job is sent, calling wait_for_spooler_job_sent() or wait_for_machine_idle() may lead to livelock as those states are unreachable. Termination may occur if the connection is broken. ``` -------------------------------- ### Submitting and Aborting an Infinite Job Source: https://github.com/meerk40t/galvoplotter/blob/main/README.md This snippet illustrates how to submit a continuous job to the `GalvoController`'s spooler and then programmatically abort it. The `my_job` function creates an infinite loop of light-line drawing, which is then terminated after a short delay using `controller.shutdown()`. ```python controller = GalvoController(settings_file=".json") def my_job(c): c.lighting_configuration() c.dark(0x8000, 0x8000) c.light(0x2000, 0x2000) return False controller.submit(my_job) time.sleep(2) controller.shutdown() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.