{ "info": { "author": "Florin COSTA", "author_email": "hardhat@raspihats.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Education", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Home Automation", "Topic :: Software Development", "Topic :: System :: Hardware" ], "description": "raspihats package\n=================\n\nThis package provides the necessary code to interface the Raspberry Pi HATs(add-on boards) from raspihats.com_:\n\nTypical usage often looks like this:\n\n.. code-block:: python\n\n #!/usr/bin/env python\n # In this setup there are two I2C-HATs stacked, one DI16ac and one DQ10rly.\n from raspihats.i2c_hats import DI16ac, DQ10rly\n\n di16ac = DI16ac(0x40) # 0x40 is the I2C bus address\n dq10rly = DQ10rly(0x50) # 0x50 is the I2C bus address\n\n while True:\n state = di16ac.di.channels[0] # get digital input channel 0\n dq10rly.dq.channels[0] = state # set digital output channel 0\n dq10rly.dq.channels[1] = not state # set digital output channel 1\n\nIRQ feature(from v2.3.0)\n------------------------\n\n Starting from hardware revision 2.0, DI16ac and DI6acDQ6rly boards can trigger an IRQ line that's connected to GPIO21 of the Raspberry Pi.\n\n.. code-block:: python\n\n try:\n import Queue as queue\n except ImportError:\n import queue\n from time import sleep\n import RPi.GPIO as GPIO\n from raspihats.i2c_hats import DI16ac, DI6acDQ6rly\n\n IRQ_PIN = 21\n GPIO.setmode(GPIO.BCM)\n\n # IRQ pin setup as input with pull-up enabled\n GPIO.setup(IRQ_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)\n\n # this queue is use to safely exchange information between threads\n event_queue = queue.Queue(maxsize = 20)\n\n def isr(pin):\n event_queue.put(pin)\n\n GPIO.add_event_detect(IRQ_PIN, GPIO.FALLING, callback=isr)\n\n # b = DI16ac(0x40) # 0x40 is the I2C bus address\n b = DI6acDQ6rly(0x60) # 0x60 is the I2C bus address\n\n print(str(b.name) + ' ' + str(b.fw_version))\n print('Use Ctrl+C to stop program.')\n\n # enable raising edge IRQs for Digital Input channels 0 and 2\n b.di.irq_reg.rising_edge_control = 0x05\n\n # enable falling edge IRQs for Digital Input channels 1 and 2\n b.di.irq_reg.falling_edge_control = 0x06\n\n # dump DigitalInputs IRQ CaptureQueue contents and release IRQ line by\n # writing 0 to DigitalInputs IRQ Capture Register\n b.di.irq_reg.capture = 0\n\n while True:\n try:\n # wait until there is something in the queue, timeout is here because a\n # queue.get without a timeout can't be interrupted with a KeyboardInterrupt\n pin = event_queue.get(block=True, timeout=0.2)\n if pin == IRQ_PIN:\n # read the DigitalInputs IRQ Capture Register(to read the values\n # stored in the DigitalInputs IRQ CaptureQueue) until the\n # returned value is 0, this means DigitalInputs IRQ CaptureQueue\n # is empty and the IRQ line is released\n while True:\n capture = b.di.irq_reg.capture\n if capture == 0:\n break\n status = capture & 0xFFFF\n states = (capture >> 16) & 0xFFFF\n for channel in range(0, 16):\n mask = 0x01 << channel\n if (status & mask) > 0:\n print('IRQ detected on channel: %d, state: %d' %(channel, (states & mask) >> channel))\n except queue.Empty:\n pass\n\n except KeyboardInterrupt:\n # disable raising edge IRQs for Digital Input channels\n b.di.irq_reg.raising_edge_control = 0\n\n # disable falling edge IRQs for Digital Input channels\n b.di.irq_reg.falling_edge_control = 0\n\n GPIO.remove_event_detect(IRQ_PIN)\n GPIO.cleanup()\n\n break\n\n\nListing attributes and methods(from v2.0.0)\n-------------------------------------------\n\n.. code-block:: python\n\n #!/usr/bin/env python\n from raspihats.i2c_hats import DI6acDQ6rly\n\n board = DI6acDQ6rly(0x60) # 0x60 is the I2C bus address\n\n board.name # get board name, in this case 'DI6acDQ6rly'\n board.status.value # get status word\n board.reset() # reset board\n\n # cwdt - Communication WatchDog Timer\n board.cwdt.period # get CommunicationWatchDogTimer(CWDT) period\n board.cwdt.period = 1 # set CWDT period, any value greather than 0 enables the CWDT\n board.cwdt.period = 0 # 0 disables the CWDT\n\n # di - Digital Inputs\n board.di.value # get all digital input channel states, bit 0 represents channel 0 state and so on ..\n board.di.channels[0] # get digital input channel 0 state, access using channel index\n board.di.channels['I0'] # get digital input channel 0 state, access using channel label\n board.di.r_counters[0] # get digital input channel 0 raising edge counter\n board.di.r_counters['I0'] # get digital input channel 0 raising edge counter\n board.di.r_counters[0] = 0 # reset digital input channel 0 raising edge counter\n board.di.r_counters['I0'] = 0 # reset digital input channel 0 raising edge counter\n board.di.f_counters[0] # get digital input channel 0 falling edge counter\n board.di.f_counters['I0'] # get digital input channel 0 falling edge counter\n board.di.f_counters[0] = 0 # reset digital input channel 0 falling edge counter\n board.di.f_counters['I0'] = 0 # reset digital input channel 0 falling edge counter\n board.di.reset_counters() # reset all counters(rising and falling edge) for all channels\n board.di.labels # get digital input labels\n\n # dq - Digital Outputs\n board.dq.value # get all digital output channel states, bit 0 represents channel 0 and so on ..\n board.dq.value = 0 # set all digital output channel states\n board.dq.channels[0] # get digital output channel 0 state, access using channel index\n board.dq.channels[0] = 0 # set digital output channel 0 state\n board.dq.channels['Q0'] # get digital output channel 0 state, access using channel label\n board.dq.channels['Q0'] = 0 # set digital output channel 0 state\n # PowerOnValue -- loaded to Digital Outputs at board power on\n board.dq.power_on_value # get digital output channels PowerOnValue, bit 0 represents channel 0 and so on ..\n board.dq.power_on_value = 0 # set digital output channels PowerOnValue\n # SafetyValue -- loaded to Digital Outputs at CWDT timeout\n board.dq.safety_value # get digital output channels SafetyValue, bit 0 represents channel 0 and so on ..\n board.dq.safety_value = 0 # set digital output channels SafetyValue\n board.dq.labels # get digital output labels\n\nChange Log\n----------\n\nv2.3.0\n~~~~~~\n - Added IRQ support\n\nv2.2.3\n~~~~~~\n - enum34 is loaded for python<3.4\n - Setup script warning if it's not run with sudo(used to setup I2C ClockStretchTimeout)\n\nv2.2.2\n~~~~~~\n - Bug fix in setup script, BCM2835 platform hardware is now recognized.\n - Bug fix in robotframework interface, status.value is now returned by get_status()\n\n\nv2.2.1\n~~~~~~\n - Added StatusWord class. To get raw int value use board.status.value, to get beautiful string representation use str(board.status).\n\nv2.1.1\n~~~~~~\n - String representation of I2CHat object doesn't use an I2C bus transfer any more.\n - Improved exception messages\n\nv2.1.0\n~~~~~~\n - Improved exception handling\n\nv2.0.1\n~~~~~~\n - Fixed I2C clock stretch timeout setup script\n\nv2.0.0\n~~~~~~\n - Attributes are now used for accessing board parameters, rather then methods\n - Added support for new boards:\n\n - DI16ac_ (replacement for Di16_)\n - DQ10rly_ (replacement for Rly10_)\n - DQ16oc_\n - DI6acDQ6rly_ (replacement for Di6Rly6_)\n\nv1.1.1\n~~~~~~\n - Added support for new boards:\n\n - Di16_\n - Rly10_\n - Di6Rly6_\n\n.. code-block:: python\n\n #!/usr/bin/env python\n # In this setup there are two I2C-HATs stacked, one Di16 and one Rly10.\n from raspihats.i2c_hats import Di16, Rly10\n\n di16 = Di16(0x40) # 0x40 is the I2C bus address\n rly10 = Rly10(0x50) # 0x50 is the I2C bus address\n # The I2C-HAT address high nibble is fixed(0x4 for Di16, 0x5 for Rly10), the low nibble\n # value is set using the on-board address jumper, range is [0x0 .. 0xF].\n\n while True:\n state = di16.di_get_channel_state('Di1.1')\n rly10.do_set_channel_state('Rly1', state)\n rly10.do_set_channel_state('Rly2', not state)\n\n\nInstallation\n------------\n\nInstall dependencies\n~~~~~~~~~~~~~~~~~~~~\n\nThe python-smbus package\n\n.. code-block:: console\n\n $ sudo apt-get install python-smbus\n # or if using python 3\n $ sudo apt-get install python3-smbus\n\n\nInstall from repository\n~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: console\n\n # Make sure you have git, pip and setuptools installed\n $ git clone git@github.com:raspihats/raspihats.git\n $ cd raspihats\n $ sudo python setup.py install\n # or if using python 3\n $ sudo python3 setup.py install\n\n\nInstall using pip\n~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: console\n\n # Make sure you have pip and setuptools installed\n $ sudo pip install raspihats\n # or if using python 3\n $ sudo pip3 install raspihats\n\n\nCheckout raspihats.com_\n\n.. _raspihats.com: http://www.raspihats.com\n.. _Di16: http://raspihats.com/product/di16/\n.. _Rly10: http://raspihats.com/product/rly10/\n.. _Di6Rly6: http://raspihats.com/product/di6rly6/\n.. _DI16ac: http://raspihats.com/product/di16ac/\n.. _DQ10rly: http://raspihats.com/product/dq10rly/\n.. _DQ16oc: http://raspihats.com/product/dq16oc/\n.. _DI6acDQ6rly: http://raspihats.com/product/di6acdq6rly/\n", "description_content_type": null, "docs_url": "https://pythonhosted.org/raspihats/", "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/raspihats/raspihats", "keywords": "Raspberry Pi hats add-on boards", "license": "The MIT License (MIT)\n\nCopyright (c) 2016 raspihats\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "maintainer": "", "maintainer_email": "", "name": "raspihats", "package_url": "https://pypi.org/project/raspihats/", "platform": "", "project_url": "https://pypi.org/project/raspihats/", "project_urls": { "Homepage": "https://github.com/raspihats/raspihats" }, "release_url": "https://pypi.org/project/raspihats/2.3.0/", "requires_dist": null, "requires_python": "", "summary": "package for controlling raspihats.com boards", "version": "2.3.0" }, "last_serial": 3488925, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "6ae70a170e7ab2f12064f9973495d395", "sha256": "d04f17105fc8d0237172a0dfe1b9cb2750b691d460615260f506d66043484077" }, "downloads": -1, "filename": "raspihats-1.1.0.tar.gz", "has_sig": false, "md5_digest": "6ae70a170e7ab2f12064f9973495d395", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15023, "upload_time": "2016-07-20T18:07:50", "url": "https://files.pythonhosted.org/packages/6c/b3/0384d2070b52967cc0941fb120477ba392906d419ea23d6c01c6a2fffef5/raspihats-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "d8001c90540b1e6838ad7e3b97284f7c", "sha256": "3b8a6fd9798000ef8009027b726ab5b67068dcf13305eeb9710eb3a50e3bbb1a" }, "downloads": -1, "filename": "raspihats-1.1.1.tar.gz", "has_sig": false, "md5_digest": "d8001c90540b1e6838ad7e3b97284f7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15105, "upload_time": "2016-07-20T19:59:13", "url": "https://files.pythonhosted.org/packages/a2/66/9e1476e5c76543d0d84739970745f559943182135538ce57000348cd14be/raspihats-1.1.1.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "90c752d4dbbe011d802302539c10e8ef", "sha256": "ede6f36744b30b9ea3d182869ee4e2c1e495228c89c74034af3de28724ce79bd" }, "downloads": -1, "filename": "raspihats-2.0.0.tar.gz", "has_sig": false, "md5_digest": "90c752d4dbbe011d802302539c10e8ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18093, "upload_time": "2017-02-16T19:22:39", "url": "https://files.pythonhosted.org/packages/19/83/820ca84f9eb4f6a2c302e391d53f462e83296cc003c135f775f4e2ecc9d8/raspihats-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "da837d9de6230459ebe20d62fe909b07", "sha256": "8b6c7c755a46f8787b761ff3a3330dc0c6b1d453accccca7b449cc21b206b8af" }, "downloads": -1, "filename": "raspihats-2.0.1.tar.gz", "has_sig": false, "md5_digest": "da837d9de6230459ebe20d62fe909b07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13830, "upload_time": "2017-02-17T20:46:12", "url": "https://files.pythonhosted.org/packages/a0/fc/efbd623cc2150c192c095ed7f79810db286d9954293af60c4f4c82dde4e0/raspihats-2.0.1.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "4add498286ac3bdabad8f5b477aa8de4", "sha256": "4ba3cb1dcb64e753d3726bcfb9cfe12c42c2b1e50e1c341c6a2f937fdc818f1b" }, "downloads": -1, "filename": "raspihats-2.1.0.tar.gz", "has_sig": false, "md5_digest": "4add498286ac3bdabad8f5b477aa8de4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13859, "upload_time": "2017-04-24T12:00:19", "url": "https://files.pythonhosted.org/packages/61/d1/e377f359fd3cb52c06a4f12cacc73d76353ecb7c6d5c1456fcf7287c4d6e/raspihats-2.1.0.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "a71421c6692ea9a6ff4007e761faa73c", "sha256": "771b21c7b56cf3b1a8e36cf4a3c6bdf7b6749a0b732758c80c366ed4a7c9a1b1" }, "downloads": -1, "filename": "raspihats-2.1.1.tar.gz", "has_sig": false, "md5_digest": "a71421c6692ea9a6ff4007e761faa73c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13958, "upload_time": "2017-04-26T11:34:59", "url": "https://files.pythonhosted.org/packages/f4/52/8fac5480ac768ea5ec31b9660265c9508a9bd9ce5f19c44ae0fc1bf98d07/raspihats-2.1.1.tar.gz" } ], "2.2.1": [ { "comment_text": "", "digests": { "md5": "7d8646f12cbf9995f7e6996bc52c62f2", "sha256": "5c26811050b9ae18ce0c44fcd3685eaa74318203c62ed435c8c67879c05bcc89" }, "downloads": -1, "filename": "raspihats-2.2.1.tar.gz", "has_sig": false, "md5_digest": "7d8646f12cbf9995f7e6996bc52c62f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14274, "upload_time": "2017-04-26T19:36:35", "url": "https://files.pythonhosted.org/packages/a1/47/f34a80d8eed61c484d4592ba954df804f1711a21c29fbff85cc96a138a8b/raspihats-2.2.1.tar.gz" } ], "2.2.2": [ { "comment_text": "", "digests": { "md5": "458ac0c66bd6e8b2f0e48b9ffc958578", "sha256": "af59fe7371c58ab250845a242bc8f3857c841a8d4c13705ab6f7cd5d76e47475" }, "downloads": -1, "filename": "raspihats-2.2.2.tar.gz", "has_sig": false, "md5_digest": "458ac0c66bd6e8b2f0e48b9ffc958578", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17010, "upload_time": "2017-05-07T18:40:03", "url": "https://files.pythonhosted.org/packages/fc/d6/48412ea355642058677525b4e82b9c38345e58c4e3c6cea40363f11f1295/raspihats-2.2.2.tar.gz" } ], "2.2.3": [ { "comment_text": "", "digests": { "md5": "2747a4fada97e9acd705f9b619d46958", "sha256": "cd31cacbb3592b1255ad3d07a1212a0e3ba83dd90b2b75e6feaf6bbb5113b4df" }, "downloads": -1, "filename": "raspihats-2.2.3.tar.gz", "has_sig": false, "md5_digest": "2747a4fada97e9acd705f9b619d46958", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14765, "upload_time": "2017-09-26T10:13:37", "url": "https://files.pythonhosted.org/packages/1e/27/364af5163eaae9922e994310d5d26ae1df0e454271733ca62e3c2b7f0f3a/raspihats-2.2.3.tar.gz" } ], "2.3.0": [ { "comment_text": "", "digests": { "md5": "7957d1f23047aa3f7961791ed9193799", "sha256": "a82220618cd1d97cbbc77684b904c6f47028978a8587a7b959bd1034473009cb" }, "downloads": -1, "filename": "raspihats-2.3.0.tar.gz", "has_sig": false, "md5_digest": "7957d1f23047aa3f7961791ed9193799", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17836, "upload_time": "2018-01-14T17:15:06", "url": "https://files.pythonhosted.org/packages/5f/90/d7b2a17fd733c62acf935905204d82f3ac6367644478db98218ac63f2b13/raspihats-2.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7957d1f23047aa3f7961791ed9193799", "sha256": "a82220618cd1d97cbbc77684b904c6f47028978a8587a7b959bd1034473009cb" }, "downloads": -1, "filename": "raspihats-2.3.0.tar.gz", "has_sig": false, "md5_digest": "7957d1f23047aa3f7961791ed9193799", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17836, "upload_time": "2018-01-14T17:15:06", "url": "https://files.pythonhosted.org/packages/5f/90/d7b2a17fd733c62acf935905204d82f3ac6367644478db98218ac63f2b13/raspihats-2.3.0.tar.gz" } ] }