{ "info": { "author": "Philip Howard", "author_email": "phil@gadgetoid.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development", "Topic :: System :: Hardware" ], "description": "Pibrella\n========\n\nSupport code and API library for the Pibrella addon board.\n\nInstallation\n============\n\nThe easy way\n------------\n\n**Python 3:**\n\n sudo apt-get install python3-pip\n sudo pip-3.2 install pibrella\n\n**Python 2:**\n\n sudo apt-get install python-pip\n sudo pip install pibrella\n\nAlternative method\n------------------\n\nAlternatively you can clone this repository and install:\n\n git clone http://github.com/pimoroni/pibrella\n cd pibrella\n sudo python setup.py install\n\nTo try the examples:\n\n git clone http://github.com/pimoroni/pibrella\n cd pibrella/examples\n sudo python siren.py\n\n\nUsage\n=====\n\nRun as root!\n------------\n\nPibrella depends upon RPi.GPIO > 0.5.4, which requires root to access your GPIO.\n\nIf you're using an interactive shell you should: sudo python -i, otherwise sudo python yourscript.py\n\nFirst steps\n-----------\n\nTo get started you need to import pibrella. Simply:\n\n import pibrella\n\nThis will set up GPIO for you and collect all of the Pibrella's inputs and outputs into some handily named objects.\n\nIf, for example, you wanted to turn on an LED you could:\n\n pibrella.light.red.on()\n\nAnd to turn it off again:\n\n pibrella.light.red.off()\n\nPibrellas collections ( lights, inputs, outputs ) allow you to also control a group of things at the same time. So to turn all of the LEDs off you can simply:\n\n pibrella.light.off()\n\nOr on:\n\n pibrella.light.on()\n\n\nBlinking and pulsing LEDs\n-------------------------\n\nLights aren't simply there for toggling on and off. Any good lighting display needs pulsing, fading, blinking and strobing. Pibrella has functions for those, too:\n\n pibrella.light.red.blink(ON_TIME, OFF_TIME) \n\nAnd something more exciting:\n\n pibrella.light.red.pulse(FADE_IN_TIME, FADE_OUT_TIME, ON_TIME, OFF_TIME)\n\nThe astute observer will realise that these are equivilent:\n\n pibrella.light.red.pulse(0, 0, 1, 1)\n pibrella.light.red.blink(1, 1)\n\nYou can also fade LEDs from one brightness to another, like so:\n\n pibrella.light.red.fade(0, 100, 2) # From 0 to 100% in 2 seconds\n\n\nInputs and outputs\n------------------\n\nThe input and output collections correspond to the 4 in and 4 out pins of the Pibrella. These are named a, b, c, d for inputs and e, f, g, h for outputs- you'll see these labels on the board itself.\n\nTo turn output \"e\" on, you can:\n\n pibrella.output.e.on()\n\nYou can also write an explicit value, ( 1 is on/high, 0 is off/low ) like so\n\n pibrella.output.e.write(1)\n\nThis is useful if you want to toggle a pin on and off programmatically, or write an input value directly to an output.\n\nAnd you can write to the whole output collection simultaneously if you wish:\n\n pibrella.output.write(1)\n\nInputs are similar, except you're reading them instead of turning them on and off. To read a single input:\n\n my_value = pibrella.input.e.read()\n\nOr to read all inputs into a dictionary:\n\n inputs = pibrella.input.read()\n input_e = inputs['e']\n\n\nThe button\n----------\n\nThe Pibrella button is, for all intents and purposes, just another input. It does, however, have a pull-down resistor enabled to prevent it reading random electrical fluctuations as button presses.\n\nLike an input, you can read the button state at any time:\n\n pibrella.button.read()\n\nThe buzzer\n----------\n\nThe buzzer is just another output. However just turning it on and off wont get you much more than a single pop, it needs to be toggled rapidly to make a continuous tone. We've provided functions for this.\n\nFirst, you can buzz at a specific frequency:\n\n pibrella.buzzer.buzz( frequency )\n \nOr play a note ( you can use both positive and negative values here, with 0 being A at 440Hz )\n\n pibrella.buzzer.note( 1 )\n\nOr play a built-in tone:\n\n pibrella.buzzer.fail()\n pibrella.buzzer.success()\n\n\nHandling events\n---------------\n\nIf you want to catch an input changing state and run a specific function, you can use changed, pressed and released on any of the inputs or the button. Changed will trigger when a pin transitions from 1 ( high/on ) to 0 ( low/off ) or vice versa. Pressed will trigger when it transitions from 0 to 1, and Released when it transitions from 1 to 0.\n\nFor example:\n\n def button_pressed(pin):\n print(\"You pressed the button!\")\n\n pibrella.button.pressed(button_pressed)\n\nThe \"pin\" parameter of the button pressed function is the Pibrella pin that triggered the event, in this case \"pin\" will be equal to \"pibrella.button\" so you can .read() it.\n\n def button_changed(pin):\n if pin.read() == 1:\n print(\"You pressed the button!\")\n else:\n print(\"You released the button!\")\n\n pibrella.button.changed(button_changed)\n\nIf you want to turn a light on when the button is pressed, your code should look something like this:\n\n import pibrella\n\n def button_changed(pin):\n pibrella.light.red.write(pin.read())\n\n pibrella.button.changed(button_changed)\n\nAnd in just 4 lines, you've got started with event-driven programming!\n\nQuick Reference\n===============\n\nAll of Pibrella's inputs, outputs and lights are stored in collectons. You can reference a pin by name or by index in one of three ways:\n\n\tpibrella.light[0]\t\t# By index\n\tpibrella.light['red']\t\t# By name, for use with a variable\n\tpibrella.light.red\t\t# By name\n\nYou can also refer to a whole collection at once, simply by omitting the index or name:\n\t\n\tpibrella.light\n\nHelp Text\n---------\n\nPibrella has a small amount of built-in help. If you want to know the names of the lights, inputs or putputs simply type:\n\n pibrella.lights\n\nOr otherwise, and you'll get a list of the supported names.\n\nLights\n------\n\nThe following methods are available for every Pibrella light:\n\n\t.on()\t# Turn a light on\n\t.off()\t# Turn a light off\n\t.high()\t# Same as on\n\t.low() \t# Same as off\n\n\t.toggle() # Toggle a lights status from on to off and off to on\n\t# If lights are pulsing/blinking toggle will always turn them off\n\n\t.pulse( transition_on, transition_off, time_on, time_off )\t# Pulse a light, values in seconds\n\t.blink( time_on, time_off )\t# Blink a light, values in seconds\n\t.write( value )\t# Turn on if value = 1, or off if value = 0\n\nOutputs\n-------\n\nAn output can do everything a light can do, they are identical in all but name!\n\nInputs\n------\n\nThe following methods are available for every Pibrella input:\n\nGeneral\n-------\n\n\tpibrella.pause() # Wrapper for signal.pause(), great for pausing your application after calling blink, pulse or loop\n\n\tpibrella.loop( function_name ) # Pass pibrella a function to run over and over again, asyncronously\n\t# You must call pibrella.pause() after giving it a function to loop, or your code will simply exit!\n\n\n\nChange Log\n==========\n\n1.2\n---\n- Significant version bump to highlight launch to Production/Stable status\n- Small tweak to allow use of with, ie: \"with pibrella.light.red as red:\"\n\n1.1.7-dev\n---------\n- Fixed buzzer to stop after playing melody\n- Wrapped changed/pressed/released so they can be registered simultaneously\n- Added \"len\" to pin collections, to support random.choice(pibrella.light)\n- Added error if run without root\n\n1.1.6-dev\n---------\n- Populated LICENSE.txt\n\n1.1.5-dev\n---------\n- Renamed amber to yellow and added alias support for backwards-compatibility\n- Added lights, inputs, outputs and pins as pluralalised aliases for light, input etc\n- Tweaked how on/off/toggle calls to lights/outputs are handled during pulse/blink\n\n1.1.4-dev\n---------\n- Added pulse(), blink() and fade() to all outputs\n\n1.1.3-dev\n---------\n- Built-in asyncronous alarm sound! pibrella.buzzer.alarm()\n- Replaced xrange with range\n\n1.1.2-dev\n---------\n- Added support for REV 1 Raspberry Pi\n\n1.1.1-dev\n---------\n- Added fade(from,to,duration) for lights\n\n1.1-dev\n-------\n- Removed *.all.* keyword, use pibrella.input.read() instead of pibrella.input.all.read()\n- Added helper to list pins, try: pibrella.input in interactive shell\n- Added ['name'] and [idx] support to pin collections, try: pibrella.input[0] pibrella.input['a']\n- Added buzzer to pibrella.pin\n- Added return values to most methods\n\n1.0-dev\n-------\n- Initial development/beta release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://explore.pimoroni.com", "keywords": "Raspberry Pi Explorer HAT", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "Explorer", "package_url": "https://pypi.org/project/Explorer/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Explorer/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://explore.pimoroni.com" }, "release_url": "https://pypi.org/project/Explorer/0.1/", "requires_dist": null, "requires_python": null, "summary": "A module to control the Explorer HAT Raspberry Pi Addon Board", "version": "0.1" }, "last_serial": 1399118, "releases": { "0.1": [] }, "urls": [] }