{ "info": { "author": "Scorch / Tatarize", "author_email": "tatarize@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "# K40Nano\nAPI support for K40 Laser Cutter with Nano Boards.\n(Derived from K40 Whisperer, by Scorch)\n\nK40Nano is intended to pull out the low level functionality from K40Whisperer, improve, document, and ecapsulate it and present a functional low level API. Making this functionality more direct, understandable, and extendable for everybody.\n\nInstall\n---\nTo install via PyPI\n\n`pip install k40nano`\n\nInclude `k40nano` as part your project requirements.\n\nCompatibility\n---\nK40Nano should be compatible with both Python 2.7 and 3.6.\n\n\nExamples\n---\nSee the companion K40Tools project for examples and useful tools built for the API.\nhttps://github.com/K40Nano/K40Tools\n\n\nAPI\n---\n\nThis API encapsulates the two major advances of K40 Whisperer, writing into `LHYMICRO-GL` format and transmitting data directly to the K40 device. Writing the `LHYMICRO-GL` encoded commands is done with `NanoPlotter` and it transmits this data to the device with `NanoConnection`.\n\nThe primary method of controlling the device is with a `Plotter` which is just like a pen plotter interface. This should be very simple and easy to use, and yet able to encapsulate everything we are doing.\n\nNanoPlotter / Plotter interface\n---\n\nThe M, A, B series boards use `LHYMICRO-GL` encoding which is derived from pen-plotters. As such, plotter interface is the best, simplest, and most natural way to interact with the K40.\n\nFor debugging purposes, there are also specialty plotters which write to file types rather than to a NanoConnection. These are `PngPlotter` and `SvgPlotter` which plot to PNG files and an SVG files respectively.\n\n \nPlotters have:\n* open()\n* move(dx, dy)\n* down()\n* up()\n* close()\n\n* enter_concat_mode()\n* enter_compact_mode(speed, harmonic_step)\n* exit_compact_mode_finish()\n* exit_compact_mode_reset()\n* exit_compact_mode_break()\n\nWhen writing to `LHYMICRO-GL` format, there are a few non-plotter based judgment calls to be made here as to how we should encode the data. As such, `NanoPlotter` uses a few mode altering commands outside the scope of typical plotter. Mostly this controls the compact mode for the device and how we would like our data packaged.\n\nIn default mode, the device will simply execute the command immediately and pop the stack. This sends everything as rapid commands, even turning the laser on and off without moving it.\n\nIn concat mode, commands are all strung together. They may be delayed until the current packet is full. But these are all rapid commands, where the users has chosen not flush out the packet after each command. These commands will be written to the buffer but may not be sent until the (30 byte) packet is full and as sending prematurely may introduce undesirable commands to the stack. When the NanoPlotter is closed, the packets are flushed by popping the stack.\n\nInternally there a mode called \"unfinished\" which is basically the same as concat, except that when we close a connection in unfinished it must enter compact_mode() and then exit_compact_mode_finish(), this is because the device was previously was in compact mode and we cannot be sure the current task was actually finished, so we cannot safely pop the stack.\n\nIf we do not manually invoke `enter_concat_mode()` and we only exit compact mode with `exit_compact_mode_finish()`, the \"unfinished\" mode will not occur.\n\nThe device itself has a compact mode. These are compacted instruction sets, executed quickly, at a particular head-movement speed. You must call `enter_compact_mode()` at a specific speed and the plotter commands are executed in compact_mode on the device. This is typical for vector-cuts, vector-engraves and raster line engraves, anything where you need to go slower to cut deeper, it also reduces the amount of data to be sent.\n\nThere are three ways to exit this mode.\n* Finish. This sends a finished command, and blocks our code operations until the device itself says the task is complete. Returning us to default mode.\n* Reset. This sends a reset command, allowing additional code to be sent without delay, and returns us to unfinished mode.\n* Break. Doesn't reset the speed commands within the device. It returns us to unfinished mode. We can still reenter compact mode at whatever speed, but if the speed has changed, NanoPlotter has to (enter_compact, reset, exit_compact) to permit the speed change or to close the plotter. But, if your intention is to run more compact commands at at the same speed after some rapid moves, break should permit that without resetting the speed internally.\n\nIn addition to theses we have a couple helpful device specific commands:\n* `home()` : Homes the device back to 0,0 (upper left corner)\n* `unlock_rail()` : Allows you to manually drag the rail into position.\n* `lock_rail()` : Locks the rail again (this will be done automatically for most things).\n* `abort()` : Kills the current job, restores us to default mode.\n\nThese should be done in default mode. If we aren't in default mode, the `NanoPlotter` will attempt get to default mode by exiting whatever modes the device is in. `abort()`, however, won't do anything other than kill whatever the device is currently doing and doesn't need to be called in any particular mode.\n\nNOTE: In default mode, down() and up() commands are single-packet commands. This will cause the K40 to turn on the laser and just sit there firing the laser. If this is not desirable, do not use these commands in default mode.\n\nConnections\n---\nThe `NanoPlotter` sends its data via a connection. In addition to the `NanoConnection`, there are a couple other debug connection classes `FileWriteConnection` and `PrintConnection` that can be requested when we open the `NanoConnection`, if these are used by the NanoPlotter the data will be redirected to them and written to a file or printed to the screen accordingly.\n\nConnections try to mimic a file-like object:\n\n* open() - Opens the connection\n* send(data) - Sends data immediately.\n* write(data) - Writes data to the buffer and sends as packets complete.\n* flush() - Sends the buffer immediately.\n* buffer(data) - Buffers the data, and makes no attempt to transmit it.\n* close() - Closes the connection\n* wait() - Waits for the device to report task complete.\n\nYou can also, use the python `with` statement for connections and plotters to ensure we open and close our connections correctly.\n\nNanoConnection\n---\nThe `NanoConnection` class is based on almost exclusively a highly-streamlined version of K40 Whisperer code and performs the interface, packetizations, and handling the usb connection to the device. The USB connection is done by the `NanoUsb` class. For testing purposes, the `MockUsb` class can be exchanged for the `NanoUsb` class. The MockUsb class will also be used if there is no valid `pyusb` install.\n\nIf you wish to send data via the `NanoConnection` direcly, for example you want to feed it pre-made EGV data, you would only need to open the connection, write() the data, flush() the buffer, and close() the connection. And the connection will deal with all the packetization and crc errors and resends for you.\n\n```python\nwith NanoConnection(board=\"B1\") as stream:\n stream.write(\"IPP\")\n```\n\n\nUnits\n---\nThe code throughout uses mils (1/1000th of an inch). So 2000 is 2 inches, etc. The lasers have a dpi of 1000. In the speed code there we sometimes use period, as the speed codes are linear with regard to the period. Stepper motors like those within the K40 are speed controlled by the delay between ticks sent to the motor to step one. This tends to be used internally and you can use mm per second.\n\n\nCoordinate System\n---\nThe coordinate system is that the origin is in the upper left corners and all Y locations are DOWN. Which is to say higher Y values mean lower on the device. This is similar to all modern graphics system. Internally the commands are all relative with a positive magnitude.\n\n\nDocumentation\n---\nSee Wiki for documentation of the LHYMICRO-GL format.\n\nhttps://github.com/K40Nano/K40Nano/wiki", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/K40Nano/K40Nano", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "k40nano", "package_url": "https://pypi.org/project/k40nano/", "platform": "", "project_url": "https://pypi.org/project/k40nano/", "project_urls": { "Homepage": "https://github.com/K40Nano/K40Nano" }, "release_url": "https://pypi.org/project/k40nano/0.2.2/", "requires_dist": null, "requires_python": "", "summary": "Low Level K40 Control", "version": "0.2.2" }, "last_serial": 4706741, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "86fa057a9bd41632447cd140c187d33b", "sha256": "322f8bd912e7f1a61870a3881c805185445707586527298dd001c7f2ed16de06" }, "downloads": -1, "filename": "k40nano-0.1.0.tar.gz", "has_sig": false, "md5_digest": "86fa057a9bd41632447cd140c187d33b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18538, "upload_time": "2019-01-07T06:16:15", "url": "https://files.pythonhosted.org/packages/54/7f/54d8faa07f7f3a7b326ae595d075867045addb5454c5f301aa860c67c310/k40nano-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "f27d7ad3bbc781d36ab8f59379d69851", "sha256": "faa55ccf19dfd2306afd3b142d90ed2196df17f49af69274968e0b1b8a4061ab" }, "downloads": -1, "filename": "k40nano-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f27d7ad3bbc781d36ab8f59379d69851", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18620, "upload_time": "2019-01-08T12:00:03", "url": "https://files.pythonhosted.org/packages/f6/6d/dfdbda25b2fee1be2418e5cf582599f55a78926bec8ec59a7bf65db66a45/k40nano-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "b4a87d870ba8edc3e0eb6255aa1ea89c", "sha256": "16523d253245af0767d9d2fb827102234d076ab9401040e96e5e7b5450adee13" }, "downloads": -1, "filename": "k40nano-0.2.0.tar.gz", "has_sig": false, "md5_digest": "b4a87d870ba8edc3e0eb6255aa1ea89c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36111, "upload_time": "2019-01-15T11:30:35", "url": "https://files.pythonhosted.org/packages/f2/71/bc52d2651c67213b0d94cb0b7b0ce667114e1f449cd165ccf3bc8eb46c9f/k40nano-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "a9316e878f3968e7edf38eb2c498a29d", "sha256": "614d7cad590edd413dedc398ac4cd32edfbd3468791e484b4cd1f380a1bfec84" }, "downloads": -1, "filename": "k40nano-0.2.1.tar.gz", "has_sig": false, "md5_digest": "a9316e878f3968e7edf38eb2c498a29d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36286, "upload_time": "2019-01-16T13:40:24", "url": "https://files.pythonhosted.org/packages/ee/aa/fc8413ed8b14b94239959f47fbf3e5cc46225984b66dbc8061a98be4a924/k40nano-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "100fd3e6097ca59830d18ad84201dc34", "sha256": "721c080084ce72206886fed51a04b45f59a2420e77e7f901a9ce68caf6c586a2" }, "downloads": -1, "filename": "k40nano-0.2.2.tar.gz", "has_sig": false, "md5_digest": "100fd3e6097ca59830d18ad84201dc34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36636, "upload_time": "2019-01-17T07:20:36", "url": "https://files.pythonhosted.org/packages/ca/2e/b651624690d6d0ecf8735e83b1b0fbe3e73f6e6566e970343e48ee5aa621/k40nano-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "100fd3e6097ca59830d18ad84201dc34", "sha256": "721c080084ce72206886fed51a04b45f59a2420e77e7f901a9ce68caf6c586a2" }, "downloads": -1, "filename": "k40nano-0.2.2.tar.gz", "has_sig": false, "md5_digest": "100fd3e6097ca59830d18ad84201dc34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36636, "upload_time": "2019-01-17T07:20:36", "url": "https://files.pythonhosted.org/packages/ca/2e/b651624690d6d0ecf8735e83b1b0fbe3e73f6e6566e970343e48ee5aa621/k40nano-0.2.2.tar.gz" } ] }