{ "info": { "author": "zourtney", "author_email": "zourtney@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "gpiocrust\n=========\n\n.. image:: http://travis-ci.org/zourtney/gpiocrust.png?branch=master\n :target: http://travis-ci.org/zourtney/gpiocrust\n\nA concise, pythonic wrapper around the Raspberry Pi\u2019s `RPi.GPIO`_\nlibrary. An encrusting, if you will.\n\nWith (almost silent) fallback to mock objects, you can prototype pin I/O locally on your favorite computer, even when your Pi is on the other side of town (see *Mock API* for more details).\n\n*gpiocrust* is fully compatible with Python 2 and Python 3.\n\nIn a nutshell\n-------------\n\nDownload from PyPI with ``easy_install`` or ``pip``.\n\n.. code:: bash\n\n pip install gpiocrust\n\nIn a *.py* file, import the library and start setting pin values. It's easy! Here's a bare-bones example that will turn on GPIO pin 15:\n\n.. code:: python\n\n from gpiocrust import Header, OutputPin\n\n with Header() as header:\n pin = OutputPin(15, value=0)\n pin.value = 1\n\nAPI\n---\n\n*gpiocrust* provides four classes to help give GPIO pin manipulation a more object-oriented feel. They are:\n\n- ``Header``\n- ``OutputPin``\n- ``PWMOutputPin``\n- ``InputPin``\n\n\n**Header**\n\nThe ``Header`` class just wraps the GPIO setup and teardown methods.\nMost importantly, it ensures that ``GPIO.cleanup()`` is called. For\nexample:\n\n.. code:: python\n\n from gpiocrust import Header\n\n with Header() as header:\n # Application logic goes here\n pass\n\n # All cleaned up now.\n\n**OutputPin**\n\nThe ``OutputPin`` class controls a single GPIO pin for output. Set its\nvalue to ``True`` (``1``) or ``False`` (``0``). That\u2019s all there is to\nit!\n\n.. code:: python\n\n from gpiocrust import Header, OutputPin\n\n with Header() as header:\n shiny_led = OutputPin(11)\n shiny_led.value = True\n ...\n\n``value`` defaults to ``False``, but can be set with a keyword argument.\n\n.. code:: python\n\n shiny_led = OutputPin(11, value=True)\n\n**PWMOutputPin**\n\nThe ``PWMOutputPin`` class controls a single GPIO pin for output, but\nallows for variable ``value``\\ s via software pulse width modulation.\n\n.. code:: python\n\n from gpiocrust import Header, PWMOutputPin\n\n with Header() as header:\n soft_led = PWMOutputPin(11)\n soft_led.value = 0.25\n ...\n\nYou can set the frequency (Hz) via the ``frequency`` property. For\nexample:\n\n.. code:: python\n\n from gpiocrust import Header, PWMOutputPin\n\n with Header() as header:\n soft_led = PWMOutputPin(11, frequency=100)\n soft_led.frequency = 50\n\n**NOTE:** the RPi.GPIO implementation uses duty cycle values from ``0``\nto ``100``. To be consistent with ``OutputPin``, ``PWMOutputPin`` uses\ndecimal values ``0.0`` to ``1.0``.\n\nFor a good overview of how to use the `RPi.GPIO`_ implementation, see\n`this video`_.\n\n**InputPin**\n\nThe ``InputPin`` class controls a single GPIO pin for input. You can\nwatch for edge events using a ``callback`` argument or via the\n``@change`` decorator. For now, ``InputPin`` only supports watching\n``GPIO.BOTH`` (rising *and* falling) events.\n\n.. code:: python\n\n from gpiocrust import Header, InputPin\n\n def alert_president(value):\n pass\n\n with Header() as header:\n the_red_button = InputPin(11, callback=alert_president)\n\nIt\u2019s even cleaner with the ``@change`` decorator.\n\n.. code:: python\n\n from gpiocrust import Header, InputPin\n\n with Header() as header:\n the_red_button = InputPin(11, value=0)\n\n @the_red_button.change\n def alert_president(value):\n pass\n\nMock API\n--------\n\nMock classes are included that mimick the native GPIO functionality. The\nlibrary falls back to mock objects when the ``RPi.GPIO`` package cannot\nbe loaded. This allows one to code the general I/O flow of an\napplication in development environments where running code on a physical\nRaspberry Pi is inconvenient or impossible (i.e, the computer you're \nreading this on).\n\nFallback is automatic, so your import statements will look just as\nbefore.\n\nOutputPin example\n-----------------\n\n.. code:: python\n\n import time\n from gpiocrust import Header, OutputPin, PWMOutputPin\n\n with Header() as header:\n pin11 = OutputPin(11)\n pin15 = PWMOutputPin(15, frequency=100, value=0)\n\n try:\n while 1:\n # Going up\n pin11.value = True\n\n for i in range(100):\n pin15.value = i / 100.0\n time.sleep(0.01)\n\n time.sleep(0.5)\n\n # Going down\n pin11.value = False\n \n for i in range(100):\n pin15.value = (100 - i) / 100.0\n time.sleep(0.01)\n \n time.sleep(0.5)\n except KeyboardInterrupt:\n pass\n\n\n.. _RPi.GPIO: https://pypi.python.org/pypi/RPi.GPIO\n.. _this video: http://youtu.be/uUn0KWwwkq8\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zourtney/gpiocrust", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "gpiocrust", "package_url": "https://pypi.org/project/gpiocrust/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/gpiocrust/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/zourtney/gpiocrust" }, "release_url": "https://pypi.org/project/gpiocrust/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "A pythonic wrapper around RPi.GPIO", "version": "1.0.0" }, "last_serial": 1031711, "releases": { "0.9.0": [ { "comment_text": "", "digests": { "md5": "276a20e8b0503449acc9f1a13361ff5b", "sha256": "6e09ff0c0550b8f6559eb3d368cd3434a03d46299be09cd882bb42d6cfc79009" }, "downloads": -1, "filename": "gpiocrust-0.9.0.tar.gz", "has_sig": false, "md5_digest": "276a20e8b0503449acc9f1a13361ff5b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3665, "upload_time": "2014-03-12T05:54:38", "url": "https://files.pythonhosted.org/packages/58/84/1cf370f0ab5bb4e882f17f3990569545cd738f9c63c114fe21016e0a6e55/gpiocrust-0.9.0.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "24e1d34eb352bcb81f127d5ef4868a8b", "sha256": "10b6db12749dd70945d52286624cffda61a0e55327f40b2ed13b1dd2baa52142" }, "downloads": -1, "filename": "gpiocrust-0.9.1.tar.gz", "has_sig": false, "md5_digest": "24e1d34eb352bcb81f127d5ef4868a8b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3873, "upload_time": "2014-03-13T04:08:42", "url": "https://files.pythonhosted.org/packages/37/92/7e5847f2f197956e07f34d6088d95205d1cee54131d3a12076794e366d9b/gpiocrust-0.9.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "2ad20704d47a99911d1c299efbd16e1a", "sha256": "c0e0556db8241ccc82dd941a214c207bbe7beff84d5f77a70ca2b2fa0b1e9a54" }, "downloads": -1, "filename": "gpiocrust-1.0.0.tar.gz", "has_sig": false, "md5_digest": "2ad20704d47a99911d1c299efbd16e1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3977, "upload_time": "2014-03-16T22:35:14", "url": "https://files.pythonhosted.org/packages/e8/da/164c40fdc4140a77ef23c9890f3f1b6d6b4c3f7a047505eecb7154b620bf/gpiocrust-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2ad20704d47a99911d1c299efbd16e1a", "sha256": "c0e0556db8241ccc82dd941a214c207bbe7beff84d5f77a70ca2b2fa0b1e9a54" }, "downloads": -1, "filename": "gpiocrust-1.0.0.tar.gz", "has_sig": false, "md5_digest": "2ad20704d47a99911d1c299efbd16e1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3977, "upload_time": "2014-03-16T22:35:14", "url": "https://files.pythonhosted.org/packages/e8/da/164c40fdc4140a77ef23c9890f3f1b6d6b4c3f7a047505eecb7154b620bf/gpiocrust-1.0.0.tar.gz" } ] }