[
  {
    "path": ".github/workflows/test.yml",
    "content": "name: Python Tests\n\non:\n  pull_request:\n  push:\n    branches:\n      - master\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python: [2.7, 3.5, 3.7, 3.9]\n\n    steps:\n      - uses: actions/checkout@v2\n      - name: Set up Python ${{ matrix.python }}\n        uses: actions/setup-python@v2\n        with:\n          python-version: ${{ matrix.python }}\n      - name: Install Dependencies\n        run: |\n          python -m pip install --upgrade setuptools tox\n      - name: Run Tests\n        working-directory: library\n        run: |\n          tox -e py\n      - name: Coverage\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        working-directory: library\n        run: |\n          python -m pip install coveralls\n          coveralls --service=github\n        if: ${{ matrix.python == '3.9' }}\n\n"
  },
  {
    "path": ".gitignore",
    "content": "build/\n_build/\n*.o\n*.so\n*.a\n*.py[cod]\n*.egg-info\ndist/\n__pycache__\n.DS_Store\n*.deb\n*.dsc\n*.build\n*.changes\n*.orig.*\npackaging/*tar.xz\nlibrary/debian/\nlibrary/blinkt\n.coverage\n.tox/\n.vscode/\n.pytest_cache/\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM resin/rpi-raspbian:jessie\n\nRUN apt-get update -qy && apt-get install -qy \\\n    python \\\n    python-rpi.gpio\n\n# Cancel out any Entrypoint already set in the base image.\nENTRYPOINT []\t\n\nWORKDIR /root/\n\nCOPY library\tlibrary\nWORKDIR /root/library\nRUN python setup.py install\n\nWORKDIR /root/\nCOPY examples\texamples\nWORKDIR /root/examples/\n\nCMD [\"python\", \"larson.py\"]\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 Pimoroni Ltd.\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"
  },
  {
    "path": "README.md",
    "content": "![Blinkt!](blinkt-logo.png)\r\n\r\n[![Build Status](https://travis-ci.com/pimoroni/blinkt.svg?branch=master)](https://travis-ci.com/pimoroni/blinkt)\r\n[![Coverage Status](https://coveralls.io/repos/github/pimoroni/blinkt/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/blinkt?branch=master)\r\n[![PyPi Package](https://img.shields.io/pypi/v/blinkt.svg)](https://pypi.python.org/pypi/blinkt)\r\n[![Python Versions](https://img.shields.io/pypi/pyversions/blinkt.svg)](https://pypi.python.org/pypi/blinkt)\r\n\r\nhttps://shop.pimoroni.com/products/blinkt\r\n\r\nEight super-bright RGB LED indicators, ideal for adding visual notifications to your Raspberry Pi on their own or on a pHAT stacking header.\r\n\r\n## Installing\r\n\r\n### Full install (recommended):\r\n\r\nWe've created an easy installation script that will install all pre-requisites and get your Blinkt!\r\nup and running with minimal efforts. To run it, fire up Terminal which you'll find in Menu -> Accessories -> Terminal\r\non your Raspberry Pi desktop, as illustrated below:\r\n\r\n![Finding the terminal](http://get.pimoroni.com/resources/github-repo-terminal.png)\r\n\r\nIn the new terminal window type the command exactly as it appears below (check for typos) and follow the on-screen instructions:\r\n\r\n```bash\r\ncurl https://get.pimoroni.com/blinkt | bash\r\n```\r\n\r\nAlternatively, on Raspbian, you can download the `pimoroni-dashboard` and install your product by browsing to the relevant entry:\r\n\r\n```bash\r\nsudo apt-get install pimoroni\r\n```\r\n(you will find the Dashboard under 'Accessories' too, in the Pi menu - or just run `pimoroni-dashboard` at the command line)\r\n\r\nIf you choose to download examples you'll find them in `/home/pi/Pimoroni/blinkt/`.\r\n\r\n### Manual install:\r\n\r\n#### Library install for Python 3:\r\n\r\non Raspbian:\r\n\r\n```bash\r\nsudo apt-get install python3-blinkt\r\n```\r\n\r\nother environments: \r\n\r\n```bash\r\nsudo pip3 install blinkt\r\n```\r\n\r\n#### Library install for Python 2:\r\n\r\non Raspbian:\r\n\r\n```bash\r\nsudo apt-get install python-blinkt\r\n```\r\n\r\nother environments: \r\n\r\n```bash\r\nsudo pip2 install blinkt\r\n```\r\n\r\n### Development:\r\n\r\nIf you want to contribute, or like living on the edge of your seat by having the latest code, you should clone this repository, `cd` to the library directory, and run:\r\n\r\n```bash\r\nsudo python3 setup.py install\r\n```\r\n(or `sudo python setup.py install` whichever your primary Python environment may be)\r\n\r\n## Documentation & Support\r\n\r\n* Guides and tutorials - https://learn.pimoroni.com/blinkt\r\n* Function reference - http://docs.pimoroni.com/blinkt/\r\n* GPIO Pinout - https://pinout.xyz/pinout/blinkt\r\n* Get help - http://forums.pimoroni.com/c/support\r\n\r\n## Unofficial / Third-party libraries\r\n\r\n* Golang library & examples by [Alex Ellis](https://www.alexellis.io) - https://github.com/alexellis/blinkt_go, https://github.com/alexellis/blinkt_go_examples\r\n* Java library by Jim Darby - https://github.com/hackerjimbo/PiJava\r\n* Java library by @HoldYourWaffle - https://github.com/HoldYourWaffle/blinkt4j\r\n* Node.js library by @irrelon - https://github.com/irrelon/node-blinkt\r\n* Rust library by @golemparts - https://github.com/golemparts/blinkt\r\n"
  },
  {
    "path": "documentation/REFERENCE.md",
    "content": "# Blinkt Function Reference\r\n\r\nThe two Blinkt methods you'll most commonly use are `set_pixel` and `show`. Here's a simple example:\r\n\r\n```\r\nfrom blinkt import set_pixel, show\r\n\r\nset_pixel(0,255,0,0)\r\nshow()\r\n```\r\n\r\n`set_pixel` takes an optional fifth parameter; the brightness from 0.0 to 1.0.\r\n\r\n`set_pixel(pixel_no, red, green, blue, brightness)`\r\n\r\nYou can also change the brightness with `set_brightness` from 0.0 to 1.0, for example:\r\n\r\n```\r\nfrom blinkt import set_brightness\r\n\r\nset_brightness(0.5)\r\nshow()\r\n```\r\n\r\nAdditionally, there exists a helper function `set_all` which allows you to set all pixels to the same color and brightness. The `brightness` parameter is just like the one in `set_pixel`: it's optional and ranges from 0.0 to 1.0.\r\n\r\n`set_all(red, green, blue, brightness)`\r\n"
  },
  {
    "path": "examples/1d_tetris.py",
    "content": "#!/usr/bin/env python\n\nimport time\nfrom random import randint\n\nimport blinkt\n\nMAX_SIZE = 4\nMAX_GRID = blinkt.NUM_PIXELS + MAX_SIZE - 1\n\nOFF = (0, 0, 0)\ngrid = [OFF] * (MAX_GRID + 1)\n\nblinkt.set_clear_on_exit()\n\n\n# The tetris algorithm fail when random_color was 0,0,0 now avoided\ndef random_color():\n    return (randint(0, 255), randint(0, 255), randint(1, 50))\n\n\ndef random_tile(max_size, min_size=1):\n    return (randint(min_size, max_size), random_color())\n\n\ndef place(tile):\n    for i in range(0, tile[0]):\n        grid[MAX_GRID - i - len(tile)] = tile[1]\n\n\ndef update():\n    for i in range(blinkt.NUM_PIXELS):\n        blinkt.set_pixel(i, grid[i][0], grid[i][1], grid[i][2])\n    blinkt.show()\n\n\ndef has_lines():\n    return grid[0] != OFF\n\n\ndef get_lines():\n    lines = []\n    for i, color in enumerate(grid):\n        if color == OFF:\n            return lines\n        else:\n            lines.append(i)\n    return lines\n\n\ndef blink_lines():\n    def hide():\n        for line in get_lines():\n            blinkt.set_pixel(line, 0, 0, 0)\n        blinkt.show()\n\n    hide()\n    time.sleep(0.5)\n    update()\n    time.sleep(0.5)\n    hide()\n    time.sleep(0.5)\n\n\ndef remove_lines():\n    for line in get_lines():\n        grid[line] = OFF\n\n\ndef gravity():\n    grid.append(OFF)\n    grid.pop(0)\n\n\ndef main():\n    blinkt.set_brightness(0.1)\n    place(random_tile(MAX_SIZE))\n    update()\n\n    while True:\n        time.sleep(0.5)\n\n        if has_lines():\n            blink_lines()\n            remove_lines()\n            place(random_tile(MAX_SIZE))\n        else:\n            gravity()\n\n        update()\n\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "examples/README.md",
    "content": "## Examples\n\nThe examples in this directory should just work with Blinkt!, although you'll need to add Twitter developer access tokens and secrets in the `twitter_monitor.py` example. You can get these at [https://dev.twitter.com/](https://dev.twitter.com/), after setting up a new application. Where noted, the instructions for adding keys / installing modules are in the code itself.\n\nThe examples in the `extra_examples` folder are designed to work with other pHATs and HATs, so be aware of that before trying them.\n\n## List of examples with basic instructions\n\n- 1d_tetris - shows randomly coloured lights falling into place and clearing occasionally. No input needed. Offline.\n- binary_clock - shows time in hours, minutes, and seconds using the local time from your Pi. No input needed. Offline.\n- binary_clock_meld - shows time in hours (red), minutes (green) and seconds (blue) using local time from your Pi. No input needed. Offline.\n- blinkt_thermo - draws a graph of the temperature based on the openweather data for whatever city you set it to. Needs keys and ID from openweathermap.org. Online.\n- candle - flickers the pixels in a candle effect. May require a numpy install. Offline.\n- cheerlights - reads twitter for any tweets with the hashtag \"cheerlights\" and a colour. Changes all the pixels to that colour. Online.\n- cpu_load - shows a graph of cpu usage as a percentage. May require a psutil install. Offline.\n- cpu_temp - shows a graph of the cpu temperature as a percentage. Offline.\n- eyedropper - shows the rgb value at cursor location real time. Offline.\n- gradient_graph - pulses a rainbow across the blinkt and back again. Offline.\n- graph - pulses a magenta graph across the blinkt and back again. Offline.\n- larson - remember Knight Rider? Offline.\n- larson_hue - same as larson, but in rainbow colours! Offline.\n- mem_load - shows a graph of the memory load on the Pi as a percentage. Offline.\n- morse_code - shows a message in [warning: flashing] morse code. Change line 40 if you want a different message. Offline.\n- mqtt - send controls remotely to your Blinkt. May require a paho-mqtt install. Requires setup on another machine as per instructions in the code. Online.\n- pulse - pulses cyan light from the centre pixels to outer edges. Offline.\n- rainbow - shows a gently moving rainbow along the blinkt. Yay, rainbows! Offline.\n- random_blink - blinks yellow lights at random, like paparazzi in a crowd. Change colour on line 14 if you like. Offline.\n- random_blink_colours - imagine if the paparazzi were carrying pastel unicorns. Offline.\n- resistor_clock - shows the time in pairs of pixels, using resistor codes. Brown light (representing a 1) is a bit hard to see. Offline.\n- rgb - Run this one a bit differently. Type python rgb.py and then three values, eg python rgb.py 10 90 80 will make it turn on cyan, python rgb.py 100 0 0 will make it turn on red. Offline.\n- setup.cfg is NOT an example.\n- solid_colours - Flashes red, green, blue on repeat. You can change the colours on lines 14, 17 and 20. Offline.\n- twitter_monitor - Will show a notification when the hashtag of your choice (line 48) is mentioned on Twitter. You need to add consumer key, consumer secret, access token and access secret (see instructions at top of this document). Online.\n"
  },
  {
    "path": "examples/anvil-colour-control.py",
    "content": "# Basic example for controlling the Blinkt LED colours via Anvil\n# Learn more at: https://anvil.works/\n#\n# Dependencies:\n#\n# python3 -m pip install blinkt colour anvil-uplink\n#\n# Run this example with:\n#\n# python3 anvil-colour-control.py\n#\n# You'll be prompted for an email address to set up the web control\n# portion of this example.\n#\n# Check your email, click the link and- when the app has loads -\n# hit the \"Run\" button at the top to start remote-controlling\n# your Blinkt!\n\nimport blinkt\nfrom colour import Color\n\nfrom anvil.app_creator import create_app\nimport anvil.server\n\n# Create the Blinkt demo app in your Anvil account\napp = create_app(\"blinkt\")\n\n# Define functions that can be called from your Anvil app on the web\nanvil.server.connect(app.uplink_key)\n\n\n@anvil.server.callable\ndef set_color(color_string):\n    print(\"Setting LEDs to {}\".format(color_string))\n    c = Color(color_string)\n    blinkt.set_all(c.red * 255, c.green * 255, c.blue * 255, 1.0)\n    blinkt.show()\n\n\n@anvil.server.callable\ndef clear():\n    print(\"Clearing LEDs\")\n    blinkt.clear()\n    blinkt.show()\n\n\n# Display the URL where you can control the Blinkt LEDS\nprint(\"Control your Blinkt LEDs at {}\".format(app.origin))\nprint(\"Press Ctrl-C to exit\")\n\n# Keep the script running until the user exits with Ctrl-C\nanvil.server.wait_forever()\n"
  },
  {
    "path": "examples/binary_clock.py",
    "content": "#!/usr/bin/env python\n\nfrom time import localtime, sleep\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\nMODE_HOUR = 0\nMODE_MIN = 1\nMODE_SEC = 2\nMODE_NAMES = {MODE_HOUR: 'Hour mode',\n              MODE_MIN: 'Minute mode',\n              MODE_SEC: 'Seconds mode'}\n\ntime_to_stay_in_mode = 3\ntime_in_mode = 0\nmode = 0\n\nlh = 0\nlm = 0\n\nwhile True:\n    t = localtime()\n    h, m, s = t.tm_hour, t.tm_min, t.tm_sec\n\n    if h != lh:\n        mode = MODE_HOUR\n        time_in_mode = 0\n\n    elif m != lm:\n        mode = MODE_MIN\n        time_in_mode = 0\n\n    lm = m\n    lh = h\n\n    blinkt.clear()\n\n    if (s % 2) == 0:\n        blinkt.set_pixel(1, 64, 64, 64)\n\n    if mode == MODE_HOUR:\n        blinkt.set_pixel(0, 255, 0, 0)\n        for x in range(6):\n            bit = (h & (1 << x)) > 0\n            r, g, b = [128 * bit] * 3\n            blinkt.set_pixel(7 - x, r, g, b)\n\n    if mode == MODE_MIN:\n        blinkt.set_pixel(0, 0, 255, 0)\n        for x in range(6):\n            bit = (m & (1 << x)) > 0\n            r, g, b = [128 * bit] * 3\n            blinkt.set_pixel(7 - x, r, g, b)\n\n    if mode == MODE_SEC:\n        blinkt.set_pixel(0, 0, 0, 255)\n        for x in range(6):\n            bit = (s & (1 << x)) > 0\n            r, g, b = [128 * bit] * 3\n            blinkt.set_pixel(7 - x, r, g, b)\n\n    blinkt.show()\n    print('{h:2d}:{m:02d}:{s:02d}; mode: {mode}; time in mode: {tim}'.format(h=h,\n                                                                             m=m,\n                                                                             s=s,\n                                                                             mode=MODE_NAMES[mode],\n                                                                             tim=time_in_mode))\n\n    time_in_mode += 1\n    if time_in_mode == time_to_stay_in_mode:\n        mode += 1\n        mode %= 3\n        time_in_mode = 0\n\n    sleep(1)\n"
  },
  {
    "path": "examples/binary_clock_meld.py",
    "content": "#!/usr/bin/env python\n\nfrom time import localtime, sleep\n\nimport blinkt\n\n\nprint('Hour = Red, Minute = Green, Second = Blue')\n\nblinkt.set_clear_on_exit()\n\nblinkt.set_brightness(0.2)\n\non_value = 64\n\nwhile True:\n    t = localtime()\n    h, m, s = t.tm_hour, t.tm_min, t.tm_sec\n\n    print('{h:2d}:{m:02d}:{s:02d}'.format(h=h, m=m, s=s))\n\n    blinkt.clear()\n\n    # Blink LED 0\n    v = on_value * (s % 2)\n    blinkt.set_pixel(0, v, v, v)\n\n    for n in range(6):\n        # Grab the n'th bit from hour, min and second\n        bit_h = (h & (1 << n)) > 0\n        bit_m = (m & (1 << n)) > 0\n        bit_s = (s & (1 << n)) > 0\n\n        r, g, b = [int(c * on_value) for c in (bit_h, bit_m, bit_s)]\n\n        blinkt.set_pixel(7 - n, r, g, b)\n\n    blinkt.show()\n\n    sleep(1)\n"
  },
  {
    "path": "examples/blinkt_thermo.py",
    "content": "#!/usr/bin/env python\n\n# Data from OpenWeatherMap\n# show_graph function adapted from cpu_temp.py\n\nfrom time import sleep\nfrom sys import exit\n\ntry:\n    import requests\nexcept ImportError:\n    exit('This script requires the requests module\\nInstall with: sudo pip install requests')\n\nimport blinkt\n\n\n# Grab your API key here: http://openweathermap.org\n# List of city ID city.list.json.gz can be downloaded here http://bulk.openweathermap.org/sample/\nAPI_KEY = ''\nCITY_ID = ''\n\nurl = 'http://api.openweathermap.org/data/2.5/weather'\n\ntemp = 0\n\n\ndef update_weather():\n    global temp\n    payload = {\n        'id': CITY_ID,\n        'units': 'metric',\n        'appid': API_KEY\n    }\n    try:\n        r = requests.get(url=url, params=payload)\n        temp = r.json().get('main').get('temp')\n        print('Temperture = ' + str(temp) + ' C')\n\n    except requests.exceptions.ConnectionError:\n        print('Connection Error')\n\n\ndef show_graph(v, r, g, b):\n    v *= blinkt.NUM_PIXELS\n    for x in range(blinkt.NUM_PIXELS):\n        if v < 0:\n            r, g, b = 0, 0, 0\n        else:\n            r, g, b = [int(min(v, 1.0) * c) for c in [r, g, b]]\n        blinkt.set_pixel(x, r, g, b)\n        v -= 1\n    blinkt.show()\n\n\ndef draw_thermo(temp):\n    v = temp\n    v /= 40\n    v += (1 / 8)\n    show_graph(v, 255, 0, 0)\n\n\nblinkt.set_brightness(0.1)\n\nwhile 1:\n    update_weather()\n    draw_thermo(temp)\n    sleep(120)\n"
  },
  {
    "path": "examples/candle.py",
    "content": "#!/usr/bin/env python\n\nimport colorsys\nimport time\nfrom sys import exit\n\ntry:\n    import numpy as np\nexcept ImportError:\n    exit('This script requires the numpy module\\nInstall with: sudo apt install python3-numpy')\n\nimport blinkt\n\n\nblinkt.clear()\nstart = 0\nend = 60\n\nwhile True:\n    wait = np.random.choice(np.random.noncentral_chisquare(5, 1, 1000), 1)[0] / 50\n    n = np.random.choice(np.random.noncentral_chisquare(5, 0.1, 1000), 1)\n    limit = int(n[0])\n\n    if limit > blinkt.NUM_PIXELS:\n        limit = blinkt.NUM_PIXELS\n\n    for pixel in range(limit):\n        hue = start + (((end - start) / float(blinkt.NUM_PIXELS)) * pixel)\n        r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(hue / 360.0, 1.0, 1.0)]\n        blinkt.set_pixel(pixel, r, g, b)\n        blinkt.show()\n        time.sleep(0.05 / (pixel + 1))\n\n    time.sleep(wait)\n    blinkt.clear()\n"
  },
  {
    "path": "examples/cheerlights.py",
    "content": "#!/usr/bin/env python\nimport time\nfrom sys import exit\n\ntry:\n    import requests\nexcept ImportError:\n    exit('This script requires the requests module\\nInstall with: sudo pip install requests')\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\n\ndef hex_to_rgb(col_hex):\n    \"\"\"Convert a hex colour to an RGB tuple.\"\"\"\n    col_hex = col_hex.lstrip('#')\n    return bytearray.fromhex(col_hex)\n\n\nwhile True:\n    r = requests.get('http://api.thingspeak.com/channels/1417/field/2/last.json', timeout=2)\n    json = r.json()\n\n    if 'field2' not in json:\n        print('Error {status}: {error}'.format(status=json['status'], error=json['error']))\n        time.sleep(5)\n        continue\n\n    r, g, b = hex_to_rgb(json['field2'])\n\n    for i in range(blinkt.NUM_PIXELS):\n        blinkt.set_pixel(i, r, g, b)\n\n    blinkt.show()\n\n    time.sleep(5)  # Be friendly to the API\n"
  },
  {
    "path": "examples/cpu_load.py",
    "content": "#!/usr/bin/env python\nimport time\nfrom sys import exit\n\ntry:\n    import psutil\nexcept ImportError:\n    exit('This script requires the psutil module\\nInstall with: sudo apt install python3-psutil')\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\n\ndef show_graph(v, r, g, b):\n    v *= blinkt.NUM_PIXELS\n    for x in range(blinkt.NUM_PIXELS):\n        if v < 0:\n            r, g, b = 0, 0, 0\n        else:\n            r, g, b = [int(min(v, 1.0) * c) for c in [r, g, b]]\n        blinkt.set_pixel(x, r, g, b)\n        v -= 1\n\n    blinkt.show()\n\n\nblinkt.set_brightness(0.1)\n\nwhile True:\n    v = psutil.cpu_percent() / 100.0\n    show_graph(v, 255, 255, 255)\n    time.sleep(0.01)\n"
  },
  {
    "path": "examples/cpu_temp.py",
    "content": "#!/usr/bin/env python\n\nimport time\nfrom subprocess import PIPE, Popen\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\n\ndef get_cpu_temperature():\n    process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)\n    output, _error = process.communicate()\n    output = output.decode()\n\n    pos_start = output.index('=') + 1\n    pos_end = output.rindex(\"'\")\n\n    temp = float(output[pos_start:pos_end])\n\n    return temp\n\n\ndef show_graph(v, r, g, b):\n    v *= blinkt.NUM_PIXELS\n    for x in range(blinkt.NUM_PIXELS):\n        if v < 0:\n            r, g, b = 0, 0, 0\n        else:\n            r, g, b = [int(min(v, 1.0) * c) for c in [r, g, b]]\n\n        blinkt.set_pixel(x, r, g, b)\n        v -= 1\n\n    blinkt.show()\n\n\nblinkt.set_brightness(0.1)\n\nwhile True:\n    v = get_cpu_temperature() / 100.0\n    show_graph(v, 255, 255, 255)\n    time.sleep(0.01)\n"
  },
  {
    "path": "examples/extra_examples/README.md",
    "content": "#Extra Examples\n\nThe examples in this folder are designed to work with other pHATs and HATs:\n\n* drum_hits.py expects a Drum HAT to be available and the relevant Python library installed\n\n* pov_rainbow.py and spirit_level.py expects an Enviro pHAT to be available and the relevant Python library installed\n\n"
  },
  {
    "path": "examples/extra_examples/drum_hits.py",
    "content": "#!/usr/bin/env python\n\nimport glob\nimport os\nimport time\nfrom sys import exit\n\ntry:\n    import drumhat\nexcept ImportError:\n    exit('This script requires the drumhat module\\nInstall with: sudo pip install drumhat')\n\ntry:\n    import pygame\nexcept ImportError:\n    exit('This script requires the pygame module\\nInstall with: sudo pip install pygame')\n\nimport blinkt\n\n\nDRUM_FOLDER = 'drums2'\n\nBANK = os.path.join(os.path.dirname(__file__), DRUM_FOLDER)\n\npygame.mixer.init(44100, -16, 1, 512)\npygame.mixer.set_num_channels(16)\n\nfiles = glob.glob(os.path.join(BANK, '*.wav'))\nfiles.sort()\n\nsamples = [pygame.mixer.Sound(f) for f in files]\n\n\ndef show_all(state):\n    for i in range(8):\n        val = state * 255\n        blinkt.set_pixel(i, val, val, val)\n    blinkt.show()\n\n\ndef handle_hit(event):\n    samples[event.channel].play(loops=0)\n    show_all(1)\n    print('You hit pad {}, playing: {}'.format(event.pad, files[event.channel]))\n\n\ndef handle_release():\n    show_all(0)\n\n\ndrumhat.on_hit(drumhat.PADS, handle_hit)\ndrumhat.on_release(drumhat.PADS, handle_release)\n\nwhile True:\n    time.sleep(1)\n"
  },
  {
    "path": "examples/extra_examples/pov_rainbow.py",
    "content": "#!/usr/bin/env python\n\nimport time\nfrom colorsys import hsv_to_rgb\nfrom sys import exit\n\ntry:\n    from envirophat import motion\nexcept ImportError:\n    exit('This script requires the envirophat module\\nInstall with: sudo pip install envirophat')\n\nimport blinkt\n\noffset = 0\ndirection = 0\nt = []\nt_start = 0\n\ntotal_time = 1000\n\n\ndef millis():\n    return int(round(time.time() * 1000))\n\n\nwhile True:\n    x, y, z = motion.accelerometer()\n    print(y)\n\n    if y < -1.9 and not direction == -1:\n        direction = -1\n        t.append(millis() - t_start)\n        t_start = millis()\n        t = t[-5:]\n\n    if y > 1.9 and not direction == 1:\n        direction = 1\n        t.append(millis() - t_start)\n        t_start = millis()\n        t = t[-5:]\n\n    if len(t) > 0:\n        total_time = float(sum(t)) / len(t)\n\n    offset = ((millis() - t_start) / total_time)\n\n    # offset += direction * 10\n\n    offset = min(1.0, offset)\n    offset = max(0.0, offset)\n\n    hue = offset\n\n    if direction == -1:\n        hue = 1.0 - offset\n\n    r, g, b = [int(c * 255.0) for c in hsv_to_rgb(hue, 1.0, 1.0)]\n\n    for x in range(8):\n        blinkt.set_pixel(x, r, g, b)\n\n    blinkt.show()\n\n    time.sleep(0.0001)\n"
  },
  {
    "path": "examples/extra_examples/spirit_level.py",
    "content": "#!/usr/bin/env python\n\nimport time\nfrom sys import exit\n\ntry:\n    from envirophat import motion\nexcept ImportError:\n    exit('This script requires the envirophat module\\nInstall with: sudo pip install envirophat')\n\nimport blinkt\n\n\nx_avg = []\n\nwhile True:\n    x, y, z = motion.accelerometer()\n\n    x_avg.append(x)\n    x_avg = x_avg[-5:]\n\n    x = float(sum(x_avg)) / len(x_avg)\n    x = max(-1, x)\n    x = min(1, x)\n\n    blinkt.clear()\n    if abs(x) < 0.05:\n        blinkt.set_pixel(3, 0, 255, 0)\n        blinkt.set_pixel(4, 0, 255, 0)\n\n    elif x > 0:\n        val = abs(x) * 4.0\n        for x in range(4):\n            if val < 0:\n                break\n            blinkt.set_pixel(3 - x, int(255.0 * min(val, 1.0)), 0, 0)\n            val -= 1\n\n    elif x < 0:\n        val = abs(x) * 4.0\n        for x in range(4):\n            if val < 0:\n                break\n            blinkt.set_pixel(4 + x, int(255.0 * min(val, 1.0)), 0, 0)\n            val -= 1\n\n    blinkt.show()\n\n    time.sleep(0.01)\n"
  },
  {
    "path": "examples/eyedropper.py",
    "content": "#!/usr/bin/env python3\n\nfrom PIL import ImageGrab\nimport pyautogui\nimport blinkt\nimport time\n\nprint('Press Ctrl-C to quit.')\n\ntry:\n    while True:\n        x, y = pyautogui.position()\n        im = ImageGrab.grab(bbox=(x - 1, y, x, y + 1))\n        rawrgb = list(im.getdata())\n        rgb = str(rawrgb)[2:-2]\n        r, g, b = rgb.split(', ')\n        blinkt.set_all(r, g, b)\n        blinkt.set_brightness(1)\n        blinkt.show()\n        time.sleep(0.01)\nexcept KeyboardInterrupt:\n    print('\\n')\n"
  },
  {
    "path": "examples/gradient_graph.py",
    "content": "#!/usr/bin/env python\n\nimport colorsys\nimport math\nimport time\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\nhue_range = 120\nhue_start = 0\nmax_brightness = 0.2\n\n\ndef show_graph(v, r, g, b):\n    v *= blinkt.NUM_PIXELS\n    for x in range(blinkt.NUM_PIXELS):\n        hue = ((hue_start + ((x / float(blinkt.NUM_PIXELS)) * hue_range)) % 360) / 360.0\n        r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(hue, 1.0, 1.0)]\n        if v < 0:\n            brightness = 0\n        else:\n            brightness = min(v, 1.0) * max_brightness\n\n        blinkt.set_pixel(x, r, g, b, brightness)\n        v -= 1\n\n    blinkt.show()\n\n\nblinkt.set_brightness(0.1)\n\ntry:\n    while True:\n        t = time.time() * 2\n        v = (math.sin(t) + 1) / 2  # Get a value between 0 and 1\n        show_graph(v, 255, 0, 255)\n        time.sleep(0.01)\n\nexcept KeyboardInterrupt:\n    pass\n"
  },
  {
    "path": "examples/graph.py",
    "content": "#!/usr/bin/env python\n\nimport math\nimport time\n\nimport blinkt\n\n\nblinkt.set_clear_on_exit()\n\n\ndef show_graph(v, r, g, b):\n    v *= blinkt.NUM_PIXELS\n    for x in range(blinkt.NUM_PIXELS):\n        if v < 0:\n            r, g, b = 0, 0, 0\n        else:\n            r, g, b = [int(min(v, 1.0) * c) for c in [r, g, b]]\n        blinkt.set_pixel(x, r, g, b)\n        v -= 1\n\n    blinkt.show()\n\n\nblinkt.set_brightness(0.1)\n\ntry:\n    while True:\n        t = time.time()\n        v = (math.sin(t) + 1) / 2  # Get a value between 0 and 1\n        show_graph(v, 255, 0, 255)\n        time.sleep(0.01)\n\nexcept KeyboardInterrupt:\n    pass\n"
  },
  {
    "path": "examples/half.py",
    "content": "#!/usr/bin/env python\n\nimport blinkt\n\nblinkt.set_clear_on_exit(False)\nblinkt.set_all(255, 255, 255, 0.5)\nblinkt.show()\n"
  },
  {
    "path": "examples/kitt.py",
    "content": "#!/usr/bin/env python\n\nimport time          # so we can wait between frames\nimport blinkt        # so we can talk to our blinkt lights!\n\nBRIGHTNESS = 0.2     # range is 0.0 to 1.0\nMAX_COLOUR = 255     # range is 0 to 255\nDECAY_FACTOR = 1.5   # how quickly should MAX_COLOUR fade? (1.5 works well)\nTIME_SLEEP = 0.04    # seconds (0.04 works well)\n\nPIXELS = blinkt.NUM_PIXELS  # usually 8, can use fewer if you like!\n\nblinkt.clear         # make all pixels blank / black\nblinkt.set_brightness(BRIGHTNESS)\n\nbrightpixel = -1\ndirection = 1\n\nprint('Hello Michael.\\nHow are you today?')\n\nwhile True:\n    # decay all pixels\n    for x in range(PIXELS):\n        pixel = blinkt.get_pixel(x)  # format is [ r, g, b, brightness? ]\n        blinkt.set_pixel(x, pixel[0] / DECAY_FACTOR, 0, 0)\n\n    # brightpixel should move back and forth all the pixels,\n    # in a ping-pong, triangle wave. Not (co)sine.\n    brightpixel += direction\n\n    if brightpixel >= PIXELS - 1:\n        brightpixel = PIXELS - 1\n        direction = - abs(direction)\n    if brightpixel <= 0:\n        brightpixel = 0\n        direction = abs(direction)\n\n    blinkt.set_pixel(brightpixel, MAX_COLOUR, 0, 0)\n\n    blinkt.show()           # draw the lights!\n    time.sleep(TIME_SLEEP)  # wait a bit before working on next frame\n"
  },
  {
    "path": "examples/larson.py",
    "content": "#!/usr/bin/env python\n\nimport time\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\nREDS = [0, 0, 0, 0, 0, 16, 64, 255, 64, 16, 0, 0, 0, 0, 0, 0]\n\nstart_time = time.time()\n\nwhile True:\n    # Sine wave, spends a little longer at min/max\n    # delta = (time.time() - start_time) * 8\n    # offset = int(round(((math.sin(delta) + 1) / 2) * (blinkt.NUM_PIXELS - 1)))\n\n    # Triangle wave, a snappy ping-pong effect\n    delta = (time.time() - start_time) * 16\n    offset = int(abs((delta % len(REDS)) - blinkt.NUM_PIXELS))\n\n    for i in range(blinkt.NUM_PIXELS):\n        blinkt.set_pixel(i, REDS[offset + i], 0, 0)\n\n    blinkt.show()\n\n    time.sleep(0.1)\n"
  },
  {
    "path": "examples/larson_hue.py",
    "content": "#!/usr/bin/env python\n\nimport math\nimport time\nimport colorsys\n\nimport blinkt\n\nFALLOFF = 1.9\nSCAN_SPEED = 4\n\nblinkt.set_clear_on_exit()\n\nstart_time = time.time()\n\nwhile True:\n    delta = (time.time() - start_time)\n\n    # Offset is a sine wave derived from the time delta\n    # we use this to animate both the hue and larson scan\n    # so they are kept in sync with each other\n    offset = (math.sin(delta * SCAN_SPEED) + 1) / 2\n\n    # Use offset to pick the right colour from the hue wheel\n    hue = int(round(offset * 360))\n\n    # Maximum number basex on NUM_PIXELS\n    max_val = blinkt.NUM_PIXELS - 1\n\n    # Now we generate a value from 0 to max_val\n    offset = int(round(offset * max_val))\n\n    for x in range(blinkt.NUM_PIXELS):\n        sat = 1.0\n\n        val = max_val - (abs(offset - x) * FALLOFF)\n        val /= float(max_val)   # Convert to 0.0 to 1.0\n        val = max(val, 0.0)     # Ditch negative values\n\n        xhue = hue              # Grab hue for this pixel\n        xhue += (1 - val) * 10  # Use the val offset to give a slight colour trail variation\n        xhue %= 360             # Clamp to 0-359\n        xhue /= 360.0           # Convert to 0.0 to 1.0\n\n        r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(xhue, sat, val)]\n\n        blinkt.set_pixel(x, r, g, b, val / 4)\n\n    blinkt.show()\n\n    time.sleep(0.001)\n"
  },
  {
    "path": "examples/max.py",
    "content": "#!/usr/bin/env python\n\nimport blinkt\n\nblinkt.set_clear_on_exit(False)\nblinkt.set_all(255, 255, 255, 1.0)\nblinkt.show()\n"
  },
  {
    "path": "examples/mem_load.py",
    "content": "#!/usr/bin/env python\n\nimport time\nfrom sys import exit\n\ntry:\n    import psutil\nexcept ImportError:\n    exit('This script requires the psutil module\\nInstall with: sudo apt install python3-psutil')\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\n\ndef show_graph(v, r, g, b):\n    v *= blinkt.NUM_PIXELS\n    for x in range(blinkt.NUM_PIXELS):\n        if v < 0:\n            r, g, b = 0, 0, 0\n        else:\n            r, g, b = [int(min(v, 1.0) * c) for c in [r, g, b]]\n\n        blinkt.set_pixel(x, r, g, b)\n        v -= 1\n\n    blinkt.show()\n\n\nblinkt.set_brightness(0.1)\n\nwhile True:\n    v = psutil.virtual_memory().percent / 100.0\n    show_graph(v, 255, 0, 255)\n    time.sleep(0.01)\n"
  },
  {
    "path": "examples/morse_code.py",
    "content": "#!/usr/bin/env python\n\nimport time\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\n\ndef show_all(state):\n    \"\"\"Set all LEDs.\"\"\"\n    for i in range(blinkt.NUM_PIXELS):\n        val = state * 255\n        blinkt.set_pixel(i, val, val, val)\n    blinkt.show()\n\n\ndef dot():\n    \"\"\"Blink LEDs for 0.05 seconds.\"\"\"\n    show_all(1)\n    time.sleep(0.05)\n    show_all(0)\n    time.sleep(0.2)\n\n\ndef dash():\n    \"\"\"Blink LEDs for 0.2 seconds.\"\"\"\n    show_all(1)\n    time.sleep(0.2)\n    show_all(0)\n    time.sleep(0.2)\n\n\ndef space():\n    \"\"\"Delay for 0.02 seconds.\"\"\"\n    time.sleep(0.2)\n\n\n# 0 is a space, 1 is a dot and 2 is a dash\nMORSE = ' -... .. . -..  - -. .  - . -  -.  -. -   '\n\nwhile True:\n    for m in MORSE:\n        if m == ' ':\n            space()\n        elif m == '.':\n            dot()\n        elif m == '-':\n            dash()\n"
  },
  {
    "path": "examples/mqtt.py",
    "content": "#!/usr/bin/env python\nfrom sys import exit\n\ntry:\n    import paho.mqtt.client as mqtt\nexcept ImportError:\n    exit('This example requires the paho-mqtt module\\nInstall with: sudo pip install paho-mqtt')\n\nimport blinkt\n\n\nMQTT_SERVER = 'iot.eclipse.org'\nMQTT_PORT = 1883\nMQTT_TOPIC = 'pimoroni/blinkt'\n\n# Set these to use authorisation\nMQTT_USER = None\nMQTT_PASS = None\n\nprint(\"\"\"\nMQTT Blinkt! Control\n\nThis example uses public MQTT messages from {server} on port {port} to control Blinkt!\n\nIt will monitor the {topic} topic by default, and understands the following messages:\n\nrgb,<pixel>,<r>,<g>,<b> - Set a single pixel to an RGB colour. Example: rgb,1,255,0,255\nclr - Clear Blinkt!\n\nYou can use the online MQTT tester at http://www.hivemq.com/demos/websocket-client/ to send messages.\n\nUse {server} as the host, and port 80 (Eclipse's websocket port). Set the topic to topic: {topic}\n\"\"\".format(\n    server=MQTT_SERVER,\n    port=MQTT_PORT,\n    topic=MQTT_TOPIC\n))\n\n\ndef on_connect(client, userdata, flags, rc):\n    print('Connected with result code ' + str(rc))\n\n    client.subscribe(MQTT_TOPIC)\n\n\ndef on_message(client, userdata, msg):\n\n    data = msg.payload\n    if type(data) is bytes:\n        data = data.decode('utf-8')\n    data = data.split(',')\n    command = data.pop(0)\n\n    if command == 'clr' and len(data) == 0:\n        blinkt.clear()\n        blinkt.show()\n        return\n\n    if command == 'rgb' and len(data) == 4:\n        try:\n            pixel = data.pop(0)\n\n            if pixel == '*':\n                pixel = None\n            else:\n                pixel = int(pixel)\n                if pixel > 7:\n                    print('Pixel out of range: ' + str(pixel))\n                    return\n\n            r, g, b = [int(x) & 0xff for x in data]\n\n            print(command, pixel, r, g, b)\n\n        except ValueError:\n            print('Malformed command: ' + str(msg.payload))\n            return\n\n        if pixel is None:\n            for x in range(blinkt.NUM_PIXELS):\n                blinkt.set_pixel(x, r, g, b)\n        else:\n            blinkt.set_pixel(pixel, r, g, b)\n\n        blinkt.show()\n        return\n\n\nblinkt.set_clear_on_exit()\n\nclient = mqtt.Client()\nclient.on_connect = on_connect\nclient.on_message = on_message\n\nif MQTT_USER is not None and MQTT_PASS is not None:\n    print('Using username: {un} and password: {pw}'.format(un=MQTT_USER, pw='*' * len(MQTT_PASS)))\n    client.username_pw_set(username=MQTT_USER, password=MQTT_PASS)\n\nclient.connect(MQTT_SERVER, MQTT_PORT, 60)\n\nclient.loop_forever()\n"
  },
  {
    "path": "examples/off.py",
    "content": "#!/usr/bin/env python\n\nimport blinkt\n\nblinkt.clear()\nblinkt.show()\n"
  },
  {
    "path": "examples/pulse.py",
    "content": "#!/usr/bin/env python\n\nimport colorsys\nimport time\nfrom sys import exit\n\ntry:\n    import numpy as np\nexcept ImportError:\n    exit('This script requires the numpy module\\nInstall with: sudo pip install numpy')\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\n\ndef make_gaussian(fwhm):\n    x = np.arange(0, blinkt.NUM_PIXELS, 1, float)\n    y = x[:, np.newaxis]\n    x0, y0 = 3.5, 3.5\n    fwhm = fwhm\n    gauss = np.exp(-4 * np.log(2) * ((x - x0) ** 2 + (y - y0) ** 2) / fwhm ** 2)\n    return gauss\n\n\nwhile True:\n    for z in list(range(1, 10)[::-1]) + list(range(1, 10)):\n        fwhm = 5.0 / z\n        gauss = make_gaussian(fwhm)\n        start = time.time()\n        y = 4\n\n        for x in range(blinkt.NUM_PIXELS):\n            h = 0.5\n            s = 1.0\n            v = gauss[x, y]\n            rgb = colorsys.hsv_to_rgb(h, s, v)\n            r, g, b = [int(255.0 * i) for i in rgb]\n            blinkt.set_pixel(x, r, g, b)\n\n        blinkt.show()\n        end = time.time()\n        t = end - start\n\n        if t < 0.04:\n            time.sleep(0.04 - t)\n"
  },
  {
    "path": "examples/rainbow.py",
    "content": "#!/usr/bin/env python\n\nimport colorsys\nimport time\n\nimport blinkt\n\nspacing = 360.0 / 16.0\nhue = 0\n\nblinkt.set_clear_on_exit()\nblinkt.set_brightness(0.1)\n\nwhile True:\n    hue = int(time.time() * 100) % 360\n    for x in range(blinkt.NUM_PIXELS):\n        offset = x * spacing\n        h = ((hue + offset) % 360) / 360.0\n        r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]\n        blinkt.set_pixel(x, r, g, b)\n\n    blinkt.show()\n    time.sleep(0.001)\n"
  },
  {
    "path": "examples/random_blink.py",
    "content": "#!/usr/bin/env python\n\nimport random\nimport time\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\n\nwhile True:\n    pixels = random.sample(range(blinkt.NUM_PIXELS), random.randint(1, 5))\n    for i in range(blinkt.NUM_PIXELS):\n        if i in pixels:\n            blinkt.set_pixel(i, 255, 150, 0)\n        else:\n            blinkt.set_pixel(i, 0, 0, 0)\n    blinkt.show()\n    time.sleep(0.05)\n"
  },
  {
    "path": "examples/random_blink_colours.py",
    "content": "#!/usr/bin/env python\n\nimport random\nimport time\n\nimport blinkt\n\nblinkt.set_clear_on_exit()\nblinkt.set_brightness(0.1)\n\nwhile True:\n    for i in range(blinkt.NUM_PIXELS):\n        blinkt.set_pixel(i, random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))\n\n    blinkt.show()\n    time.sleep(0.05)\n"
  },
  {
    "path": "examples/resistor_clock.py",
    "content": "#!/usr/bin/env python\n\nimport time\n\nimport blinkt\n\n\ncolours = [\n    [0, 0, 0],        # 0 black\n    [139, 69, 19],    # 1 brown\n    [255, 0, 0],      # 2 red\n    [255, 69, 0],     # 3 orange\n    [255, 255, 0],    # 4 yellow\n    [0, 255, 0],      # 5 green\n    [0, 0, 255],      # 6 blue\n    [128, 0, 128],    # 7 violet\n    [255, 255, 100],  # 8 grey\n    [255, 255, 255],  # 9 white\n]\n\nblinkt.set_clear_on_exit()\n\nwhile True:\n    hour = time.localtime().tm_hour\n    minute = time.localtime().tm_min\n\n    hourten = int(hour / 10)\n    hourunit = int(hour % 10)\n    minuteten = int(minute / 10)\n    minuteunit = int(minute % 10)\n\n    r, g, b = colours[hourten]\n    blinkt.set_pixel(0, r, g, b)\n    blinkt.set_pixel(1, r, g, b)\n\n    r, g, b = colours[hourunit]\n    blinkt.set_pixel(2, r, g, b)\n    blinkt.set_pixel(3, r, g, b)\n\n    r, g, b = colours[minuteten]\n    blinkt.set_pixel(4, r, g, b)\n    blinkt.set_pixel(5, r, g, b)\n\n    r, g, b = colours[minuteunit]\n    blinkt.set_pixel(6, r, g, b)\n    blinkt.set_pixel(7, r, g, b)\n\n    blinkt.show()\n\n    time.sleep(0.5)\n\n    blinkt.set_pixel(7, 0, 0, 0)\n\n    blinkt.show()\n\n    time.sleep(0.5)\n"
  },
  {
    "path": "examples/rgb.py",
    "content": "#!/usr/bin/env python\n\nimport sys\n\nimport blinkt\n\n\ndef usage():\n    print('Usage: {} <r> <g> <b>'.format(sys.argv[0]))\n    sys.exit(1)\n\n\nif len(sys.argv) != 4:\n    usage()\n\n# Exit if non integer value. int() will raise a ValueError\ntry:\n    r, g, b = [int(x) for x in sys.argv[1:]]\nexcept ValueError:\n    usage()\n\n# Exit if any of r, g, b are greater than 255\nif max(r, g, b) > 255:\n    usage()\n\nprint('Setting Blinkt to {r},{g},{b}'.format(r=r, g=g, b=b))\n\nblinkt.set_clear_on_exit(False)\n\nblinkt.set_all(r, g, b)\n\nblinkt.show()\n"
  },
  {
    "path": "examples/setall.py",
    "content": "#!/usr/bin/env python\n\nimport sys\nfrom sys import argv\nimport blinkt\n\nif len(argv) < 4 or len(argv) > 5:\n    sys.stderr.write(\"Syntax: {0} <red> <green> <blue> [brightness]\\n\".format(argv[0]))\n    exit(1)\n\nred = int(argv[1])\ngreen = int(argv[2])\nblue = int(argv[3])\nbright = float(argv[4]) if len(argv) > 4 else None\n\nblinkt.set_clear_on_exit(False)\nblinkt.set_all(red, green, blue, bright)\nblinkt.show()\n"
  },
  {
    "path": "examples/setup.cfg",
    "content": "[flake8]\nignore=\n    D100  # Ignore various docstring reqs\n    D101\n    D102\n    D103\n    E501  # Ignore long lines"
  },
  {
    "path": "examples/solid_colours.py",
    "content": "#!/usr/bin/env python\n\nimport time\n\nimport blinkt\n\n\nblinkt.set_clear_on_exit()\n\nstep = 0\n\nwhile True:\n    if step == 0:\n        blinkt.set_all(128, 0, 0)\n\n    if step == 1:\n        blinkt.set_all(0, 128, 0)\n\n    if step == 2:\n        blinkt.set_all(0, 0, 128)\n\n    step += 1\n    step %= 3\n    blinkt.show()\n    time.sleep(0.5)\n"
  },
  {
    "path": "examples/solid_colours2.py",
    "content": "#!/usr/bin/env python\n\nimport time\n\nimport blinkt\n\n\nblinkt.set_clear_on_exit()\n\nstep = 0\n\nwhile True:\n    if step == 0:\n        blinkt.set_all(128, 0, 0)\n    elif step == 1:\n        blinkt.set_all(0, 128, 0)\n    elif step == 2:\n        blinkt.set_all(128, 128, 0)\n    elif step == 3:\n        blinkt.set_all(0, 0, 128)\n    elif step == 4:\n        blinkt.set_all(128, 0, 128)\n    elif step == 5:\n        blinkt.set_all(0, 128, 128)\n    elif step == 6:\n        blinkt.set_all(128, 128, 128)\n\n    step += 1\n    step %= 7\n    blinkt.show()\n    time.sleep(0.5)\n"
  },
  {
    "path": "examples/solid_colours3.py",
    "content": "#!/usr/bin/env python\n\nimport time\n\nimport blinkt\n\n\nblinkt.set_clear_on_exit()\n\nstep = 0\n\nwhile True:\n    for i in range(0, 128):\n        j = 128 - i\n        if step == 0:\n            blinkt.set_all(128, j, j)\n        elif step == 1:\n            blinkt.set_all(j, i, 0)\n        elif step == 2:\n            blinkt.set_all(i, 128, 0)\n        elif step == 3:\n            blinkt.set_all(j, j, i)\n        elif step == 4:\n            blinkt.set_all(i, 0, 128)\n        elif step == 5:\n            blinkt.set_all(j, i, 128)\n        elif step == 6:\n            blinkt.set_all(i, 128, 128)\n        blinkt.show()\n        time.sleep(0.01)\n\n    step += 1\n    step %= 7\n    time.sleep(0.5)\n"
  },
  {
    "path": "examples/twitter_monitor.py",
    "content": "#!/usr/bin/env python\n\nimport time\nfrom sys import exit\n\ntry:\n    from tweepy import Stream, OAuthHandler\n    from tweepy.streaming import StreamListener\nexcept ImportError:\n    exit('This script requires the tweepy module\\nInstall with: sudo pip install tweepy')\n\nimport blinkt\n\n\nckey = ''     # Consumer key\ncsecret = ''  # Consumer secret\natoken = ''   # Access token\nasecret = ''  # Access secret\n\n\nclass listener(StreamListener):\n    def on_data(self, data):\n        blink_blinkt()\n        return True\n\n    def on_error(self, status):\n        print(status)\n\n\ndef blink_blinkt():\n    for i in range(3):\n        for j in range(blinkt.NUM_PIXELS):\n            blinkt.set_pixel(j, 255, 0, 0)\n\n        blinkt.show()\n        time.sleep(0.1)\n\n        for j in range(blinkt.NUM_PIXELS):\n            blinkt.set_pixel(j, 0, 0, 0)\n\n        blinkt.show()\n        time.sleep(0.2)\n\n\nauth = OAuthHandler(ckey, csecret)\nauth.set_access_token(atoken, asecret)\ntwitterstream = Stream(auth, listener())\ntwitterstream.filter(track=['#INSERTHASHTAGHERE'])\n"
  },
  {
    "path": "examples/unionjack.py",
    "content": "#!/usr/bin/env python\n\nimport time\nimport blinkt\n\nRED__ = (255, 0, 0)\nWHITE = (127, 127, 127)\nBLUE_ = (0, 0, 255)\n\npattern = [\n    [RED__, BLUE_, WHITE, RED__, RED__, WHITE, BLUE_, RED__],\n    [BLUE_, RED__, WHITE, RED__, RED__, WHITE, RED__, BLUE_],\n    [WHITE, WHITE, WHITE, RED__, RED__, WHITE, WHITE, WHITE],\n    [RED__, RED__, RED__, RED__, RED__, RED__, RED__, RED__],\n    [RED__, RED__, RED__, RED__, RED__, RED__, RED__, RED__],\n    [WHITE, WHITE, WHITE, RED__, RED__, WHITE, WHITE, WHITE],\n    [BLUE_, RED__, WHITE, RED__, RED__, WHITE, RED__, BLUE_],\n    [RED__, BLUE_, WHITE, RED__, RED__, WHITE, BLUE_, RED__],\n]\n\nblinkt.set_clear_on_exit()\nblinkt.set_brightness(0.1)\n\nwhile 1:\n    for line in pattern:\n        for i, pixel in enumerate(line):\n            r, g, b = pixel\n            blinkt.set_pixel(i, r, g, b)\n        blinkt.show()\n        time.sleep(0.25)\n"
  },
  {
    "path": "examples/white.py",
    "content": "#!/usr/bin/env python\n\nimport blinkt\n\nblinkt.set_clear_on_exit(False)\nblinkt.set_all(255, 255, 255, 1.0)\nblinkt.show()\n"
  },
  {
    "path": "library/.coveragerc",
    "content": "[run]\nsource = blinkt\nomit =\n    .tox/*\n"
  },
  {
    "path": "library/CHANGELOG.txt",
    "content": "0.1.2\n-----\n\n* BugFix: Added sleep to data output, see: https://github.com/pimoroni/blinkt/issues/62\n\n0.1.1\n-----\n\n* New: Added `get_pixel` to return colour and brightness of a single pixel\n\n0.1.0\n-----\n\n* Removed try/except from RPi.GPIO import, output was misleading at best\n* Reverted default behaviour of clear on exit\n\n0.0.9\n-----\n\n* Added set_all method to set all pixels\n* Changed default behaviour of clear on exit to reduce module side-effects\n* Move GPIO initialisation to show() to reduce module side-effects\n\n0.0.8\n-----\n\n* Tweaked some methods to show intent as implementation detail only\n* Added docstrings detailing public methods\n\n0.0.7\n-----\n\n* Fixed bug with APA102 pixels that have a small, black die (vs the larger, paler one)\n\n0.0.6\n-----\n\n* set_clear_on_exit now method\n\n0.0.5\n-----\n\n* Range clamping and coercion to integers\n\n0.0.4\n-----\n\n* Various bug fixes\n\n0.0.3\n-----\n\n* Switch to Python\n\n0.0.2\n-----\n\n* Bug fixes for C Library\n\n0.0.1\n-----\n\n* Original C Library\n\n"
  },
  {
    "path": "library/LICENSE.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2016 Pimoroni Ltd\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\nall copies 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\nTHE SOFTWARE.\n"
  },
  {
    "path": "library/MANIFEST.in",
    "content": "include CHANGELOG.txt\ninclude LICENSE.txt\ninclude README.rst\ninclude setup.py\ninclude blinkt.py\n"
  },
  {
    "path": "library/Makefile",
    "content": "all:\n\tgcc -Wall -DTEST lib/blinkt.c -l bcm2835 -o blinkt\n\ndevel:\n\t-rm -r build\n\tpython setup.py build\n\tsudo python setup.py develop\n"
  },
  {
    "path": "library/README.md",
    "content": "#Blinkt Pure Python Library\n"
  },
  {
    "path": "library/README.rst",
    "content": ".. figure:: blinkt-logo.png\n   :alt: Blinkt!\n\n   Blinkt!\n\n|Build Status| |Coverage Status| |PyPi Package| |Python Versions|\n\nhttps://shop.pimoroni.com/products/blinkt\n\nEight super-bright RGB LED indicators, ideal for adding visual\nnotifications to your Raspberry Pi on their own or on a pHAT stacking\nheader.\n\nInstalling\n----------\n\nFull install (recommended):\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe've created an easy installation script that will install all\npre-requisites and get your Blinkt! up and running with minimal efforts.\nTo run it, fire up Terminal which you'll find in Menu -> Accessories ->\nTerminal on your Raspberry Pi desktop, as illustrated below:\n\n.. figure:: http://get.pimoroni.com/resources/github-repo-terminal.png\n   :alt: Finding the terminal\n\n   Finding the terminal\n\nIn the new terminal window type the command exactly as it appears below\n(check for typos) and follow the on-screen instructions:\n\n.. code:: bash\n\n    curl https://get.pimoroni.com/blinkt | bash\n\nAlternatively, on Raspbian, you can download the ``pimoroni-dashboard``\nand install your product by browsing to the relevant entry:\n\n.. code:: bash\n\n    sudo apt-get install pimoroni\n\n(you will find the Dashboard under 'Accessories' too, in the Pi menu -\nor just run ``pimoroni-dashboard`` at the command line)\n\nIf you choose to download examples you'll find them in\n``/home/pi/Pimoroni/blinkt/``.\n\nManual install:\n~~~~~~~~~~~~~~~\n\nLibrary install for Python 3:\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\non Raspbian:\n\n.. code:: bash\n\n    sudo apt-get install python3-blinkt\n\nother environments:\n\n.. code:: bash\n\n    sudo pip3 install blinkt\n\nLibrary install for Python 2:\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\non Raspbian:\n\n.. code:: bash\n\n    sudo apt-get install python-blinkt\n\nother environments:\n\n.. code:: bash\n\n    sudo pip2 install blinkt\n\nDevelopment:\n~~~~~~~~~~~~\n\nIf you want to contribute, or like living on the edge of your seat by\nhaving the latest code, you should clone this repository, ``cd`` to the\nlibrary directory, and run:\n\n.. code:: bash\n\n    sudo python3 setup.py install\n\n(or ``sudo python setup.py install`` whichever your primary Python\nenvironment may be)\n\nDocumentation & Support\n-----------------------\n\n-  Guides and tutorials - https://learn.pimoroni.com/blinkt\n-  Function reference - http://docs.pimoroni.com/blinkt/\n-  GPIO Pinout - https://pinout.xyz/pinout/blinkt\n-  Get help - http://forums.pimoroni.com/c/support\n\nUnofficial / Third-party libraries\n----------------------------------\n\n-  Golang library & examples by `Alex\n   Ellis <https://www.alexellis.io>`__ -\n   https://github.com/alexellis/blinkt\\_go\\_examples\n-  Java library by Jim Darby - https://github.com/hackerjimbo/PiJava\n\n.. |Build Status| image:: https://travis-ci.com/pimoroni/blinkt.svg?branch=master\n   :target: https://travis-ci.com/pimoroni/blinkt\n.. |Coverage Status| image:: https://coveralls.io/repos/github/pimoroni/blinkt/badge.svg?branch=master\n   :target: https://coveralls.io/github/pimoroni/blinkt?branch=master\n.. |PyPi Package| image:: https://img.shields.io/pypi/v/blinkt.svg\n   :target: https://pypi.python.org/pypi/blinkt\n.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/blinkt.svg\n   :target: https://pypi.python.org/pypi/blinkt\n"
  },
  {
    "path": "library/blinkt.py",
    "content": "\"\"\"Library for the Pimoroni Blinkt! - 8-pixel APA102 LED display.\"\"\"\nimport atexit\nimport time\n\nimport RPi.GPIO as GPIO\n\n\n__version__ = '0.1.2'\n\nDAT = 23\nCLK = 24\nNUM_PIXELS = 8\nBRIGHTNESS = 7\n\npixels = [[0, 0, 0, BRIGHTNESS]] * NUM_PIXELS\n\nsleep_time = 0\n\n_gpio_setup = False\n_clear_on_exit = True\n\n\ndef _exit():\n    if _clear_on_exit:\n        clear()\n        show()\n    GPIO.cleanup()\n\n\ndef set_brightness(brightness):\n    \"\"\"Set the brightness of all pixels.\n\n    :param brightness: Brightness: 0.0 to 1.0\n\n    \"\"\"\n    if brightness < 0 or brightness > 1:\n        raise ValueError('Brightness should be between 0.0 and 1.0')\n\n    for x in range(NUM_PIXELS):\n        pixels[x][3] = int(31.0 * brightness) & 0b11111\n\n\ndef clear():\n    \"\"\"Clear the pixel buffer.\"\"\"\n    for x in range(NUM_PIXELS):\n        pixels[x][0:3] = [0, 0, 0]\n\n\ndef _write_byte(byte):\n    for x in range(8):\n        GPIO.output(DAT, byte & 0b10000000)\n        GPIO.output(CLK, 1)\n        time.sleep(sleep_time)\n        byte <<= 1\n        GPIO.output(CLK, 0)\n        time.sleep(sleep_time)\n\n\n# Emit exactly enough clock pulses to latch the small dark die APA102s which are weird\n# for some reason it takes 36 clocks, the other IC takes just 4 (number of pixels/2)\ndef _eof():\n    GPIO.output(DAT, 0)\n    for x in range(36):\n        GPIO.output(CLK, 1)\n        time.sleep(sleep_time)\n        GPIO.output(CLK, 0)\n        time.sleep(sleep_time)\n\n\ndef _sof():\n    GPIO.output(DAT, 0)\n    for x in range(32):\n        GPIO.output(CLK, 1)\n        time.sleep(sleep_time)\n        GPIO.output(CLK, 0)\n        time.sleep(sleep_time)\n\n\ndef show():\n    \"\"\"Output the buffer to Blinkt!.\"\"\"\n    global _gpio_setup\n\n    if not _gpio_setup:\n        GPIO.setmode(GPIO.BCM)\n        GPIO.setwarnings(False)\n        GPIO.setup(DAT, GPIO.OUT)\n        GPIO.setup(CLK, GPIO.OUT)\n        atexit.register(_exit)\n        _gpio_setup = True\n\n    _sof()\n\n    for pixel in pixels:\n        r, g, b, brightness = pixel\n        _write_byte(0b11100000 | brightness)\n        _write_byte(b)\n        _write_byte(g)\n        _write_byte(r)\n\n    _eof()\n\n\ndef set_all(r, g, b, brightness=None):\n    \"\"\"Set the RGB value and optionally brightness of all pixels.\n\n    If you don't supply a brightness value, the last value set for each pixel be kept.\n\n    :param r: Amount of red: 0 to 255\n    :param g: Amount of green: 0 to 255\n    :param b: Amount of blue: 0 to 255\n    :param brightness: Brightness: 0.0 to 1.0 (default around 0.2)\n\n    \"\"\"\n    for x in range(NUM_PIXELS):\n        set_pixel(x, r, g, b, brightness)\n\n\ndef get_pixel(x):\n    \"\"\"Get the RGB and brightness value of a specific pixel.\n\n    :param x: The horizontal position of the pixel: 0 to 7\n\n    \"\"\"\n    r, g, b, brightness = pixels[x]\n    brightness /= 31.0\n\n    return r, g, b, round(brightness, 3)\n\n\ndef set_pixel(x, r, g, b, brightness=None):\n    \"\"\"Set the RGB value, and optionally brightness, of a single pixel.\n\n    If you don't supply a brightness value, the last value will be kept.\n\n    :param x: The horizontal position of the pixel: 0 to 7\n    :param r: Amount of red: 0 to 255\n    :param g: Amount of green: 0 to 255\n    :param b: Amount of blue: 0 to 255\n    :param brightness: Brightness: 0.0 to 1.0 (default around 0.2)\n\n    \"\"\"\n    if brightness is None:\n        brightness = pixels[x][3]\n    else:\n        brightness = int(31.0 * brightness) & 0b11111\n\n    pixels[x] = [int(r) & 0xff, int(g) & 0xff, int(b) & 0xff, brightness]\n\n\ndef set_clear_on_exit(value=True):\n    \"\"\"Set whether Blinkt! should be cleared upon exit.\n\n    By default Blinkt! will turn off the pixels on exit, but calling::\n\n        blinkt.set_clear_on_exit(False)\n\n    Will ensure that it does not.\n\n    :param value: True or False (default True)\n\n    \"\"\"\n    global _clear_on_exit\n    _clear_on_exit = value\n"
  },
  {
    "path": "library/setup.cfg",
    "content": "[flake8]\nexclude =\n\ttest.py\n\t.tox,\n\t.eggs,\n\t.git,\n\t__pycache__,\n\tbuild,\n\tdist\nignore =\n\tE501\n"
  },
  {
    "path": "library/setup.py",
    "content": "#!/usr/bin/env python\n\n\"\"\"\nCopyright (c) 2016 Pimoroni.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, 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\"\"\"\n\ntry:\n    from setuptools import setup\nexcept ImportError:\n    from distutils.core import setup\n\nclassifiers = ['Development Status :: 5 - Production/Stable',\n               'Operating System :: POSIX :: Linux',\n               'License :: OSI Approved :: MIT License',\n               'Intended Audience :: Developers',\n               'Programming Language :: Python :: 2.6',\n               'Programming Language :: Python :: 2.7',\n               'Programming Language :: Python :: 3',\n               'Topic :: Software Development',\n               'Topic :: System :: Hardware']\n\nsetup(\n    name='blinkt',\n    version='0.1.2',\n    author='Philip Howard',\n    author_email='phil@pimoroni.com',\n    description=\"\"\"Python library for driving Pimoroni Blinkt!\"\"\",\n    long_description=open('README.rst').read() + '\\n' + open('CHANGELOG.txt').read(),\n    license='MIT',\n    keywords='Raspberry Pi LED',\n    url='http://www.pimoroni.com',\n    classifiers=classifiers,\n    py_modules=['blinkt'],\n    install_requires=['RPi.GPIO']\n)\n"
  },
  {
    "path": "library/tests/test_setup.py",
    "content": "\"\"\"Test Blinkt! basis initialisation.\"\"\"\nimport mock\nimport sys\nfrom tools import GPIO\n\n\ndef test_setup():\n    \"\"\"Test init succeeds and GPIO pins are setup.\"\"\"\n    gpio = GPIO()\n    sys.modules['RPi'] = mock.Mock()\n    sys.modules['RPi'].GPIO = gpio\n    sys.modules['RPi.GPIO'] = gpio\n    import blinkt\n    blinkt.show()\n\n    assert gpio.pin_modes[blinkt.DAT] == gpio.OUT\n    assert gpio.pin_modes[blinkt.CLK] == gpio.OUT\n"
  },
  {
    "path": "library/tests/tools.py",
    "content": "# noqa D100\nclass GPIO:\n    \"\"\"Mock RPi.GPIO class.\n\n    Stubs out enough of RPi.GPIO to validate pin states are set correctly.\n\n    \"\"\"\n\n    BCM = 1\n    OUT = 1\n    IN = 1\n\n    def __init__(self):              # noqa D100\n        self.pin_modes = {}\n        self.pin_states = {}\n\n    def output(self, pin, value):    # noqa D100\n        self.pin_states[pin] = value\n\n    def setmode(self, mode):         # noqa D100\n        pass\n\n    def setwarnings(self, mode):     # noqa D100\n        pass\n\n    def setup(self, pin, mode):      # noqa D100\n        self.pin_modes[pin] = mode\n\n    def cleanup(self):               # noqa D100\n        pass\n"
  },
  {
    "path": "library/tox.ini",
    "content": "[tox]\nenvlist = py{27,35,37,39},qa\nskip_missing_interpreters = True\n\n[testenv]\ncommands =\n\tpython setup.py install\n\tcoverage run -m py.test -v -r wsx\n\tcoverage report\ndeps =\n\tmock\n\tpytest>=3.1\n\tpytest-cov\n \n[testenv:qa]\ncommands =\n\tflake8\n\tflake8 ../examples/\n\trstcheck README.rst\ndeps =\n\tflake8\n\tflake8-docstrings\n\tflake8-quotes\n\trstcheck\n"
  },
  {
    "path": "library_c/CHANGELOG.txt",
    "content": ""
  },
  {
    "path": "library_c/MANIFEST.in",
    "content": "include README.md\ninclude README.txt\ninclude CHANGELOG.txt\ninclude setup.py\ninclude blinkt_wrap.c \ninclude blinkt.py\ninclude lib/*\n"
  },
  {
    "path": "library_c/Makefile",
    "content": "all:\n\tgcc -Wall -DTEST lib/blinkt.c -l bcm2835 -o blinkt\n\ndevel:\n\t-rm -r build\n\tpython setup.py build\n\tsudo python setup.py develop\n"
  },
  {
    "path": "library_c/README.md",
    "content": ""
  },
  {
    "path": "library_c/README.txt",
    "content": ""
  },
  {
    "path": "library_c/blinkt.i",
    "content": "%module blinkt\n\n%include \"stdint.i\"\n%include \"carrays.i\"\n\n%{\n#include \"lib/blinkt.h\"\n%}\n\n%include \"lib/blinkt.h\"\n\n%pythoncode %{\nimport atexit\n\ndef clean_exit():\n    stop()\n\nif start() > 0:\n    raise ImportError(\"Blinkt requires root.\")\n\natexit.register(clean_exit)\n%}\n"
  },
  {
    "path": "library_c/blinkt.py",
    "content": "# This file was automatically generated by SWIG (http://www.swig.org).\n# Version 3.0.2\n#\n# Do not make changes to this file unless you know what you are doing--modify\n# the SWIG interface file instead.\n\n\n\n\n\nfrom sys import version_info\nif version_info >= (2,6,0):\n    def swig_import_helper():\n        from os.path import dirname\n        import imp\n        fp = None\n        try:\n            fp, pathname, description = imp.find_module('_blinkt', [dirname(__file__)])\n        except ImportError:\n            import _blinkt\n            return _blinkt\n        if fp is not None:\n            try:\n                _mod = imp.load_module('_blinkt', fp, pathname, description)\n            finally:\n                fp.close()\n            return _mod\n    _blinkt = swig_import_helper()\n    del swig_import_helper\nelse:\n    import _blinkt\ndel version_info\ntry:\n    _swig_property = property\nexcept NameError:\n    pass # Python < 2.2 doesn't have 'property'.\ndef _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n    if (name == \"thisown\"): return self.this.own(value)\n    if (name == \"this\"):\n        if type(value).__name__ == 'SwigPyObject':\n            self.__dict__[name] = value\n            return\n    method = class_type.__swig_setmethods__.get(name,None)\n    if method: return method(self,value)\n    if (not static):\n        self.__dict__[name] = value\n    else:\n        raise AttributeError(\"You cannot add attributes to %s\" % self)\n\ndef _swig_setattr(self,class_type,name,value):\n    return _swig_setattr_nondynamic(self,class_type,name,value,0)\n\ndef _swig_getattr(self,class_type,name):\n    if (name == \"thisown\"): return self.this.own()\n    method = class_type.__swig_getmethods__.get(name,None)\n    if method: return method(self)\n    raise AttributeError(name)\n\ndef _swig_repr(self):\n    try: strthis = \"proxy of \" + self.this.__repr__()\n    except: strthis = \"\"\n    return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\ntry:\n    _object = object\n    _newclass = 1\nexcept AttributeError:\n    class _object : pass\n    _newclass = 0\n\n\n\ndef clear():\n  return _blinkt.clear()\nclear = _blinkt.clear\n\ndef set_pixel_uint32(*args):\n  return _blinkt.set_pixel_uint32(*args)\nset_pixel_uint32 = _blinkt.set_pixel_uint32\n\ndef set_pixel(*args):\n  return _blinkt.set_pixel(*args)\nset_pixel = _blinkt.set_pixel\n\ndef set_pixel_brightness(*args):\n  return _blinkt.set_pixel_brightness(*args)\nset_pixel_brightness = _blinkt.set_pixel_brightness\n\ndef rgbb(*args):\n  return _blinkt.rgbb(*args)\nrgbb = _blinkt.rgbb\n\ndef rgb(*args):\n  return _blinkt.rgb(*args)\nrgb = _blinkt.rgb\n\ndef stop():\n  return _blinkt.stop()\nstop = _blinkt.stop\n\ndef start():\n  return _blinkt.start()\nstart = _blinkt.start\n\ndef show():\n  return _blinkt.show()\nshow = _blinkt.show\nimport atexit\n\ndef clean_exit():\n    stop()\n\nif start() > 0:\n    raise ImportError(\"Blinkt requires root.\")\n\natexit.register(clean_exit)\n\n# This file is compatible with both classic and new-style classes.\n\n\n"
  },
  {
    "path": "library_c/blinkt_wrap.c",
    "content": "/* ----------------------------------------------------------------------------\n * This file was automatically generated by SWIG (http://www.swig.org).\n * Version 3.0.2\n *\n * This file is not intended to be easily readable and contains a number of\n * coding conventions designed to improve portability and efficiency. Do not make\n * changes to this file unless you know what you are doing--modify the SWIG\n * interface file instead.\n * ----------------------------------------------------------------------------- */\n\n#define SWIGPYTHON\n#define SWIG_PYTHON_DIRECTOR_NO_VTABLE\n\n/* -----------------------------------------------------------------------------\n *  This section contains generic SWIG labels for method/variable\n *  declarations/attributes, and other compiler dependent labels.\n * ----------------------------------------------------------------------------- */\n\n/* template workaround for compilers that cannot correctly implement the C++ standard */\n#ifndef SWIGTEMPLATEDISAMBIGUATOR\n# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)\n#  define SWIGTEMPLATEDISAMBIGUATOR template\n# elif defined(__HP_aCC)\n/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */\n/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */\n#  define SWIGTEMPLATEDISAMBIGUATOR template\n# else\n#  define SWIGTEMPLATEDISAMBIGUATOR\n# endif\n#endif\n\n/* inline attribute */\n#ifndef SWIGINLINE\n# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))\n#   define SWIGINLINE inline\n# else\n#   define SWIGINLINE\n# endif\n#endif\n\n/* attribute recognised by some compilers to avoid 'unused' warnings */\n#ifndef SWIGUNUSED\n# if defined(__GNUC__)\n#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))\n#     define SWIGUNUSED __attribute__ ((__unused__))\n#   else\n#     define SWIGUNUSED\n#   endif\n# elif defined(__ICC)\n#   define SWIGUNUSED __attribute__ ((__unused__))\n# else\n#   define SWIGUNUSED\n# endif\n#endif\n\n#ifndef SWIG_MSC_UNSUPPRESS_4505\n# if defined(_MSC_VER)\n#   pragma warning(disable : 4505) /* unreferenced local function has been removed */\n# endif\n#endif\n\n#ifndef SWIGUNUSEDPARM\n# ifdef __cplusplus\n#   define SWIGUNUSEDPARM(p)\n# else\n#   define SWIGUNUSEDPARM(p) p SWIGUNUSED\n# endif\n#endif\n\n/* internal SWIG method */\n#ifndef SWIGINTERN\n# define SWIGINTERN static SWIGUNUSED\n#endif\n\n/* internal inline SWIG method */\n#ifndef SWIGINTERNINLINE\n# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE\n#endif\n\n/* exporting methods */\n#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)\n#  ifndef GCC_HASCLASSVISIBILITY\n#    define GCC_HASCLASSVISIBILITY\n#  endif\n#endif\n\n#ifndef SWIGEXPORT\n# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n#   if defined(STATIC_LINKED)\n#     define SWIGEXPORT\n#   else\n#     define SWIGEXPORT __declspec(dllexport)\n#   endif\n# else\n#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)\n#     define SWIGEXPORT __attribute__ ((visibility(\"default\")))\n#   else\n#     define SWIGEXPORT\n#   endif\n# endif\n#endif\n\n/* calling conventions for Windows */\n#ifndef SWIGSTDCALL\n# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n#   define SWIGSTDCALL __stdcall\n# else\n#   define SWIGSTDCALL\n# endif\n#endif\n\n/* Deal with Microsoft's attempt at deprecating C standard runtime functions */\n#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)\n# define _CRT_SECURE_NO_DEPRECATE\n#endif\n\n/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */\n#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)\n# define _SCL_SECURE_NO_DEPRECATE\n#endif\n\n\n\n#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)\n/* Use debug wrappers with the Python release dll */\n# undef _DEBUG\n# include <Python.h>\n# define _DEBUG\n#else\n# include <Python.h>\n#endif\n\n/* -----------------------------------------------------------------------------\n * swigrun.swg\n *\n * This file contains generic C API SWIG runtime support for pointer\n * type checking.\n * ----------------------------------------------------------------------------- */\n\n/* This should only be incremented when either the layout of swig_type_info changes,\n   or for whatever reason, the runtime changes incompatibly */\n#define SWIG_RUNTIME_VERSION \"4\"\n\n/* define SWIG_TYPE_TABLE_NAME as \"SWIG_TYPE_TABLE\" */\n#ifdef SWIG_TYPE_TABLE\n# define SWIG_QUOTE_STRING(x) #x\n# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)\n# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)\n#else\n# define SWIG_TYPE_TABLE_NAME\n#endif\n\n/*\n  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for\n  creating a static or dynamic library from the SWIG runtime code.\n  In 99.9% of the cases, SWIG just needs to declare them as 'static'.\n\n  But only do this if strictly necessary, ie, if you have problems\n  with your compiler or suchlike.\n*/\n\n#ifndef SWIGRUNTIME\n# define SWIGRUNTIME SWIGINTERN\n#endif\n\n#ifndef SWIGRUNTIMEINLINE\n# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE\n#endif\n\n/*  Generic buffer size */\n#ifndef SWIG_BUFFER_SIZE\n# define SWIG_BUFFER_SIZE 1024\n#endif\n\n/* Flags for pointer conversions */\n#define SWIG_POINTER_DISOWN        0x1\n#define SWIG_CAST_NEW_MEMORY       0x2\n\n/* Flags for new pointer objects */\n#define SWIG_POINTER_OWN           0x1\n\n\n/*\n   Flags/methods for returning states.\n\n   The SWIG conversion methods, as ConvertPtr, return an integer\n   that tells if the conversion was successful or not. And if not,\n   an error code can be returned (see swigerrors.swg for the codes).\n\n   Use the following macros/flags to set or process the returning\n   states.\n\n   In old versions of SWIG, code such as the following was usually written:\n\n     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {\n       // success code\n     } else {\n       //fail code\n     }\n\n   Now you can be more explicit:\n\n    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);\n    if (SWIG_IsOK(res)) {\n      // success code\n    } else {\n      // fail code\n    }\n\n   which is the same really, but now you can also do\n\n    Type *ptr;\n    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);\n    if (SWIG_IsOK(res)) {\n      // success code\n      if (SWIG_IsNewObj(res) {\n        ...\n\tdelete *ptr;\n      } else {\n        ...\n      }\n    } else {\n      // fail code\n    }\n\n   I.e., now SWIG_ConvertPtr can return new objects and you can\n   identify the case and take care of the deallocation. Of course that\n   also requires SWIG_ConvertPtr to return new result values, such as\n\n      int SWIG_ConvertPtr(obj, ptr,...) {\n        if (<obj is ok>) {\n          if (<need new object>) {\n            *ptr = <ptr to new allocated object>;\n            return SWIG_NEWOBJ;\n          } else {\n            *ptr = <ptr to old object>;\n            return SWIG_OLDOBJ;\n          }\n        } else {\n          return SWIG_BADOBJ;\n        }\n      }\n\n   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be\n   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the\n   SWIG errors code.\n\n   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code\n   allows to return the 'cast rank', for example, if you have this\n\n       int food(double)\n       int fooi(int);\n\n   and you call\n\n      food(1)   // cast rank '1'  (1 -> 1.0)\n      fooi(1)   // cast rank '0'\n\n   just use the SWIG_AddCast()/SWIG_CheckState()\n*/\n\n#define SWIG_OK                    (0)\n#define SWIG_ERROR                 (-1)\n#define SWIG_IsOK(r)               (r >= 0)\n#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)\n\n/* The CastRankLimit says how many bits are used for the cast rank */\n#define SWIG_CASTRANKLIMIT         (1 << 8)\n/* The NewMask denotes the object was created (using new/malloc) */\n#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)\n/* The TmpMask is for in/out typemaps that use temporal objects */\n#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)\n/* Simple returning values */\n#define SWIG_BADOBJ                (SWIG_ERROR)\n#define SWIG_OLDOBJ                (SWIG_OK)\n#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)\n#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)\n/* Check, add and del mask methods */\n#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)\n#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)\n#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))\n#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)\n#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)\n#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))\n\n/* Cast-Rank Mode */\n#if defined(SWIG_CASTRANK_MODE)\n#  ifndef SWIG_TypeRank\n#    define SWIG_TypeRank             unsigned long\n#  endif\n#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */\n#    define SWIG_MAXCASTRANK          (2)\n#  endif\n#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)\n#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)\nSWIGINTERNINLINE int SWIG_AddCast(int r) {\n  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;\n}\nSWIGINTERNINLINE int SWIG_CheckState(int r) {\n  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;\n}\n#else /* no cast-rank mode */\n#  define SWIG_AddCast(r) (r)\n#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)\n#endif\n\n\n#include <string.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef void *(*swig_converter_func)(void *, int *);\ntypedef struct swig_type_info *(*swig_dycast_func)(void **);\n\n/* Structure to store information on one type */\ntypedef struct swig_type_info {\n  const char             *name;\t\t\t/* mangled name of this type */\n  const char             *str;\t\t\t/* human readable name of this type */\n  swig_dycast_func        dcast;\t\t/* dynamic cast function down a hierarchy */\n  struct swig_cast_info  *cast;\t\t\t/* linked list of types that can cast into this type */\n  void                   *clientdata;\t\t/* language specific type data */\n  int                    owndata;\t\t/* flag if the structure owns the clientdata */\n} swig_type_info;\n\n/* Structure to store a type and conversion function used for casting */\ntypedef struct swig_cast_info {\n  swig_type_info         *type;\t\t\t/* pointer to type that is equivalent to this type */\n  swig_converter_func     converter;\t\t/* function to cast the void pointers */\n  struct swig_cast_info  *next;\t\t\t/* pointer to next cast in linked list */\n  struct swig_cast_info  *prev;\t\t\t/* pointer to the previous cast */\n} swig_cast_info;\n\n/* Structure used to store module information\n * Each module generates one structure like this, and the runtime collects\n * all of these structures and stores them in a circularly linked list.*/\ntypedef struct swig_module_info {\n  swig_type_info         **types;\t\t/* Array of pointers to swig_type_info structures that are in this module */\n  size_t                 size;\t\t        /* Number of types in this module */\n  struct swig_module_info *next;\t\t/* Pointer to next element in circularly linked list */\n  swig_type_info         **type_initial;\t/* Array of initially generated type structures */\n  swig_cast_info         **cast_initial;\t/* Array of initially generated casting structures */\n  void                    *clientdata;\t\t/* Language specific module data */\n} swig_module_info;\n\n/*\n  Compare two type names skipping the space characters, therefore\n  \"char*\" == \"char *\" and \"Class<int>\" == \"Class<int >\", etc.\n\n  Return 0 when the two name types are equivalent, as in\n  strncmp, but skipping ' '.\n*/\nSWIGRUNTIME int\nSWIG_TypeNameComp(const char *f1, const char *l1,\n\t\t  const char *f2, const char *l2) {\n  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {\n    while ((*f1 == ' ') && (f1 != l1)) ++f1;\n    while ((*f2 == ' ') && (f2 != l2)) ++f2;\n    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;\n  }\n  return (int)((l1 - f1) - (l2 - f2));\n}\n\n/*\n  Check type equivalence in a name list like <name1>|<name2>|...\n  Return 0 if equal, -1 if nb < tb, 1 if nb > tb\n*/\nSWIGRUNTIME int\nSWIG_TypeCmp(const char *nb, const char *tb) {\n  int equiv = 1;\n  const char* te = tb + strlen(tb);\n  const char* ne = nb;\n  while (equiv != 0 && *ne) {\n    for (nb = ne; *ne; ++ne) {\n      if (*ne == '|') break;\n    }\n    equiv = SWIG_TypeNameComp(nb, ne, tb, te);\n    if (*ne) ++ne;\n  }\n  return equiv;\n}\n\n/*\n  Check type equivalence in a name list like <name1>|<name2>|...\n  Return 0 if not equal, 1 if equal\n*/\nSWIGRUNTIME int\nSWIG_TypeEquiv(const char *nb, const char *tb) {\n  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;\n}\n\n/*\n  Check the typename\n*/\nSWIGRUNTIME swig_cast_info *\nSWIG_TypeCheck(const char *c, swig_type_info *ty) {\n  if (ty) {\n    swig_cast_info *iter = ty->cast;\n    while (iter) {\n      if (strcmp(iter->type->name, c) == 0) {\n        if (iter == ty->cast)\n          return iter;\n        /* Move iter to the top of the linked list */\n        iter->prev->next = iter->next;\n        if (iter->next)\n          iter->next->prev = iter->prev;\n        iter->next = ty->cast;\n        iter->prev = 0;\n        if (ty->cast) ty->cast->prev = iter;\n        ty->cast = iter;\n        return iter;\n      }\n      iter = iter->next;\n    }\n  }\n  return 0;\n}\n\n/*\n  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison\n*/\nSWIGRUNTIME swig_cast_info *\nSWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {\n  if (ty) {\n    swig_cast_info *iter = ty->cast;\n    while (iter) {\n      if (iter->type == from) {\n        if (iter == ty->cast)\n          return iter;\n        /* Move iter to the top of the linked list */\n        iter->prev->next = iter->next;\n        if (iter->next)\n          iter->next->prev = iter->prev;\n        iter->next = ty->cast;\n        iter->prev = 0;\n        if (ty->cast) ty->cast->prev = iter;\n        ty->cast = iter;\n        return iter;\n      }\n      iter = iter->next;\n    }\n  }\n  return 0;\n}\n\n/*\n  Cast a pointer up an inheritance hierarchy\n*/\nSWIGRUNTIMEINLINE void *\nSWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {\n  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);\n}\n\n/*\n   Dynamic pointer casting. Down an inheritance hierarchy\n*/\nSWIGRUNTIME swig_type_info *\nSWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {\n  swig_type_info *lastty = ty;\n  if (!ty || !ty->dcast) return ty;\n  while (ty && (ty->dcast)) {\n    ty = (*ty->dcast)(ptr);\n    if (ty) lastty = ty;\n  }\n  return lastty;\n}\n\n/*\n  Return the name associated with this type\n*/\nSWIGRUNTIMEINLINE const char *\nSWIG_TypeName(const swig_type_info *ty) {\n  return ty->name;\n}\n\n/*\n  Return the pretty name associated with this type,\n  that is an unmangled type name in a form presentable to the user.\n*/\nSWIGRUNTIME const char *\nSWIG_TypePrettyName(const swig_type_info *type) {\n  /* The \"str\" field contains the equivalent pretty names of the\n     type, separated by vertical-bar characters.  We choose\n     to print the last name, as it is often (?) the most\n     specific. */\n  if (!type) return NULL;\n  if (type->str != NULL) {\n    const char *last_name = type->str;\n    const char *s;\n    for (s = type->str; *s; s++)\n      if (*s == '|') last_name = s+1;\n    return last_name;\n  }\n  else\n    return type->name;\n}\n\n/*\n   Set the clientdata field for a type\n*/\nSWIGRUNTIME void\nSWIG_TypeClientData(swig_type_info *ti, void *clientdata) {\n  swig_cast_info *cast = ti->cast;\n  /* if (ti->clientdata == clientdata) return; */\n  ti->clientdata = clientdata;\n\n  while (cast) {\n    if (!cast->converter) {\n      swig_type_info *tc = cast->type;\n      if (!tc->clientdata) {\n\tSWIG_TypeClientData(tc, clientdata);\n      }\n    }\n    cast = cast->next;\n  }\n}\nSWIGRUNTIME void\nSWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {\n  SWIG_TypeClientData(ti, clientdata);\n  ti->owndata = 1;\n}\n\n/*\n  Search for a swig_type_info structure only by mangled name\n  Search is a O(log #types)\n\n  We start searching at module start, and finish searching when start == end.\n  Note: if start == end at the beginning of the function, we go all the way around\n  the circular list.\n*/\nSWIGRUNTIME swig_type_info *\nSWIG_MangledTypeQueryModule(swig_module_info *start,\n                            swig_module_info *end,\n\t\t            const char *name) {\n  swig_module_info *iter = start;\n  do {\n    if (iter->size) {\n      size_t l = 0;\n      size_t r = iter->size - 1;\n      do {\n\t/* since l+r >= 0, we can (>> 1) instead (/ 2) */\n\tsize_t i = (l + r) >> 1;\n\tconst char *iname = iter->types[i]->name;\n\tif (iname) {\n\t  int compare = strcmp(name, iname);\n\t  if (compare == 0) {\n\t    return iter->types[i];\n\t  } else if (compare < 0) {\n\t    if (i) {\n\t      r = i - 1;\n\t    } else {\n\t      break;\n\t    }\n\t  } else if (compare > 0) {\n\t    l = i + 1;\n\t  }\n\t} else {\n\t  break; /* should never happen */\n\t}\n      } while (l <= r);\n    }\n    iter = iter->next;\n  } while (iter != end);\n  return 0;\n}\n\n/*\n  Search for a swig_type_info structure for either a mangled name or a human readable name.\n  It first searches the mangled names of the types, which is a O(log #types)\n  If a type is not found it then searches the human readable names, which is O(#types).\n\n  We start searching at module start, and finish searching when start == end.\n  Note: if start == end at the beginning of the function, we go all the way around\n  the circular list.\n*/\nSWIGRUNTIME swig_type_info *\nSWIG_TypeQueryModule(swig_module_info *start,\n                     swig_module_info *end,\n\t\t     const char *name) {\n  /* STEP 1: Search the name field using binary search */\n  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);\n  if (ret) {\n    return ret;\n  } else {\n    /* STEP 2: If the type hasn't been found, do a complete search\n       of the str field (the human readable name) */\n    swig_module_info *iter = start;\n    do {\n      size_t i = 0;\n      for (; i < iter->size; ++i) {\n\tif (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))\n\t  return iter->types[i];\n      }\n      iter = iter->next;\n    } while (iter != end);\n  }\n\n  /* neither found a match */\n  return 0;\n}\n\n/*\n   Pack binary data into a string\n*/\nSWIGRUNTIME char *\nSWIG_PackData(char *c, void *ptr, size_t sz) {\n  static const char hex[17] = \"0123456789abcdef\";\n  const unsigned char *u = (unsigned char *) ptr;\n  const unsigned char *eu =  u + sz;\n  for (; u != eu; ++u) {\n    unsigned char uu = *u;\n    *(c++) = hex[(uu & 0xf0) >> 4];\n    *(c++) = hex[uu & 0xf];\n  }\n  return c;\n}\n\n/*\n   Unpack binary data from a string\n*/\nSWIGRUNTIME const char *\nSWIG_UnpackData(const char *c, void *ptr, size_t sz) {\n  unsigned char *u = (unsigned char *) ptr;\n  const unsigned char *eu = u + sz;\n  for (; u != eu; ++u) {\n    char d = *(c++);\n    unsigned char uu;\n    if ((d >= '0') && (d <= '9'))\n      uu = ((d - '0') << 4);\n    else if ((d >= 'a') && (d <= 'f'))\n      uu = ((d - ('a'-10)) << 4);\n    else\n      return (char *) 0;\n    d = *(c++);\n    if ((d >= '0') && (d <= '9'))\n      uu |= (d - '0');\n    else if ((d >= 'a') && (d <= 'f'))\n      uu |= (d - ('a'-10));\n    else\n      return (char *) 0;\n    *u = uu;\n  }\n  return c;\n}\n\n/*\n   Pack 'void *' into a string buffer.\n*/\nSWIGRUNTIME char *\nSWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {\n  char *r = buff;\n  if ((2*sizeof(void *) + 2) > bsz) return 0;\n  *(r++) = '_';\n  r = SWIG_PackData(r,&ptr,sizeof(void *));\n  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;\n  strcpy(r,name);\n  return buff;\n}\n\nSWIGRUNTIME const char *\nSWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {\n  if (*c != '_') {\n    if (strcmp(c,\"NULL\") == 0) {\n      *ptr = (void *) 0;\n      return name;\n    } else {\n      return 0;\n    }\n  }\n  return SWIG_UnpackData(++c,ptr,sizeof(void *));\n}\n\nSWIGRUNTIME char *\nSWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {\n  char *r = buff;\n  size_t lname = (name ? strlen(name) : 0);\n  if ((2*sz + 2 + lname) > bsz) return 0;\n  *(r++) = '_';\n  r = SWIG_PackData(r,ptr,sz);\n  if (lname) {\n    strncpy(r,name,lname+1);\n  } else {\n    *r = 0;\n  }\n  return buff;\n}\n\nSWIGRUNTIME const char *\nSWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {\n  if (*c != '_') {\n    if (strcmp(c,\"NULL\") == 0) {\n      memset(ptr,0,sz);\n      return name;\n    } else {\n      return 0;\n    }\n  }\n  return SWIG_UnpackData(++c,ptr,sz);\n}\n\n#ifdef __cplusplus\n}\n#endif\n\n/*  Errors in SWIG */\n#define  SWIG_UnknownError    \t   -1\n#define  SWIG_IOError        \t   -2\n#define  SWIG_RuntimeError   \t   -3\n#define  SWIG_IndexError     \t   -4\n#define  SWIG_TypeError      \t   -5\n#define  SWIG_DivisionByZero \t   -6\n#define  SWIG_OverflowError  \t   -7\n#define  SWIG_SyntaxError    \t   -8\n#define  SWIG_ValueError     \t   -9\n#define  SWIG_SystemError    \t   -10\n#define  SWIG_AttributeError \t   -11\n#define  SWIG_MemoryError    \t   -12\n#define  SWIG_NullReferenceError   -13\n\n\n\n/* Compatibility macros for Python 3 */\n#if PY_VERSION_HEX >= 0x03000000\n\n#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)\n#define PyInt_Check(x) PyLong_Check(x)\n#define PyInt_AsLong(x) PyLong_AsLong(x)\n#define PyInt_FromLong(x) PyLong_FromLong(x)\n#define PyInt_FromSize_t(x) PyLong_FromSize_t(x)\n#define PyString_Check(name) PyBytes_Check(name)\n#define PyString_FromString(x) PyUnicode_FromString(x)\n#define PyString_Format(fmt, args)  PyUnicode_Format(fmt, args)\n#define PyString_AsString(str) PyBytes_AsString(str)\n#define PyString_Size(str) PyBytes_Size(str)\t\n#define PyString_InternFromString(key) PyUnicode_InternFromString(key)\n#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE\n#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x)\n#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)\n\n#endif\n\n#ifndef Py_TYPE\n#  define Py_TYPE(op) ((op)->ob_type)\n#endif\n\n/* SWIG APIs for compatibility of both Python 2 & 3 */\n\n#if PY_VERSION_HEX >= 0x03000000\n#  define SWIG_Python_str_FromFormat PyUnicode_FromFormat\n#else\n#  define SWIG_Python_str_FromFormat PyString_FromFormat\n#endif\n\n\n/* Warning: This function will allocate a new string in Python 3,\n * so please call SWIG_Python_str_DelForPy3(x) to free the space.\n */\nSWIGINTERN char*\nSWIG_Python_str_AsChar(PyObject *str)\n{\n#if PY_VERSION_HEX >= 0x03000000\n  char *cstr;\n  char *newstr;\n  Py_ssize_t len;\n  str = PyUnicode_AsUTF8String(str);\n  PyBytes_AsStringAndSize(str, &cstr, &len);\n  newstr = (char *) malloc(len+1);\n  memcpy(newstr, cstr, len+1);\n  Py_XDECREF(str);\n  return newstr;\n#else\n  return PyString_AsString(str);\n#endif\n}\n\n#if PY_VERSION_HEX >= 0x03000000\n#  define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )\n#else\n#  define SWIG_Python_str_DelForPy3(x) \n#endif\n\n\nSWIGINTERN PyObject*\nSWIG_Python_str_FromChar(const char *c)\n{\n#if PY_VERSION_HEX >= 0x03000000\n  return PyUnicode_FromString(c); \n#else\n  return PyString_FromString(c);\n#endif\n}\n\n/* Add PyOS_snprintf for old Pythons */\n#if PY_VERSION_HEX < 0x02020000\n# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)\n#  define PyOS_snprintf _snprintf\n# else\n#  define PyOS_snprintf snprintf\n# endif\n#endif\n\n/* A crude PyString_FromFormat implementation for old Pythons */\n#if PY_VERSION_HEX < 0x02020000\n\n#ifndef SWIG_PYBUFFER_SIZE\n# define SWIG_PYBUFFER_SIZE 1024\n#endif\n\nstatic PyObject *\nPyString_FromFormat(const char *fmt, ...) {\n  va_list ap;\n  char buf[SWIG_PYBUFFER_SIZE * 2];\n  int res;\n  va_start(ap, fmt);\n  res = vsnprintf(buf, sizeof(buf), fmt, ap);\n  va_end(ap);\n  return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);\n}\n#endif\n\n/* Add PyObject_Del for old Pythons */\n#if PY_VERSION_HEX < 0x01060000\n# define PyObject_Del(op) PyMem_DEL((op))\n#endif\n#ifndef PyObject_DEL\n# define PyObject_DEL PyObject_Del\n#endif\n\n/* A crude PyExc_StopIteration exception for old Pythons */\n#if PY_VERSION_HEX < 0x02020000\n# ifndef PyExc_StopIteration\n#  define PyExc_StopIteration PyExc_RuntimeError\n# endif\n# ifndef PyObject_GenericGetAttr\n#  define PyObject_GenericGetAttr 0\n# endif\n#endif\n\n/* Py_NotImplemented is defined in 2.1 and up. */\n#if PY_VERSION_HEX < 0x02010000\n# ifndef Py_NotImplemented\n#  define Py_NotImplemented PyExc_RuntimeError\n# endif\n#endif\n\n/* A crude PyString_AsStringAndSize implementation for old Pythons */\n#if PY_VERSION_HEX < 0x02010000\n# ifndef PyString_AsStringAndSize\n#  define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}\n# endif\n#endif\n\n/* PySequence_Size for old Pythons */\n#if PY_VERSION_HEX < 0x02000000\n# ifndef PySequence_Size\n#  define PySequence_Size PySequence_Length\n# endif\n#endif\n\n/* PyBool_FromLong for old Pythons */\n#if PY_VERSION_HEX < 0x02030000\nstatic\nPyObject *PyBool_FromLong(long ok)\n{\n  PyObject *result = ok ? Py_True : Py_False;\n  Py_INCREF(result);\n  return result;\n}\n#endif\n\n/* Py_ssize_t for old Pythons */\n/* This code is as recommended by: */\n/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */\n#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)\ntypedef int Py_ssize_t;\n# define PY_SSIZE_T_MAX INT_MAX\n# define PY_SSIZE_T_MIN INT_MIN\ntypedef inquiry lenfunc;\ntypedef intargfunc ssizeargfunc;\ntypedef intintargfunc ssizessizeargfunc;\ntypedef intobjargproc ssizeobjargproc;\ntypedef intintobjargproc ssizessizeobjargproc;\ntypedef getreadbufferproc readbufferproc;\ntypedef getwritebufferproc writebufferproc;\ntypedef getsegcountproc segcountproc;\ntypedef getcharbufferproc charbufferproc;\nstatic long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))\n{\n  long result = 0;\n  PyObject *i = PyNumber_Int(x);\n  if (i) {\n    result = PyInt_AsLong(i);\n    Py_DECREF(i);\n  }\n  return result;\n}\n#endif\n\n#if PY_VERSION_HEX < 0x02050000\n#define PyInt_FromSize_t(x) PyInt_FromLong((long)x)\n#endif\n\n#if PY_VERSION_HEX < 0x02040000\n#define Py_VISIT(op)\t\t\t\t\\\n  do { \t\t\t\t\t\t\\\n    if (op) {\t\t\t\t\t\\\n      int vret = visit((op), arg);\t\t\\\n      if (vret)\t\t\t\t\t\\\n        return vret;\t\t\t\t\\\n    }\t\t\t\t\t\t\\\n  } while (0)\n#endif\n\n#if PY_VERSION_HEX < 0x02030000\ntypedef struct {\n  PyTypeObject type;\n  PyNumberMethods as_number;\n  PyMappingMethods as_mapping;\n  PySequenceMethods as_sequence;\n  PyBufferProcs as_buffer;\n  PyObject *name, *slots;\n} PyHeapTypeObject;\n#endif\n\n#if PY_VERSION_HEX < 0x02030000\ntypedef destructor freefunc;\n#endif\n\n#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \\\n     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \\\n     (PY_MAJOR_VERSION > 3))\n# define SWIGPY_USE_CAPSULE\n# define SWIGPY_CAPSULE_NAME ((char*)\"swig_runtime_data\" SWIG_RUNTIME_VERSION \".type_pointer_capsule\" SWIG_TYPE_TABLE_NAME)\n#endif\n\n#if PY_VERSION_HEX < 0x03020000\n#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)\n#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)\n#endif\n\n/* -----------------------------------------------------------------------------\n * error manipulation\n * ----------------------------------------------------------------------------- */\n\nSWIGRUNTIME PyObject*\nSWIG_Python_ErrorType(int code) {\n  PyObject* type = 0;\n  switch(code) {\n  case SWIG_MemoryError:\n    type = PyExc_MemoryError;\n    break;\n  case SWIG_IOError:\n    type = PyExc_IOError;\n    break;\n  case SWIG_RuntimeError:\n    type = PyExc_RuntimeError;\n    break;\n  case SWIG_IndexError:\n    type = PyExc_IndexError;\n    break;\n  case SWIG_TypeError:\n    type = PyExc_TypeError;\n    break;\n  case SWIG_DivisionByZero:\n    type = PyExc_ZeroDivisionError;\n    break;\n  case SWIG_OverflowError:\n    type = PyExc_OverflowError;\n    break;\n  case SWIG_SyntaxError:\n    type = PyExc_SyntaxError;\n    break;\n  case SWIG_ValueError:\n    type = PyExc_ValueError;\n    break;\n  case SWIG_SystemError:\n    type = PyExc_SystemError;\n    break;\n  case SWIG_AttributeError:\n    type = PyExc_AttributeError;\n    break;\n  default:\n    type = PyExc_RuntimeError;\n  }\n  return type;\n}\n\n\nSWIGRUNTIME void\nSWIG_Python_AddErrorMsg(const char* mesg)\n{\n  PyObject *type = 0;\n  PyObject *value = 0;\n  PyObject *traceback = 0;\n\n  if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);\n  if (value) {\n    char *tmp;\n    PyObject *old_str = PyObject_Str(value);\n    PyErr_Clear();\n    Py_XINCREF(type);\n\n    PyErr_Format(type, \"%s %s\", tmp = SWIG_Python_str_AsChar(old_str), mesg);\n    SWIG_Python_str_DelForPy3(tmp);\n    Py_DECREF(old_str);\n    Py_DECREF(value);\n  } else {\n    PyErr_SetString(PyExc_RuntimeError, mesg);\n  }\n}\n\n#if defined(SWIG_PYTHON_NO_THREADS)\n#  if defined(SWIG_PYTHON_THREADS)\n#    undef SWIG_PYTHON_THREADS\n#  endif\n#endif\n#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */\n#  if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)\n#    if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */\n#      define SWIG_PYTHON_USE_GIL\n#    endif\n#  endif\n#  if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */\n#    ifndef SWIG_PYTHON_INITIALIZE_THREADS\n#     define SWIG_PYTHON_INITIALIZE_THREADS  PyEval_InitThreads() \n#    endif\n#    ifdef __cplusplus /* C++ code */\n       class SWIG_Python_Thread_Block {\n         bool status;\n         PyGILState_STATE state;\n       public:\n         void end() { if (status) { PyGILState_Release(state); status = false;} }\n         SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}\n         ~SWIG_Python_Thread_Block() { end(); }\n       };\n       class SWIG_Python_Thread_Allow {\n         bool status;\n         PyThreadState *save;\n       public:\n         void end() { if (status) { PyEval_RestoreThread(save); status = false; }}\n         SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}\n         ~SWIG_Python_Thread_Allow() { end(); }\n       };\n#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   SWIG_Python_Thread_Block _swig_thread_block\n#      define SWIG_PYTHON_THREAD_END_BLOCK     _swig_thread_block.end()\n#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   SWIG_Python_Thread_Allow _swig_thread_allow\n#      define SWIG_PYTHON_THREAD_END_ALLOW     _swig_thread_allow.end()\n#    else /* C code */\n#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   PyGILState_STATE _swig_thread_block = PyGILState_Ensure()\n#      define SWIG_PYTHON_THREAD_END_BLOCK     PyGILState_Release(_swig_thread_block)\n#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   PyThreadState *_swig_thread_allow = PyEval_SaveThread()\n#      define SWIG_PYTHON_THREAD_END_ALLOW     PyEval_RestoreThread(_swig_thread_allow)\n#    endif\n#  else /* Old thread way, not implemented, user must provide it */\n#    if !defined(SWIG_PYTHON_INITIALIZE_THREADS)\n#      define SWIG_PYTHON_INITIALIZE_THREADS\n#    endif\n#    if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)\n#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK\n#    endif\n#    if !defined(SWIG_PYTHON_THREAD_END_BLOCK)\n#      define SWIG_PYTHON_THREAD_END_BLOCK\n#    endif\n#    if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)\n#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW\n#    endif\n#    if !defined(SWIG_PYTHON_THREAD_END_ALLOW)\n#      define SWIG_PYTHON_THREAD_END_ALLOW\n#    endif\n#  endif\n#else /* No thread support */\n#  define SWIG_PYTHON_INITIALIZE_THREADS\n#  define SWIG_PYTHON_THREAD_BEGIN_BLOCK\n#  define SWIG_PYTHON_THREAD_END_BLOCK\n#  define SWIG_PYTHON_THREAD_BEGIN_ALLOW\n#  define SWIG_PYTHON_THREAD_END_ALLOW\n#endif\n\n/* -----------------------------------------------------------------------------\n * Python API portion that goes into the runtime\n * ----------------------------------------------------------------------------- */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* -----------------------------------------------------------------------------\n * Constant declarations\n * ----------------------------------------------------------------------------- */\n\n/* Constant Types */\n#define SWIG_PY_POINTER 4\n#define SWIG_PY_BINARY  5\n\n/* Constant information structure */\ntypedef struct swig_const_info {\n  int type;\n  char *name;\n  long lvalue;\n  double dvalue;\n  void   *pvalue;\n  swig_type_info **ptype;\n} swig_const_info;\n\n\n/* -----------------------------------------------------------------------------\n * Wrapper of PyInstanceMethod_New() used in Python 3\n * It is exported to the generated module, used for -fastproxy\n * ----------------------------------------------------------------------------- */\n#if PY_VERSION_HEX >= 0x03000000\nSWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func)\n{\n  return PyInstanceMethod_New(func);\n}\n#else\nSWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func))\n{\n  return NULL;\n}\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n\n/* -----------------------------------------------------------------------------\n * pyrun.swg\n *\n * This file contains the runtime support for Python modules\n * and includes code for managing global variables and pointer\n * type checking.\n *\n * ----------------------------------------------------------------------------- */\n\n/* Common SWIG API */\n\n/* for raw pointers */\n#define SWIG_Python_ConvertPtr(obj, pptr, type, flags)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)\n#define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Python_ConvertPtr(obj, pptr, type, flags)\n#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)\n\n#ifdef SWIGPYTHON_BUILTIN\n#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(self, ptr, type, flags)\n#else\n#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)\n#endif\n\n#define SWIG_InternalNewPointerObj(ptr, type, flags)\tSWIG_Python_NewPointerObj(NULL, ptr, type, flags)\n\n#define SWIG_CheckImplicit(ty)                          SWIG_Python_CheckImplicit(ty) \n#define SWIG_AcquirePtr(ptr, src)                       SWIG_Python_AcquirePtr(ptr, src)\n#define swig_owntype                                    int\n\n/* for raw packed data */\n#define SWIG_ConvertPacked(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)\n#define SWIG_NewPackedObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)\n\n/* for class or struct pointers */\n#define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)\n#define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)\n\n/* for C or C++ function pointers */\n#define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_Python_ConvertFunctionPtr(obj, pptr, type)\n#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(NULL, ptr, type, 0)\n\n/* for C++ member pointers, ie, member methods */\n#define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)\n#define SWIG_NewMemberObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)\n\n\n/* Runtime API */\n\n#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule(clientdata)\n#define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)\n#define SWIG_NewClientData(obj)                         SwigPyClientData_New(obj)\n\n#define SWIG_SetErrorObj                                SWIG_Python_SetErrorObj                            \n#define SWIG_SetErrorMsg                        \tSWIG_Python_SetErrorMsg\t\t\t\t   \n#define SWIG_ErrorType(code)                    \tSWIG_Python_ErrorType(code)                        \n#define SWIG_Error(code, msg)            \t\tSWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) \n#define SWIG_fail                        \t\tgoto fail\t\t\t\t\t   \n\n\n/* Runtime API implementation */\n\n/* Error manipulation */\n\nSWIGINTERN void \nSWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {\n  SWIG_PYTHON_THREAD_BEGIN_BLOCK; \n  PyErr_SetObject(errtype, obj);\n  Py_DECREF(obj);\n  SWIG_PYTHON_THREAD_END_BLOCK;\n}\n\nSWIGINTERN void \nSWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {\n  SWIG_PYTHON_THREAD_BEGIN_BLOCK;\n  PyErr_SetString(errtype, msg);\n  SWIG_PYTHON_THREAD_END_BLOCK;\n}\n\n#define SWIG_Python_Raise(obj, type, desc)  SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)\n\n/* Set a constant value */\n\n#if defined(SWIGPYTHON_BUILTIN)\n\nSWIGINTERN void\nSwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {\n  PyObject *s = PyString_InternFromString(key);\n  PyList_Append(seq, s);\n  Py_DECREF(s);\n}\n\nSWIGINTERN void\nSWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {   \n#if PY_VERSION_HEX < 0x02030000\n  PyDict_SetItemString(d, (char *)name, obj);\n#else\n  PyDict_SetItemString(d, name, obj);\n#endif\n  Py_DECREF(obj);\n  if (public_interface)\n    SwigPyBuiltin_AddPublicSymbol(public_interface, name);\n}\n\n#else\n\nSWIGINTERN void\nSWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   \n#if PY_VERSION_HEX < 0x02030000\n  PyDict_SetItemString(d, (char *)name, obj);\n#else\n  PyDict_SetItemString(d, name, obj);\n#endif\n  Py_DECREF(obj);                            \n}\n\n#endif\n\n/* Append a value to the result obj */\n\nSWIGINTERN PyObject*\nSWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {\n#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)\n  if (!result) {\n    result = obj;\n  } else if (result == Py_None) {\n    Py_DECREF(result);\n    result = obj;\n  } else {\n    if (!PyList_Check(result)) {\n      PyObject *o2 = result;\n      result = PyList_New(1);\n      PyList_SetItem(result, 0, o2);\n    }\n    PyList_Append(result,obj);\n    Py_DECREF(obj);\n  }\n  return result;\n#else\n  PyObject*   o2;\n  PyObject*   o3;\n  if (!result) {\n    result = obj;\n  } else if (result == Py_None) {\n    Py_DECREF(result);\n    result = obj;\n  } else {\n    if (!PyTuple_Check(result)) {\n      o2 = result;\n      result = PyTuple_New(1);\n      PyTuple_SET_ITEM(result, 0, o2);\n    }\n    o3 = PyTuple_New(1);\n    PyTuple_SET_ITEM(o3, 0, obj);\n    o2 = result;\n    result = PySequence_Concat(o2, o3);\n    Py_DECREF(o2);\n    Py_DECREF(o3);\n  }\n  return result;\n#endif\n}\n\n/* Unpack the argument tuple */\n\nSWIGINTERN int\nSWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)\n{\n  if (!args) {\n    if (!min && !max) {\n      return 1;\n    } else {\n      PyErr_Format(PyExc_TypeError, \"%s expected %s%d arguments, got none\", \n\t\t   name, (min == max ? \"\" : \"at least \"), (int)min);\n      return 0;\n    }\n  }  \n  if (!PyTuple_Check(args)) {\n    if (min <= 1 && max >= 1) {\n      int i;\n      objs[0] = args;\n      for (i = 1; i < max; ++i) {\n\tobjs[i] = 0;\n      }\n      return 2;\n    }\n    PyErr_SetString(PyExc_SystemError, \"UnpackTuple() argument list is not a tuple\");\n    return 0;\n  } else {\n    Py_ssize_t l = PyTuple_GET_SIZE(args);\n    if (l < min) {\n      PyErr_Format(PyExc_TypeError, \"%s expected %s%d arguments, got %d\", \n\t\t   name, (min == max ? \"\" : \"at least \"), (int)min, (int)l);\n      return 0;\n    } else if (l > max) {\n      PyErr_Format(PyExc_TypeError, \"%s expected %s%d arguments, got %d\", \n\t\t   name, (min == max ? \"\" : \"at most \"), (int)max, (int)l);\n      return 0;\n    } else {\n      int i;\n      for (i = 0; i < l; ++i) {\n\tobjs[i] = PyTuple_GET_ITEM(args, i);\n      }\n      for (; l < max; ++l) {\n\tobjs[l] = 0;\n      }\n      return i + 1;\n    }    \n  }\n}\n\n/* A functor is a function object with one single object argument */\n#if PY_VERSION_HEX >= 0x02020000\n#define SWIG_Python_CallFunctor(functor, obj)\t        PyObject_CallFunctionObjArgs(functor, obj, NULL);\n#else\n#define SWIG_Python_CallFunctor(functor, obj)\t        PyObject_CallFunction(functor, \"O\", obj);\n#endif\n\n/*\n  Helper for static pointer initialization for both C and C++ code, for example\n  static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);\n*/\n#ifdef __cplusplus\n#define SWIG_STATIC_POINTER(var)  var\n#else\n#define SWIG_STATIC_POINTER(var)  var = 0; if (!var) var\n#endif\n\n/* -----------------------------------------------------------------------------\n * Pointer declarations\n * ----------------------------------------------------------------------------- */\n\n/* Flags for new pointer objects */\n#define SWIG_POINTER_NOSHADOW       (SWIG_POINTER_OWN      << 1)\n#define SWIG_POINTER_NEW            (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)\n\n#define SWIG_POINTER_IMPLICIT_CONV  (SWIG_POINTER_DISOWN   << 1)\n\n#define SWIG_BUILTIN_TP_INIT\t    (SWIG_POINTER_OWN << 2)\n#define SWIG_BUILTIN_INIT\t    (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*  How to access Py_None */\n#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n#  ifndef SWIG_PYTHON_NO_BUILD_NONE\n#    ifndef SWIG_PYTHON_BUILD_NONE\n#      define SWIG_PYTHON_BUILD_NONE\n#    endif\n#  endif\n#endif\n\n#ifdef SWIG_PYTHON_BUILD_NONE\n#  ifdef Py_None\n#   undef Py_None\n#   define Py_None SWIG_Py_None()\n#  endif\nSWIGRUNTIMEINLINE PyObject * \n_SWIG_Py_None(void)\n{\n  PyObject *none = Py_BuildValue((char*)\"\");\n  Py_DECREF(none);\n  return none;\n}\nSWIGRUNTIME PyObject * \nSWIG_Py_None(void)\n{\n  static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();\n  return none;\n}\n#endif\n\n/* The python void return value */\n\nSWIGRUNTIMEINLINE PyObject * \nSWIG_Py_Void(void)\n{\n  PyObject *none = Py_None;\n  Py_INCREF(none);\n  return none;\n}\n\n/* SwigPyClientData */\n\ntypedef struct {\n  PyObject *klass;\n  PyObject *newraw;\n  PyObject *newargs;\n  PyObject *destroy;\n  int delargs;\n  int implicitconv;\n  PyTypeObject *pytype;\n} SwigPyClientData;\n\nSWIGRUNTIMEINLINE int \nSWIG_Python_CheckImplicit(swig_type_info *ty)\n{\n  SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;\n  return data ? data->implicitconv : 0;\n}\n\nSWIGRUNTIMEINLINE PyObject *\nSWIG_Python_ExceptionType(swig_type_info *desc) {\n  SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;\n  PyObject *klass = data ? data->klass : 0;\n  return (klass ? klass : PyExc_RuntimeError);\n}\n\n\nSWIGRUNTIME SwigPyClientData * \nSwigPyClientData_New(PyObject* obj)\n{\n  if (!obj) {\n    return 0;\n  } else {\n    SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));\n    /* the klass element */\n    data->klass = obj;\n    Py_INCREF(data->klass);\n    /* the newraw method and newargs arguments used to create a new raw instance */\n    if (PyClass_Check(obj)) {\n      data->newraw = 0;\n      data->newargs = obj;\n      Py_INCREF(obj);\n    } else {\n#if (PY_VERSION_HEX < 0x02020000)\n      data->newraw = 0;\n#else\n      data->newraw = PyObject_GetAttrString(data->klass, (char *)\"__new__\");\n#endif\n      if (data->newraw) {\n\tPy_INCREF(data->newraw);\n\tdata->newargs = PyTuple_New(1);\n\tPyTuple_SetItem(data->newargs, 0, obj);\n      } else {\n\tdata->newargs = obj;\n      }\n      Py_INCREF(data->newargs);\n    }\n    /* the destroy method, aka as the C++ delete method */\n    data->destroy = PyObject_GetAttrString(data->klass, (char *)\"__swig_destroy__\");\n    if (PyErr_Occurred()) {\n      PyErr_Clear();\n      data->destroy = 0;\n    }\n    if (data->destroy) {\n      int flags;\n      Py_INCREF(data->destroy);\n      flags = PyCFunction_GET_FLAGS(data->destroy);\n#ifdef METH_O\n      data->delargs = !(flags & (METH_O));\n#else\n      data->delargs = 0;\n#endif\n    } else {\n      data->delargs = 0;\n    }\n    data->implicitconv = 0;\n    data->pytype = 0;\n    return data;\n  }\n}\n\nSWIGRUNTIME void \nSwigPyClientData_Del(SwigPyClientData *data) {\n  Py_XDECREF(data->newraw);\n  Py_XDECREF(data->newargs);\n  Py_XDECREF(data->destroy);\n}\n\n/* =============== SwigPyObject =====================*/\n\ntypedef struct {\n  PyObject_HEAD\n  void *ptr;\n  swig_type_info *ty;\n  int own;\n  PyObject *next;\n#ifdef SWIGPYTHON_BUILTIN\n  PyObject *dict;\n#endif\n} SwigPyObject;\n\nSWIGRUNTIME PyObject *\nSwigPyObject_long(SwigPyObject *v)\n{\n  return PyLong_FromVoidPtr(v->ptr);\n}\n\nSWIGRUNTIME PyObject *\nSwigPyObject_format(const char* fmt, SwigPyObject *v)\n{\n  PyObject *res = NULL;\n  PyObject *args = PyTuple_New(1);\n  if (args) {\n    if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {\n      PyObject *ofmt = SWIG_Python_str_FromChar(fmt);\n      if (ofmt) {\n#if PY_VERSION_HEX >= 0x03000000\n\tres = PyUnicode_Format(ofmt,args);\n#else\n\tres = PyString_Format(ofmt,args);\n#endif\n\tPy_DECREF(ofmt);\n      }\n      Py_DECREF(args);\n    }\n  }\n  return res;\n}\n\nSWIGRUNTIME PyObject *\nSwigPyObject_oct(SwigPyObject *v)\n{\n  return SwigPyObject_format(\"%o\",v);\n}\n\nSWIGRUNTIME PyObject *\nSwigPyObject_hex(SwigPyObject *v)\n{\n  return SwigPyObject_format(\"%x\",v);\n}\n\nSWIGRUNTIME PyObject *\n#ifdef METH_NOARGS\nSwigPyObject_repr(SwigPyObject *v)\n#else\nSwigPyObject_repr(SwigPyObject *v, PyObject *args)\n#endif\n{\n  const char *name = SWIG_TypePrettyName(v->ty);\n  PyObject *repr = SWIG_Python_str_FromFormat(\"<Swig Object of type '%s' at %p>\", (name ? name : \"unknown\"), (void *)v);\n  if (v->next) {\n# ifdef METH_NOARGS\n    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);\n# else\n    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);\n# endif\n# if PY_VERSION_HEX >= 0x03000000\n    PyObject *joined = PyUnicode_Concat(repr, nrep);\n    Py_DecRef(repr);\n    Py_DecRef(nrep);\n    repr = joined;\n# else\n    PyString_ConcatAndDel(&repr,nrep);\n# endif\n  }\n  return repr;  \n}\n\nSWIGRUNTIME int\nSwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)\n{\n  void *i = v->ptr;\n  void *j = w->ptr;\n  return (i < j) ? -1 : ((i > j) ? 1 : 0);\n}\n\n/* Added for Python 3.x, would it also be useful for Python 2.x? */\nSWIGRUNTIME PyObject*\nSwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)\n{\n  PyObject* res;\n  if( op != Py_EQ && op != Py_NE ) {\n    Py_INCREF(Py_NotImplemented);\n    return Py_NotImplemented;\n  }\n  res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);\n  return res;  \n}\n\n\nSWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);\n\n#ifdef SWIGPYTHON_BUILTIN\nstatic swig_type_info *SwigPyObject_stype = 0;\nSWIGRUNTIME PyTypeObject*\nSwigPyObject_type(void) {\n    SwigPyClientData *cd;\n    assert(SwigPyObject_stype);\n    cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;\n    assert(cd);\n    assert(cd->pytype);\n    return cd->pytype;\n}\n#else\nSWIGRUNTIME PyTypeObject*\nSwigPyObject_type(void) {\n  static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();\n  return type;\n}\n#endif\n\nSWIGRUNTIMEINLINE int\nSwigPyObject_Check(PyObject *op) {\n#ifdef SWIGPYTHON_BUILTIN\n  PyTypeObject *target_tp = SwigPyObject_type();\n  if (PyType_IsSubtype(op->ob_type, target_tp))\n    return 1;\n  return (strcmp(op->ob_type->tp_name, \"SwigPyObject\") == 0);\n#else\n  return (Py_TYPE(op) == SwigPyObject_type())\n    || (strcmp(Py_TYPE(op)->tp_name,\"SwigPyObject\") == 0);\n#endif\n}\n\nSWIGRUNTIME PyObject *\nSwigPyObject_New(void *ptr, swig_type_info *ty, int own);\n\nSWIGRUNTIME void\nSwigPyObject_dealloc(PyObject *v)\n{\n  SwigPyObject *sobj = (SwigPyObject *) v;\n  PyObject *next = sobj->next;\n  if (sobj->own == SWIG_POINTER_OWN) {\n    swig_type_info *ty = sobj->ty;\n    SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;\n    PyObject *destroy = data ? data->destroy : 0;\n    if (destroy) {\n      /* destroy is always a VARARGS method */\n      PyObject *res;\n      if (data->delargs) {\n\t/* we need to create a temporary object to carry the destroy operation */\n\tPyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);\n\tres = SWIG_Python_CallFunctor(destroy, tmp);\n\tPy_DECREF(tmp);\n      } else {\n\tPyCFunction meth = PyCFunction_GET_FUNCTION(destroy);\n\tPyObject *mself = PyCFunction_GET_SELF(destroy);\n\tres = ((*meth)(mself, v));\n      }\n      Py_XDECREF(res);\n    } \n#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)\n    else {\n      const char *name = SWIG_TypePrettyName(ty);\n      printf(\"swig/python detected a memory leak of type '%s', no destructor found.\\n\", (name ? name : \"unknown\"));\n    }\n#endif\n  } \n  Py_XDECREF(next);\n  PyObject_DEL(v);\n}\n\nSWIGRUNTIME PyObject* \nSwigPyObject_append(PyObject* v, PyObject* next)\n{\n  SwigPyObject *sobj = (SwigPyObject *) v;\n#ifndef METH_O\n  PyObject *tmp = 0;\n  if (!PyArg_ParseTuple(next,(char *)\"O:append\", &tmp)) return NULL;\n  next = tmp;\n#endif\n  if (!SwigPyObject_Check(next)) {\n    return NULL;\n  }\n  sobj->next = next;\n  Py_INCREF(next);\n  return SWIG_Py_Void();\n}\n\nSWIGRUNTIME PyObject* \n#ifdef METH_NOARGS\nSwigPyObject_next(PyObject* v)\n#else\nSwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))\n#endif\n{\n  SwigPyObject *sobj = (SwigPyObject *) v;\n  if (sobj->next) {    \n    Py_INCREF(sobj->next);\n    return sobj->next;\n  } else {\n    return SWIG_Py_Void();\n  }\n}\n\nSWIGINTERN PyObject*\n#ifdef METH_NOARGS\nSwigPyObject_disown(PyObject *v)\n#else\nSwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))\n#endif\n{\n  SwigPyObject *sobj = (SwigPyObject *)v;\n  sobj->own = 0;\n  return SWIG_Py_Void();\n}\n\nSWIGINTERN PyObject*\n#ifdef METH_NOARGS\nSwigPyObject_acquire(PyObject *v)\n#else\nSwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))\n#endif\n{\n  SwigPyObject *sobj = (SwigPyObject *)v;\n  sobj->own = SWIG_POINTER_OWN;\n  return SWIG_Py_Void();\n}\n\nSWIGINTERN PyObject*\nSwigPyObject_own(PyObject *v, PyObject *args)\n{\n  PyObject *val = 0;\n#if (PY_VERSION_HEX < 0x02020000)\n  if (!PyArg_ParseTuple(args,(char *)\"|O:own\",&val))\n#elif (PY_VERSION_HEX < 0x02050000)\n  if (!PyArg_UnpackTuple(args, (char *)\"own\", 0, 1, &val)) \n#else\n  if (!PyArg_UnpackTuple(args, \"own\", 0, 1, &val)) \n#endif\n    {\n      return NULL;\n    } \n  else\n    {\n      SwigPyObject *sobj = (SwigPyObject *)v;\n      PyObject *obj = PyBool_FromLong(sobj->own);\n      if (val) {\n#ifdef METH_NOARGS\n\tif (PyObject_IsTrue(val)) {\n\t  SwigPyObject_acquire(v);\n\t} else {\n\t  SwigPyObject_disown(v);\n\t}\n#else\n\tif (PyObject_IsTrue(val)) {\n\t  SwigPyObject_acquire(v,args);\n\t} else {\n\t  SwigPyObject_disown(v,args);\n\t}\n#endif\n      } \n      return obj;\n    }\n}\n\n#ifdef METH_O\nstatic PyMethodDef\nswigobject_methods[] = {\n  {(char *)\"disown\",  (PyCFunction)SwigPyObject_disown,  METH_NOARGS,  (char *)\"releases ownership of the pointer\"},\n  {(char *)\"acquire\", (PyCFunction)SwigPyObject_acquire, METH_NOARGS,  (char *)\"acquires ownership of the pointer\"},\n  {(char *)\"own\",     (PyCFunction)SwigPyObject_own,     METH_VARARGS, (char *)\"returns/sets ownership of the pointer\"},\n  {(char *)\"append\",  (PyCFunction)SwigPyObject_append,  METH_O,       (char *)\"appends another 'this' object\"},\n  {(char *)\"next\",    (PyCFunction)SwigPyObject_next,    METH_NOARGS,  (char *)\"returns the next 'this' object\"},\n  {(char *)\"__repr__\",(PyCFunction)SwigPyObject_repr,    METH_NOARGS,  (char *)\"returns object representation\"},\n  {0, 0, 0, 0}  \n};\n#else\nstatic PyMethodDef\nswigobject_methods[] = {\n  {(char *)\"disown\",  (PyCFunction)SwigPyObject_disown,  METH_VARARGS,  (char *)\"releases ownership of the pointer\"},\n  {(char *)\"acquire\", (PyCFunction)SwigPyObject_acquire, METH_VARARGS,  (char *)\"aquires ownership of the pointer\"},\n  {(char *)\"own\",     (PyCFunction)SwigPyObject_own,     METH_VARARGS,  (char *)\"returns/sets ownership of the pointer\"},\n  {(char *)\"append\",  (PyCFunction)SwigPyObject_append,  METH_VARARGS,  (char *)\"appends another 'this' object\"},\n  {(char *)\"next\",    (PyCFunction)SwigPyObject_next,    METH_VARARGS,  (char *)\"returns the next 'this' object\"},\n  {(char *)\"__repr__\",(PyCFunction)SwigPyObject_repr,   METH_VARARGS,  (char *)\"returns object representation\"},\n  {0, 0, 0, 0}  \n};\n#endif\n\n#if PY_VERSION_HEX < 0x02020000\nSWIGINTERN PyObject *\nSwigPyObject_getattr(SwigPyObject *sobj,char *name)\n{\n  return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);\n}\n#endif\n\nSWIGRUNTIME PyTypeObject*\nSwigPyObject_TypeOnce(void) {\n  static char swigobject_doc[] = \"Swig object carries a C/C++ instance pointer\";\n\n  static PyNumberMethods SwigPyObject_as_number = {\n    (binaryfunc)0, /*nb_add*/\n    (binaryfunc)0, /*nb_subtract*/\n    (binaryfunc)0, /*nb_multiply*/\n    /* nb_divide removed in Python 3 */\n#if PY_VERSION_HEX < 0x03000000\n    (binaryfunc)0, /*nb_divide*/\n#endif\n    (binaryfunc)0, /*nb_remainder*/\n    (binaryfunc)0, /*nb_divmod*/\n    (ternaryfunc)0,/*nb_power*/\n    (unaryfunc)0,  /*nb_negative*/\n    (unaryfunc)0,  /*nb_positive*/\n    (unaryfunc)0,  /*nb_absolute*/\n    (inquiry)0,    /*nb_nonzero*/\n    0,\t\t   /*nb_invert*/\n    0,\t\t   /*nb_lshift*/\n    0,\t\t   /*nb_rshift*/\n    0,\t\t   /*nb_and*/\n    0,\t\t   /*nb_xor*/\n    0,\t\t   /*nb_or*/\n#if PY_VERSION_HEX < 0x03000000\n    0,   /*nb_coerce*/\n#endif\n    (unaryfunc)SwigPyObject_long, /*nb_int*/\n#if PY_VERSION_HEX < 0x03000000\n    (unaryfunc)SwigPyObject_long, /*nb_long*/\n#else\n    0, /*nb_reserved*/\n#endif\n    (unaryfunc)0,                 /*nb_float*/\n#if PY_VERSION_HEX < 0x03000000\n    (unaryfunc)SwigPyObject_oct,  /*nb_oct*/\n    (unaryfunc)SwigPyObject_hex,  /*nb_hex*/\n#endif\n#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */\n#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */\n#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */\n#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */\n    0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */\n#endif\n  };\n\n  static PyTypeObject swigpyobject_type;\n  static int type_init = 0;\n  if (!type_init) {\n    const PyTypeObject tmp = {\n      /* PyObject header changed in Python 3 */\n#if PY_VERSION_HEX >= 0x03000000\n      PyVarObject_HEAD_INIT(NULL, 0)\n#else\n      PyObject_HEAD_INIT(NULL)\n      0,                                    /* ob_size */\n#endif\n      (char *)\"SwigPyObject\",               /* tp_name */\n      sizeof(SwigPyObject),                 /* tp_basicsize */\n      0,                                    /* tp_itemsize */\n      (destructor)SwigPyObject_dealloc,     /* tp_dealloc */\n      0,\t\t\t\t    /* tp_print */\n#if PY_VERSION_HEX < 0x02020000\n      (getattrfunc)SwigPyObject_getattr,    /* tp_getattr */\n#else\n      (getattrfunc)0,                       /* tp_getattr */\n#endif\n      (setattrfunc)0,                       /* tp_setattr */\n#if PY_VERSION_HEX >= 0x03000000\n    0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */\n#else\n      (cmpfunc)SwigPyObject_compare,        /* tp_compare */\n#endif\n      (reprfunc)SwigPyObject_repr,          /* tp_repr */\n      &SwigPyObject_as_number,              /* tp_as_number */\n      0,                                    /* tp_as_sequence */\n      0,                                    /* tp_as_mapping */\n      (hashfunc)0,                          /* tp_hash */\n      (ternaryfunc)0,                       /* tp_call */\n      0,\t\t\t\t    /* tp_str */\n      PyObject_GenericGetAttr,              /* tp_getattro */\n      0,                                    /* tp_setattro */\n      0,                                    /* tp_as_buffer */\n      Py_TPFLAGS_DEFAULT,                   /* tp_flags */\n      swigobject_doc,                       /* tp_doc */\n      0,                                    /* tp_traverse */\n      0,                                    /* tp_clear */\n      (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */\n      0,                                    /* tp_weaklistoffset */\n#if PY_VERSION_HEX >= 0x02020000\n      0,                                    /* tp_iter */\n      0,                                    /* tp_iternext */\n      swigobject_methods,                   /* tp_methods */\n      0,                                    /* tp_members */\n      0,                                    /* tp_getset */\n      0,                                    /* tp_base */\n      0,                                    /* tp_dict */\n      0,                                    /* tp_descr_get */\n      0,                                    /* tp_descr_set */\n      0,                                    /* tp_dictoffset */\n      0,                                    /* tp_init */\n      0,                                    /* tp_alloc */\n      0,                                    /* tp_new */\n      0,                                    /* tp_free */\n      0,                                    /* tp_is_gc */\n      0,                                    /* tp_bases */\n      0,                                    /* tp_mro */\n      0,                                    /* tp_cache */\n      0,                                    /* tp_subclasses */\n      0,                                    /* tp_weaklist */\n#endif\n#if PY_VERSION_HEX >= 0x02030000\n      0,                                    /* tp_del */\n#endif\n#if PY_VERSION_HEX >= 0x02060000\n      0,                                    /* tp_version */\n#endif\n#ifdef COUNT_ALLOCS\n      0,0,0,0                               /* tp_alloc -> tp_next */\n#endif\n    };\n    swigpyobject_type = tmp;\n    type_init = 1;\n#if PY_VERSION_HEX < 0x02020000\n    swigpyobject_type.ob_type = &PyType_Type;\n#else\n    if (PyType_Ready(&swigpyobject_type) < 0)\n      return NULL;\n#endif\n  }\n  return &swigpyobject_type;\n}\n\nSWIGRUNTIME PyObject *\nSwigPyObject_New(void *ptr, swig_type_info *ty, int own)\n{\n  SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());\n  if (sobj) {\n    sobj->ptr  = ptr;\n    sobj->ty   = ty;\n    sobj->own  = own;\n    sobj->next = 0;\n  }\n  return (PyObject *)sobj;\n}\n\n/* -----------------------------------------------------------------------------\n * Implements a simple Swig Packed type, and use it instead of string\n * ----------------------------------------------------------------------------- */\n\ntypedef struct {\n  PyObject_HEAD\n  void *pack;\n  swig_type_info *ty;\n  size_t size;\n} SwigPyPacked;\n\nSWIGRUNTIME int\nSwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))\n{\n  char result[SWIG_BUFFER_SIZE];\n  fputs(\"<Swig Packed \", fp); \n  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {\n    fputs(\"at \", fp); \n    fputs(result, fp); \n  }\n  fputs(v->ty->name,fp); \n  fputs(\">\", fp);\n  return 0; \n}\n  \nSWIGRUNTIME PyObject *\nSwigPyPacked_repr(SwigPyPacked *v)\n{\n  char result[SWIG_BUFFER_SIZE];\n  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {\n    return SWIG_Python_str_FromFormat(\"<Swig Packed at %s%s>\", result, v->ty->name);\n  } else {\n    return SWIG_Python_str_FromFormat(\"<Swig Packed %s>\", v->ty->name);\n  }  \n}\n\nSWIGRUNTIME PyObject *\nSwigPyPacked_str(SwigPyPacked *v)\n{\n  char result[SWIG_BUFFER_SIZE];\n  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){\n    return SWIG_Python_str_FromFormat(\"%s%s\", result, v->ty->name);\n  } else {\n    return SWIG_Python_str_FromChar(v->ty->name);\n  }  \n}\n\nSWIGRUNTIME int\nSwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)\n{\n  size_t i = v->size;\n  size_t j = w->size;\n  int s = (i < j) ? -1 : ((i > j) ? 1 : 0);\n  return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);\n}\n\nSWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);\n\nSWIGRUNTIME PyTypeObject*\nSwigPyPacked_type(void) {\n  static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();\n  return type;\n}\n\nSWIGRUNTIMEINLINE int\nSwigPyPacked_Check(PyObject *op) {\n  return ((op)->ob_type == SwigPyPacked_TypeOnce()) \n    || (strcmp((op)->ob_type->tp_name,\"SwigPyPacked\") == 0);\n}\n\nSWIGRUNTIME void\nSwigPyPacked_dealloc(PyObject *v)\n{\n  if (SwigPyPacked_Check(v)) {\n    SwigPyPacked *sobj = (SwigPyPacked *) v;\n    free(sobj->pack);\n  }\n  PyObject_DEL(v);\n}\n\nSWIGRUNTIME PyTypeObject*\nSwigPyPacked_TypeOnce(void) {\n  static char swigpacked_doc[] = \"Swig object carries a C/C++ instance pointer\";\n  static PyTypeObject swigpypacked_type;\n  static int type_init = 0;\n  if (!type_init) {\n    const PyTypeObject tmp = {\n      /* PyObject header changed in Python 3 */\n#if PY_VERSION_HEX>=0x03000000\n      PyVarObject_HEAD_INIT(NULL, 0)\n#else\n      PyObject_HEAD_INIT(NULL)\n      0,                                    /* ob_size */\n#endif\n      (char *)\"SwigPyPacked\",               /* tp_name */\n      sizeof(SwigPyPacked),                 /* tp_basicsize */\n      0,                                    /* tp_itemsize */\n      (destructor)SwigPyPacked_dealloc,     /* tp_dealloc */\n      (printfunc)SwigPyPacked_print,        /* tp_print */\n      (getattrfunc)0,                       /* tp_getattr */\n      (setattrfunc)0,                       /* tp_setattr */\n#if PY_VERSION_HEX>=0x03000000\n      0, /* tp_reserved in 3.0.1 */\n#else\n      (cmpfunc)SwigPyPacked_compare,        /* tp_compare */\n#endif\n      (reprfunc)SwigPyPacked_repr,          /* tp_repr */\n      0,                                    /* tp_as_number */\n      0,                                    /* tp_as_sequence */\n      0,                                    /* tp_as_mapping */\n      (hashfunc)0,                          /* tp_hash */\n      (ternaryfunc)0,                       /* tp_call */\n      (reprfunc)SwigPyPacked_str,           /* tp_str */\n      PyObject_GenericGetAttr,              /* tp_getattro */\n      0,                                    /* tp_setattro */\n      0,                                    /* tp_as_buffer */\n      Py_TPFLAGS_DEFAULT,                   /* tp_flags */\n      swigpacked_doc,                       /* tp_doc */\n      0,                                    /* tp_traverse */\n      0,                                    /* tp_clear */\n      0,                                    /* tp_richcompare */\n      0,                                    /* tp_weaklistoffset */\n#if PY_VERSION_HEX >= 0x02020000\n      0,                                    /* tp_iter */\n      0,                                    /* tp_iternext */\n      0,                                    /* tp_methods */\n      0,                                    /* tp_members */\n      0,                                    /* tp_getset */\n      0,                                    /* tp_base */\n      0,                                    /* tp_dict */\n      0,                                    /* tp_descr_get */\n      0,                                    /* tp_descr_set */\n      0,                                    /* tp_dictoffset */\n      0,                                    /* tp_init */\n      0,                                    /* tp_alloc */\n      0,                                    /* tp_new */\n      0,                                    /* tp_free */\n      0,                                    /* tp_is_gc */\n      0,                                    /* tp_bases */\n      0,                                    /* tp_mro */\n      0,                                    /* tp_cache */\n      0,                                    /* tp_subclasses */\n      0,                                    /* tp_weaklist */\n#endif\n#if PY_VERSION_HEX >= 0x02030000\n      0,                                    /* tp_del */\n#endif\n#if PY_VERSION_HEX >= 0x02060000\n      0,                                    /* tp_version */\n#endif\n#ifdef COUNT_ALLOCS\n      0,0,0,0                               /* tp_alloc -> tp_next */\n#endif\n    };\n    swigpypacked_type = tmp;\n    type_init = 1;\n#if PY_VERSION_HEX < 0x02020000\n    swigpypacked_type.ob_type = &PyType_Type;\n#else\n    if (PyType_Ready(&swigpypacked_type) < 0)\n      return NULL;\n#endif\n  }\n  return &swigpypacked_type;\n}\n\nSWIGRUNTIME PyObject *\nSwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)\n{\n  SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());\n  if (sobj) {\n    void *pack = malloc(size);\n    if (pack) {\n      memcpy(pack, ptr, size);\n      sobj->pack = pack;\n      sobj->ty   = ty;\n      sobj->size = size;\n    } else {\n      PyObject_DEL((PyObject *) sobj);\n      sobj = 0;\n    }\n  }\n  return (PyObject *) sobj;\n}\n\nSWIGRUNTIME swig_type_info *\nSwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)\n{\n  if (SwigPyPacked_Check(obj)) {\n    SwigPyPacked *sobj = (SwigPyPacked *)obj;\n    if (sobj->size != size) return 0;\n    memcpy(ptr, sobj->pack, size);\n    return sobj->ty;\n  } else {\n    return 0;\n  }\n}\n\n/* -----------------------------------------------------------------------------\n * pointers/data manipulation\n * ----------------------------------------------------------------------------- */\n\nSWIGRUNTIMEINLINE PyObject *\n_SWIG_This(void)\n{\n    return SWIG_Python_str_FromChar(\"this\");\n}\n\nstatic PyObject *swig_this = NULL;\n\nSWIGRUNTIME PyObject *\nSWIG_This(void)\n{\n  if (swig_this == NULL)\n    swig_this = _SWIG_This();\n  return swig_this;\n}\n\n/* #define SWIG_PYTHON_SLOW_GETSET_THIS */\n\n/* TODO: I don't know how to implement the fast getset in Python 3 right now */\n#if PY_VERSION_HEX>=0x03000000\n#define SWIG_PYTHON_SLOW_GETSET_THIS \n#endif\n\nSWIGRUNTIME SwigPyObject *\nSWIG_Python_GetSwigThis(PyObject *pyobj) \n{\n  PyObject *obj;\n\n  if (SwigPyObject_Check(pyobj))\n    return (SwigPyObject *) pyobj;\n\n#ifdef SWIGPYTHON_BUILTIN\n  (void)obj;\n# ifdef PyWeakref_CheckProxy\n  if (PyWeakref_CheckProxy(pyobj)) {\n    pyobj = PyWeakref_GET_OBJECT(pyobj);\n    if (pyobj && SwigPyObject_Check(pyobj))\n      return (SwigPyObject*) pyobj;\n  }\n# endif\n  return NULL;\n#else\n\n  obj = 0;\n\n#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))\n  if (PyInstance_Check(pyobj)) {\n    obj = _PyInstance_Lookup(pyobj, SWIG_This());      \n  } else {\n    PyObject **dictptr = _PyObject_GetDictPtr(pyobj);\n    if (dictptr != NULL) {\n      PyObject *dict = *dictptr;\n      obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;\n    } else {\n#ifdef PyWeakref_CheckProxy\n      if (PyWeakref_CheckProxy(pyobj)) {\n\tPyObject *wobj = PyWeakref_GET_OBJECT(pyobj);\n\treturn wobj ? SWIG_Python_GetSwigThis(wobj) : 0;\n      }\n#endif\n      obj = PyObject_GetAttr(pyobj,SWIG_This());\n      if (obj) {\n\tPy_DECREF(obj);\n      } else {\n\tif (PyErr_Occurred()) PyErr_Clear();\n\treturn 0;\n      }\n    }\n  }\n#else\n  obj = PyObject_GetAttr(pyobj,SWIG_This());\n  if (obj) {\n    Py_DECREF(obj);\n  } else {\n    if (PyErr_Occurred()) PyErr_Clear();\n    return 0;\n  }\n#endif\n  if (obj && !SwigPyObject_Check(obj)) {\n    /* a PyObject is called 'this', try to get the 'real this'\n       SwigPyObject from it */ \n    return SWIG_Python_GetSwigThis(obj);\n  }\n  return (SwigPyObject *)obj;\n#endif\n}\n\n/* Acquire a pointer value */\n\nSWIGRUNTIME int\nSWIG_Python_AcquirePtr(PyObject *obj, int own) {\n  if (own == SWIG_POINTER_OWN) {\n    SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);\n    if (sobj) {\n      int oldown = sobj->own;\n      sobj->own = own;\n      return oldown;\n    }\n  }\n  return 0;\n}\n\n/* Convert a pointer value */\n\nSWIGRUNTIME int\nSWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {\n  int res;\n  SwigPyObject *sobj;\n  int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;\n\n  if (!obj)\n    return SWIG_ERROR;\n  if (obj == Py_None && !implicit_conv) {\n    if (ptr)\n      *ptr = 0;\n    return SWIG_OK;\n  }\n\n  res = SWIG_ERROR;\n\n  sobj = SWIG_Python_GetSwigThis(obj);\n  if (own)\n    *own = 0;\n  while (sobj) {\n    void *vptr = sobj->ptr;\n    if (ty) {\n      swig_type_info *to = sobj->ty;\n      if (to == ty) {\n        /* no type cast needed */\n        if (ptr) *ptr = vptr;\n        break;\n      } else {\n        swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);\n        if (!tc) {\n          sobj = (SwigPyObject *)sobj->next;\n        } else {\n          if (ptr) {\n            int newmemory = 0;\n            *ptr = SWIG_TypeCast(tc,vptr,&newmemory);\n            if (newmemory == SWIG_CAST_NEW_MEMORY) {\n              assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */\n              if (own)\n                *own = *own | SWIG_CAST_NEW_MEMORY;\n            }\n          }\n          break;\n        }\n      }\n    } else {\n      if (ptr) *ptr = vptr;\n      break;\n    }\n  }\n  if (sobj) {\n    if (own)\n      *own = *own | sobj->own;\n    if (flags & SWIG_POINTER_DISOWN) {\n      sobj->own = 0;\n    }\n    res = SWIG_OK;\n  } else {\n    if (implicit_conv) {\n      SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;\n      if (data && !data->implicitconv) {\n        PyObject *klass = data->klass;\n        if (klass) {\n          PyObject *impconv;\n          data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/\n          impconv = SWIG_Python_CallFunctor(klass, obj);\n          data->implicitconv = 0;\n          if (PyErr_Occurred()) {\n            PyErr_Clear();\n            impconv = 0;\n          }\n          if (impconv) {\n            SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);\n            if (iobj) {\n              void *vptr;\n              res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);\n              if (SWIG_IsOK(res)) {\n                if (ptr) {\n                  *ptr = vptr;\n                  /* transfer the ownership to 'ptr' */\n                  iobj->own = 0;\n                  res = SWIG_AddCast(res);\n                  res = SWIG_AddNewMask(res);\n                } else {\n                  res = SWIG_AddCast(res);\t\t    \n                }\n              }\n            }\n            Py_DECREF(impconv);\n          }\n        }\n      }\n    }\n    if (!SWIG_IsOK(res) && obj == Py_None) {\n      if (ptr)\n        *ptr = 0;\n      if (PyErr_Occurred())\n        PyErr_Clear();\n      res = SWIG_OK;\n    }\n  }\n  return res;\n}\n\n/* Convert a function ptr value */\n\nSWIGRUNTIME int\nSWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {\n  if (!PyCFunction_Check(obj)) {\n    return SWIG_ConvertPtr(obj, ptr, ty, 0);\n  } else {\n    void *vptr = 0;\n    \n    /* here we get the method pointer for callbacks */\n    const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);\n    const char *desc = doc ? strstr(doc, \"swig_ptr: \") : 0;\n    if (desc)\n      desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;\n    if (!desc) \n      return SWIG_ERROR;\n    if (ty) {\n      swig_cast_info *tc = SWIG_TypeCheck(desc,ty);\n      if (tc) {\n        int newmemory = 0;\n        *ptr = SWIG_TypeCast(tc,vptr,&newmemory);\n        assert(!newmemory); /* newmemory handling not yet implemented */\n      } else {\n        return SWIG_ERROR;\n      }\n    } else {\n      *ptr = vptr;\n    }\n    return SWIG_OK;\n  }\n}\n\n/* Convert a packed value value */\n\nSWIGRUNTIME int\nSWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {\n  swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);\n  if (!to) return SWIG_ERROR;\n  if (ty) {\n    if (to != ty) {\n      /* check type cast? */\n      swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);\n      if (!tc) return SWIG_ERROR;\n    }\n  }\n  return SWIG_OK;\n}  \n\n/* -----------------------------------------------------------------------------\n * Create a new pointer object\n * ----------------------------------------------------------------------------- */\n\n/*\n  Create a new instance object, without calling __init__, and set the\n  'this' attribute.\n*/\n\nSWIGRUNTIME PyObject* \nSWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)\n{\n#if (PY_VERSION_HEX >= 0x02020000)\n  PyObject *inst = 0;\n  PyObject *newraw = data->newraw;\n  if (newraw) {\n    inst = PyObject_Call(newraw, data->newargs, NULL);\n    if (inst) {\n#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)\n      PyObject **dictptr = _PyObject_GetDictPtr(inst);\n      if (dictptr != NULL) {\n\tPyObject *dict = *dictptr;\n\tif (dict == NULL) {\n\t  dict = PyDict_New();\n\t  *dictptr = dict;\n\t  PyDict_SetItem(dict, SWIG_This(), swig_this);\n\t}\n      }\n#else\n      PyObject *key = SWIG_This();\n      PyObject_SetAttr(inst, key, swig_this);\n#endif\n    }\n  } else {\n#if PY_VERSION_HEX >= 0x03000000\n    inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);\n    if (inst) {\n      PyObject_SetAttr(inst, SWIG_This(), swig_this);\n      Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;\n    }\n#else\n    PyObject *dict = PyDict_New();\n    if (dict) {\n      PyDict_SetItem(dict, SWIG_This(), swig_this);\n      inst = PyInstance_NewRaw(data->newargs, dict);\n      Py_DECREF(dict);\n    }\n#endif\n  }\n  return inst;\n#else\n#if (PY_VERSION_HEX >= 0x02010000)\n  PyObject *inst = 0;\n  PyObject *dict = PyDict_New();\n  if (dict) {\n    PyDict_SetItem(dict, SWIG_This(), swig_this);\n    inst = PyInstance_NewRaw(data->newargs, dict);\n    Py_DECREF(dict);\n  }\n  return (PyObject *) inst;\n#else\n  PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);\n  if (inst == NULL) {\n    return NULL;\n  }\n  inst->in_class = (PyClassObject *)data->newargs;\n  Py_INCREF(inst->in_class);\n  inst->in_dict = PyDict_New();\n  if (inst->in_dict == NULL) {\n    Py_DECREF(inst);\n    return NULL;\n  }\n#ifdef Py_TPFLAGS_HAVE_WEAKREFS\n  inst->in_weakreflist = NULL;\n#endif\n#ifdef Py_TPFLAGS_GC\n  PyObject_GC_Init(inst);\n#endif\n  PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);\n  return (PyObject *) inst;\n#endif\n#endif\n}\n\nSWIGRUNTIME void\nSWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)\n{\n PyObject *dict;\n#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)\n PyObject **dictptr = _PyObject_GetDictPtr(inst);\n if (dictptr != NULL) {\n   dict = *dictptr;\n   if (dict == NULL) {\n     dict = PyDict_New();\n     *dictptr = dict;\n   }\n   PyDict_SetItem(dict, SWIG_This(), swig_this);\n   return;\n }\n#endif\n dict = PyObject_GetAttrString(inst, (char*)\"__dict__\");\n PyDict_SetItem(dict, SWIG_This(), swig_this);\n Py_DECREF(dict);\n} \n\n\nSWIGINTERN PyObject *\nSWIG_Python_InitShadowInstance(PyObject *args) {\n  PyObject *obj[2];\n  if (!SWIG_Python_UnpackTuple(args, \"swiginit\", 2, 2, obj)) {\n    return NULL;\n  } else {\n    SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);\n    if (sthis) {\n      SwigPyObject_append((PyObject*) sthis, obj[1]);\n    } else {\n      SWIG_Python_SetSwigThis(obj[0], obj[1]);\n    }\n    return SWIG_Py_Void();\n  }\n}\n\n/* Create a new pointer object */\n\nSWIGRUNTIME PyObject *\nSWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {\n  SwigPyClientData *clientdata;\n  PyObject * robj;\n  int own;\n\n  if (!ptr)\n    return SWIG_Py_Void();\n\n  clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;\n  own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;\n  if (clientdata && clientdata->pytype) {\n    SwigPyObject *newobj;\n    if (flags & SWIG_BUILTIN_TP_INIT) {\n      newobj = (SwigPyObject*) self;\n      if (newobj->ptr) {\n        PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);\n        while (newobj->next)\n\t  newobj = (SwigPyObject *) newobj->next;\n        newobj->next = next_self;\n        newobj = (SwigPyObject *)next_self;\n      }\n    } else {\n      newobj = PyObject_New(SwigPyObject, clientdata->pytype);\n    }\n    if (newobj) {\n      newobj->ptr = ptr;\n      newobj->ty = type;\n      newobj->own = own;\n      newobj->next = 0;\n#ifdef SWIGPYTHON_BUILTIN\n      newobj->dict = 0;\n#endif\n      return (PyObject*) newobj;\n    }\n    return SWIG_Py_Void();\n  }\n\n  assert(!(flags & SWIG_BUILTIN_TP_INIT));\n\n  robj = SwigPyObject_New(ptr, type, own);\n  if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {\n    PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);\n    Py_DECREF(robj);\n    robj = inst;\n  }\n  return robj;\n}\n\n/* Create a new packed object */\n\nSWIGRUNTIMEINLINE PyObject *\nSWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {\n  return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();\n}\n\n/* -----------------------------------------------------------------------------*\n *  Get type list \n * -----------------------------------------------------------------------------*/\n\n#ifdef SWIG_LINK_RUNTIME\nvoid *SWIG_ReturnGlobalTypeList(void *);\n#endif\n\nSWIGRUNTIME swig_module_info *\nSWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {\n  static void *type_pointer = (void *)0;\n  /* first check if module already created */\n  if (!type_pointer) {\n#ifdef SWIG_LINK_RUNTIME\n    type_pointer = SWIG_ReturnGlobalTypeList((void *)0);\n#else\n# ifdef SWIGPY_USE_CAPSULE\n    type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);\n# else\n    type_pointer = PyCObject_Import((char*)\"swig_runtime_data\" SWIG_RUNTIME_VERSION,\n\t\t\t\t    (char*)\"type_pointer\" SWIG_TYPE_TABLE_NAME);\n# endif\n    if (PyErr_Occurred()) {\n      PyErr_Clear();\n      type_pointer = (void *)0;\n    }\n#endif\n  }\n  return (swig_module_info *) type_pointer;\n}\n\n#if PY_MAJOR_VERSION < 2\n/* PyModule_AddObject function was introduced in Python 2.0.  The following function\n   is copied out of Python/modsupport.c in python version 2.3.4 */\nSWIGINTERN int\nPyModule_AddObject(PyObject *m, char *name, PyObject *o)\n{\n  PyObject *dict;\n  if (!PyModule_Check(m)) {\n    PyErr_SetString(PyExc_TypeError,\n\t\t    \"PyModule_AddObject() needs module as first arg\");\n    return SWIG_ERROR;\n  }\n  if (!o) {\n    PyErr_SetString(PyExc_TypeError,\n\t\t    \"PyModule_AddObject() needs non-NULL value\");\n    return SWIG_ERROR;\n  }\n  \n  dict = PyModule_GetDict(m);\n  if (dict == NULL) {\n    /* Internal error -- modules must have a dict! */\n    PyErr_Format(PyExc_SystemError, \"module '%s' has no __dict__\",\n\t\t PyModule_GetName(m));\n    return SWIG_ERROR;\n  }\n  if (PyDict_SetItemString(dict, name, o))\n    return SWIG_ERROR;\n  Py_DECREF(o);\n  return SWIG_OK;\n}\n#endif\n\nSWIGRUNTIME void\n#ifdef SWIGPY_USE_CAPSULE\nSWIG_Python_DestroyModule(PyObject *obj)\n#else\nSWIG_Python_DestroyModule(void *vptr)\n#endif\n{\n#ifdef SWIGPY_USE_CAPSULE\n  swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);\n#else\n  swig_module_info *swig_module = (swig_module_info *) vptr;\n#endif\n  swig_type_info **types = swig_module->types;\n  size_t i;\n  for (i =0; i < swig_module->size; ++i) {\n    swig_type_info *ty = types[i];\n    if (ty->owndata) {\n      SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;\n      if (data) SwigPyClientData_Del(data);\n    }\n  }\n  Py_DECREF(SWIG_This());\n  swig_this = NULL;\n}\n\nSWIGRUNTIME void\nSWIG_Python_SetModule(swig_module_info *swig_module) {\n#if PY_VERSION_HEX >= 0x03000000\n /* Add a dummy module object into sys.modules */\n  PyObject *module = PyImport_AddModule((char*)\"swig_runtime_data\" SWIG_RUNTIME_VERSION);\n#else\n  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */\n  PyObject *module = Py_InitModule((char*)\"swig_runtime_data\" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);\n#endif\n#ifdef SWIGPY_USE_CAPSULE\n  PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);\n  if (pointer && module) {\n    PyModule_AddObject(module, (char*)\"type_pointer_capsule\" SWIG_TYPE_TABLE_NAME, pointer);\n  } else {\n    Py_XDECREF(pointer);\n  }\n#else\n  PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);\n  if (pointer && module) {\n    PyModule_AddObject(module, (char*)\"type_pointer\" SWIG_TYPE_TABLE_NAME, pointer);\n  } else {\n    Py_XDECREF(pointer);\n  }\n#endif\n}\n\n/* The python cached type query */\nSWIGRUNTIME PyObject *\nSWIG_Python_TypeCache(void) {\n  static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();\n  return cache;\n}\n\nSWIGRUNTIME swig_type_info *\nSWIG_Python_TypeQuery(const char *type)\n{\n  PyObject *cache = SWIG_Python_TypeCache();\n  PyObject *key = SWIG_Python_str_FromChar(type); \n  PyObject *obj = PyDict_GetItem(cache, key);\n  swig_type_info *descriptor;\n  if (obj) {\n#ifdef SWIGPY_USE_CAPSULE\n    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);\n#else\n    descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);\n#endif\n  } else {\n    swig_module_info *swig_module = SWIG_GetModule(0);\n    descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);\n    if (descriptor) {\n#ifdef SWIGPY_USE_CAPSULE\n      obj = PyCapsule_New((void*) descriptor, NULL, NULL);\n#else\n      obj = PyCObject_FromVoidPtr(descriptor, NULL);\n#endif\n      PyDict_SetItem(cache, key, obj);\n      Py_DECREF(obj);\n    }\n  }\n  Py_DECREF(key);\n  return descriptor;\n}\n\n/* \n   For backward compatibility only\n*/\n#define SWIG_POINTER_EXCEPTION  0\n#define SWIG_arg_fail(arg)      SWIG_Python_ArgFail(arg)\n#define SWIG_MustGetPtr(p, type, argnum, flags)  SWIG_Python_MustGetPtr(p, type, argnum, flags)\n\nSWIGRUNTIME int\nSWIG_Python_AddErrMesg(const char* mesg, int infront)\n{  \n  if (PyErr_Occurred()) {\n    PyObject *type = 0;\n    PyObject *value = 0;\n    PyObject *traceback = 0;\n    PyErr_Fetch(&type, &value, &traceback);\n    if (value) {\n      char *tmp;\n      PyObject *old_str = PyObject_Str(value);\n      Py_XINCREF(type);\n      PyErr_Clear();\n      if (infront) {\n\tPyErr_Format(type, \"%s %s\", mesg, tmp = SWIG_Python_str_AsChar(old_str));\n      } else {\n\tPyErr_Format(type, \"%s %s\", tmp = SWIG_Python_str_AsChar(old_str), mesg);\n      }\n      SWIG_Python_str_DelForPy3(tmp);\n      Py_DECREF(old_str);\n    }\n    return 1;\n  } else {\n    return 0;\n  }\n}\n  \nSWIGRUNTIME int\nSWIG_Python_ArgFail(int argnum)\n{\n  if (PyErr_Occurred()) {\n    /* add information about failing argument */\n    char mesg[256];\n    PyOS_snprintf(mesg, sizeof(mesg), \"argument number %d:\", argnum);\n    return SWIG_Python_AddErrMesg(mesg, 1);\n  } else {\n    return 0;\n  }\n}\n\nSWIGRUNTIMEINLINE const char *\nSwigPyObject_GetDesc(PyObject *self)\n{\n  SwigPyObject *v = (SwigPyObject *)self;\n  swig_type_info *ty = v ? v->ty : 0;\n  return ty ? ty->str : \"\";\n}\n\nSWIGRUNTIME void\nSWIG_Python_TypeError(const char *type, PyObject *obj)\n{\n  if (type) {\n#if defined(SWIG_COBJECT_TYPES)\n    if (obj && SwigPyObject_Check(obj)) {\n      const char *otype = (const char *) SwigPyObject_GetDesc(obj);\n      if (otype) {\n\tPyErr_Format(PyExc_TypeError, \"a '%s' is expected, 'SwigPyObject(%s)' is received\",\n\t\t     type, otype);\n\treturn;\n      }\n    } else \n#endif      \n    {\n      const char *otype = (obj ? obj->ob_type->tp_name : 0); \n      if (otype) {\n\tPyObject *str = PyObject_Str(obj);\n\tconst char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;\n\tif (cstr) {\n\t  PyErr_Format(PyExc_TypeError, \"a '%s' is expected, '%s(%s)' is received\",\n\t\t       type, otype, cstr);\n          SWIG_Python_str_DelForPy3(cstr);\n\t} else {\n\t  PyErr_Format(PyExc_TypeError, \"a '%s' is expected, '%s' is received\",\n\t\t       type, otype);\n\t}\n\tPy_XDECREF(str);\n\treturn;\n      }\n    }   \n    PyErr_Format(PyExc_TypeError, \"a '%s' is expected\", type);\n  } else {\n    PyErr_Format(PyExc_TypeError, \"unexpected type is received\");\n  }\n}\n\n\n/* Convert a pointer value, signal an exception on a type mismatch */\nSWIGRUNTIME void *\nSWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) {\n  void *result;\n  if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {\n    PyErr_Clear();\n#if SWIG_POINTER_EXCEPTION\n    if (flags) {\n      SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);\n      SWIG_Python_ArgFail(argnum);\n    }\n#endif\n  }\n  return result;\n}\n\n#ifdef SWIGPYTHON_BUILTIN\nSWIGRUNTIME int\nSWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {\n  PyTypeObject *tp = obj->ob_type;\n  PyObject *descr;\n  PyObject *encoded_name;\n  descrsetfunc f;\n  int res = -1;\n\n# ifdef Py_USING_UNICODE\n  if (PyString_Check(name)) {\n    name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);\n    if (!name)\n      return -1;\n  } else if (!PyUnicode_Check(name))\n# else\n  if (!PyString_Check(name))\n# endif\n  {\n    PyErr_Format(PyExc_TypeError, \"attribute name must be string, not '%.200s'\", name->ob_type->tp_name);\n    return -1;\n  } else {\n    Py_INCREF(name);\n  }\n\n  if (!tp->tp_dict) {\n    if (PyType_Ready(tp) < 0)\n      goto done;\n  }\n\n  descr = _PyType_Lookup(tp, name);\n  f = NULL;\n  if (descr != NULL)\n    f = descr->ob_type->tp_descr_set;\n  if (!f) {\n    if (PyString_Check(name)) {\n      encoded_name = name;\n      Py_INCREF(name);\n    } else {\n      encoded_name = PyUnicode_AsUTF8String(name);\n    }\n    PyErr_Format(PyExc_AttributeError, \"'%.100s' object has no attribute '%.200s'\", tp->tp_name, PyString_AsString(encoded_name));\n    Py_DECREF(encoded_name);\n  } else {\n    res = f(descr, obj, value);\n  }\n  \n  done:\n  Py_DECREF(name);\n  return res;\n}\n#endif\n\n\n#ifdef __cplusplus\n}\n#endif\n\n\n\n#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) \n\n#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else \n\n\n\n/* -------- TYPES TABLE (BEGIN) -------- */\n\n#define SWIGTYPE_p_char swig_types[0]\n#define SWIGTYPE_p_int swig_types[1]\n#define SWIGTYPE_p_long_long swig_types[2]\n#define SWIGTYPE_p_short swig_types[3]\n#define SWIGTYPE_p_signed_char swig_types[4]\n#define SWIGTYPE_p_unsigned_char swig_types[5]\n#define SWIGTYPE_p_unsigned_int swig_types[6]\n#define SWIGTYPE_p_unsigned_long_long swig_types[7]\n#define SWIGTYPE_p_unsigned_short swig_types[8]\nstatic swig_type_info *swig_types[10];\nstatic swig_module_info swig_module = {swig_types, 9, 0, 0, 0, 0};\n#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)\n#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)\n\n/* -------- TYPES TABLE (END) -------- */\n\n#if (PY_VERSION_HEX <= 0x02000000)\n# if !defined(SWIG_PYTHON_CLASSIC)\n#  error \"This python version requires swig to be run with the '-classic' option\"\n# endif\n#endif\n\n/*-----------------------------------------------\n              @(target):= _blinkt.so\n  ------------------------------------------------*/\n#if PY_VERSION_HEX >= 0x03000000\n#  define SWIG_init    PyInit__blinkt\n\n#else\n#  define SWIG_init    init_blinkt\n\n#endif\n#define SWIG_name    \"_blinkt\"\n\n#define SWIGVERSION 0x030002 \n#define SWIG_VERSION SWIGVERSION\n\n\n#define SWIG_as_voidptr(a) (void *)((const void *)(a)) \n#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) \n\n\n#include <stdint.h>\t\t// Use the C99 official header\n\n\n#include \"lib/blinkt.h\"\n\n\n#include <limits.h>\n#if !defined(SWIG_NO_LLONG_MAX)\n# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)\n#   define LLONG_MAX __LONG_LONG_MAX__\n#   define LLONG_MIN (-LLONG_MAX - 1LL)\n#   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)\n# endif\n#endif\n\n\nSWIGINTERN int\nSWIG_AsVal_double (PyObject *obj, double *val)\n{\n  int res = SWIG_TypeError;\n  if (PyFloat_Check(obj)) {\n    if (val) *val = PyFloat_AsDouble(obj);\n    return SWIG_OK;\n  } else if (PyInt_Check(obj)) {\n    if (val) *val = PyInt_AsLong(obj);\n    return SWIG_OK;\n  } else if (PyLong_Check(obj)) {\n    double v = PyLong_AsDouble(obj);\n    if (!PyErr_Occurred()) {\n      if (val) *val = v;\n      return SWIG_OK;\n    } else {\n      PyErr_Clear();\n    }\n  }\n#ifdef SWIG_PYTHON_CAST_MODE\n  {\n    int dispatch = 0;\n    double d = PyFloat_AsDouble(obj);\n    if (!PyErr_Occurred()) {\n      if (val) *val = d;\n      return SWIG_AddCast(SWIG_OK);\n    } else {\n      PyErr_Clear();\n    }\n    if (!dispatch) {\n      long v = PyLong_AsLong(obj);\n      if (!PyErr_Occurred()) {\n\tif (val) *val = v;\n\treturn SWIG_AddCast(SWIG_AddCast(SWIG_OK));\n      } else {\n\tPyErr_Clear();\n      }\n    }\n  }\n#endif\n  return res;\n}\n\n\n#include <float.h>\n\n\n#include <math.h>\n\n\nSWIGINTERNINLINE int\nSWIG_CanCastAsInteger(double *d, double min, double max) {\n  double x = *d;\n  if ((min <= x && x <= max)) {\n   double fx = floor(x);\n   double cx = ceil(x);\n   double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */\n   if ((errno == EDOM) || (errno == ERANGE)) {\n     errno = 0;\n   } else {\n     double summ, reps, diff;\n     if (rd < x) {\n       diff = x - rd;\n     } else if (rd > x) {\n       diff = rd - x;\n     } else {\n       return 1;\n     }\n     summ = rd + x;\n     reps = diff/summ;\n     if (reps < 8*DBL_EPSILON) {\n       *d = rd;\n       return 1;\n     }\n   }\n  }\n  return 0;\n}\n\n\nSWIGINTERN int\nSWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) \n{\n#if PY_VERSION_HEX < 0x03000000\n  if (PyInt_Check(obj)) {\n    long v = PyInt_AsLong(obj);\n    if (v >= 0) {\n      if (val) *val = v;\n      return SWIG_OK;\n    } else {\n      return SWIG_OverflowError;\n    }\n  } else\n#endif\n  if (PyLong_Check(obj)) {\n    unsigned long v = PyLong_AsUnsignedLong(obj);\n    if (!PyErr_Occurred()) {\n      if (val) *val = v;\n      return SWIG_OK;\n    } else {\n      PyErr_Clear();\n#if PY_VERSION_HEX >= 0x03000000\n      {\n        long v = PyLong_AsLong(obj);\n        if (!PyErr_Occurred()) {\n          if (v < 0) {\n            return SWIG_OverflowError;\n          }\n        } else {\n          PyErr_Clear();\n        }\n      }\n#endif\n    }\n  }\n#ifdef SWIG_PYTHON_CAST_MODE\n  {\n    int dispatch = 0;\n    unsigned long v = PyLong_AsUnsignedLong(obj);\n    if (!PyErr_Occurred()) {\n      if (val) *val = v;\n      return SWIG_AddCast(SWIG_OK);\n    } else {\n      PyErr_Clear();\n    }\n    if (!dispatch) {\n      double d;\n      int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));\n      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {\n\tif (val) *val = (unsigned long)(d);\n\treturn res;\n      }\n    }\n  }\n#endif\n  return SWIG_TypeError;\n}\n\n\nSWIGINTERN int\nSWIG_AsVal_unsigned_SS_char (PyObject * obj, unsigned char *val)\n{\n  unsigned long v;\n  int res = SWIG_AsVal_unsigned_SS_long (obj, &v);\n  if (SWIG_IsOK(res)) {\n    if ((v > UCHAR_MAX)) {\n      return SWIG_OverflowError;\n    } else {\n      if (val) *val = (unsigned char)(v);\n    }\n  }  \n  return res;\n}\n\n\nSWIGINTERN int\nSWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)\n{\n  unsigned long v;\n  int res = SWIG_AsVal_unsigned_SS_long (obj, &v);\n  if (SWIG_IsOK(res)) {\n    if ((v > UINT_MAX)) {\n      return SWIG_OverflowError;\n    } else {\n      if (val) *val = (unsigned int)(v);\n    }\n  }  \n  return res;\n}\n\n\nSWIGINTERNINLINE PyObject*\n  SWIG_From_unsigned_SS_int  (unsigned int value)\n{\n  return PyInt_FromSize_t((size_t) value);\n}\n\n\nSWIGINTERNINLINE PyObject*\n  SWIG_From_int  (int value)\n{\n  return PyInt_FromLong((long) value);\n}\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nSWIGINTERN PyObject *_wrap_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  \n  if (!PyArg_ParseTuple(args,(char *)\":clear\")) SWIG_fail;\n  clear();\n  resultobj = SWIG_Py_Void();\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_set_pixel_uint32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  uint8_t arg1 ;\n  uint32_t arg2 ;\n  unsigned char val1 ;\n  int ecode1 = 0 ;\n  unsigned int val2 ;\n  int ecode2 = 0 ;\n  PyObject * obj0 = 0 ;\n  PyObject * obj1 = 0 ;\n  \n  if (!PyArg_ParseTuple(args,(char *)\"OO:set_pixel_uint32\",&obj0,&obj1)) SWIG_fail;\n  ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1);\n  if (!SWIG_IsOK(ecode1)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode1), \"in method '\" \"set_pixel_uint32\" \"', argument \" \"1\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg1 = (uint8_t)(val1);\n  ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2);\n  if (!SWIG_IsOK(ecode2)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode2), \"in method '\" \"set_pixel_uint32\" \"', argument \" \"2\"\" of type '\" \"uint32_t\"\"'\");\n  } \n  arg2 = (uint32_t)(val2);\n  set_pixel_uint32(arg1,arg2);\n  resultobj = SWIG_Py_Void();\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_set_pixel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  uint8_t arg1 ;\n  uint8_t arg2 ;\n  uint8_t arg3 ;\n  uint8_t arg4 ;\n  unsigned char val1 ;\n  int ecode1 = 0 ;\n  unsigned char val2 ;\n  int ecode2 = 0 ;\n  unsigned char val3 ;\n  int ecode3 = 0 ;\n  unsigned char val4 ;\n  int ecode4 = 0 ;\n  PyObject * obj0 = 0 ;\n  PyObject * obj1 = 0 ;\n  PyObject * obj2 = 0 ;\n  PyObject * obj3 = 0 ;\n  \n  if (!PyArg_ParseTuple(args,(char *)\"OOOO:set_pixel\",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;\n  ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1);\n  if (!SWIG_IsOK(ecode1)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode1), \"in method '\" \"set_pixel\" \"', argument \" \"1\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg1 = (uint8_t)(val1);\n  ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2);\n  if (!SWIG_IsOK(ecode2)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode2), \"in method '\" \"set_pixel\" \"', argument \" \"2\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg2 = (uint8_t)(val2);\n  ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3);\n  if (!SWIG_IsOK(ecode3)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode3), \"in method '\" \"set_pixel\" \"', argument \" \"3\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg3 = (uint8_t)(val3);\n  ecode4 = SWIG_AsVal_unsigned_SS_char(obj3, &val4);\n  if (!SWIG_IsOK(ecode4)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode4), \"in method '\" \"set_pixel\" \"', argument \" \"4\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg4 = (uint8_t)(val4);\n  set_pixel(arg1,arg2,arg3,arg4);\n  resultobj = SWIG_Py_Void();\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_set_pixel_brightness(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  uint8_t arg1 ;\n  uint8_t arg2 ;\n  unsigned char val1 ;\n  int ecode1 = 0 ;\n  unsigned char val2 ;\n  int ecode2 = 0 ;\n  PyObject * obj0 = 0 ;\n  PyObject * obj1 = 0 ;\n  \n  if (!PyArg_ParseTuple(args,(char *)\"OO:set_pixel_brightness\",&obj0,&obj1)) SWIG_fail;\n  ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1);\n  if (!SWIG_IsOK(ecode1)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode1), \"in method '\" \"set_pixel_brightness\" \"', argument \" \"1\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg1 = (uint8_t)(val1);\n  ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2);\n  if (!SWIG_IsOK(ecode2)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode2), \"in method '\" \"set_pixel_brightness\" \"', argument \" \"2\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg2 = (uint8_t)(val2);\n  set_pixel_brightness(arg1,arg2);\n  resultobj = SWIG_Py_Void();\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_rgbb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  uint8_t arg1 ;\n  uint8_t arg2 ;\n  uint8_t arg3 ;\n  uint8_t arg4 ;\n  unsigned char val1 ;\n  int ecode1 = 0 ;\n  unsigned char val2 ;\n  int ecode2 = 0 ;\n  unsigned char val3 ;\n  int ecode3 = 0 ;\n  unsigned char val4 ;\n  int ecode4 = 0 ;\n  PyObject * obj0 = 0 ;\n  PyObject * obj1 = 0 ;\n  PyObject * obj2 = 0 ;\n  PyObject * obj3 = 0 ;\n  uint32_t result;\n  \n  if (!PyArg_ParseTuple(args,(char *)\"OOOO:rgbb\",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;\n  ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1);\n  if (!SWIG_IsOK(ecode1)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode1), \"in method '\" \"rgbb\" \"', argument \" \"1\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg1 = (uint8_t)(val1);\n  ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2);\n  if (!SWIG_IsOK(ecode2)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode2), \"in method '\" \"rgbb\" \"', argument \" \"2\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg2 = (uint8_t)(val2);\n  ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3);\n  if (!SWIG_IsOK(ecode3)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode3), \"in method '\" \"rgbb\" \"', argument \" \"3\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg3 = (uint8_t)(val3);\n  ecode4 = SWIG_AsVal_unsigned_SS_char(obj3, &val4);\n  if (!SWIG_IsOK(ecode4)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode4), \"in method '\" \"rgbb\" \"', argument \" \"4\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg4 = (uint8_t)(val4);\n  result = (uint32_t)rgbb(arg1,arg2,arg3,arg4);\n  resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result));\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_rgb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  uint8_t arg1 ;\n  uint8_t arg2 ;\n  uint8_t arg3 ;\n  unsigned char val1 ;\n  int ecode1 = 0 ;\n  unsigned char val2 ;\n  int ecode2 = 0 ;\n  unsigned char val3 ;\n  int ecode3 = 0 ;\n  PyObject * obj0 = 0 ;\n  PyObject * obj1 = 0 ;\n  PyObject * obj2 = 0 ;\n  uint32_t result;\n  \n  if (!PyArg_ParseTuple(args,(char *)\"OOO:rgb\",&obj0,&obj1,&obj2)) SWIG_fail;\n  ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1);\n  if (!SWIG_IsOK(ecode1)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode1), \"in method '\" \"rgb\" \"', argument \" \"1\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg1 = (uint8_t)(val1);\n  ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2);\n  if (!SWIG_IsOK(ecode2)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode2), \"in method '\" \"rgb\" \"', argument \" \"2\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg2 = (uint8_t)(val2);\n  ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3);\n  if (!SWIG_IsOK(ecode3)) {\n    SWIG_exception_fail(SWIG_ArgError(ecode3), \"in method '\" \"rgb\" \"', argument \" \"3\"\" of type '\" \"uint8_t\"\"'\");\n  } \n  arg3 = (uint8_t)(val3);\n  result = (uint32_t)rgb(arg1,arg2,arg3);\n  resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result));\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  \n  if (!PyArg_ParseTuple(args,(char *)\":stop\")) SWIG_fail;\n  stop();\n  resultobj = SWIG_Py_Void();\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  int result;\n  \n  if (!PyArg_ParseTuple(args,(char *)\":start\")) SWIG_fail;\n  result = (int)start();\n  resultobj = SWIG_From_int((int)(result));\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nSWIGINTERN PyObject *_wrap_show(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n  PyObject *resultobj = 0;\n  \n  if (!PyArg_ParseTuple(args,(char *)\":show\")) SWIG_fail;\n  show();\n  resultobj = SWIG_Py_Void();\n  return resultobj;\nfail:\n  return NULL;\n}\n\n\nstatic PyMethodDef SwigMethods[] = {\n\t { (char *)\"SWIG_PyInstanceMethod_New\", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},\n\t { (char *)\"clear\", _wrap_clear, METH_VARARGS, NULL},\n\t { (char *)\"set_pixel_uint32\", _wrap_set_pixel_uint32, METH_VARARGS, NULL},\n\t { (char *)\"set_pixel\", _wrap_set_pixel, METH_VARARGS, NULL},\n\t { (char *)\"set_pixel_brightness\", _wrap_set_pixel_brightness, METH_VARARGS, NULL},\n\t { (char *)\"rgbb\", _wrap_rgbb, METH_VARARGS, NULL},\n\t { (char *)\"rgb\", _wrap_rgb, METH_VARARGS, NULL},\n\t { (char *)\"stop\", _wrap_stop, METH_VARARGS, NULL},\n\t { (char *)\"start\", _wrap_start, METH_VARARGS, NULL},\n\t { (char *)\"show\", _wrap_show, METH_VARARGS, NULL},\n\t { NULL, NULL, 0, NULL }\n};\n\n\n/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */\n\nstatic swig_type_info _swigt__p_char = {\"_p_char\", \"char *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_int = {\"_p_int\", \"intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_long_long = {\"_p_long_long\", \"int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_short = {\"_p_short\", \"short *|int_least16_t *|int16_t *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_signed_char = {\"_p_signed_char\", \"signed char *|int_least8_t *|int_fast8_t *|int8_t *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_unsigned_char = {\"_p_unsigned_char\", \"unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_unsigned_int = {\"_p_unsigned_int\", \"uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_unsigned_long_long = {\"_p_unsigned_long_long\", \"uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *\", 0, 0, (void*)0, 0};\nstatic swig_type_info _swigt__p_unsigned_short = {\"_p_unsigned_short\", \"unsigned short *|uint_least16_t *|uint16_t *\", 0, 0, (void*)0, 0};\n\nstatic swig_type_info *swig_type_initial[] = {\n  &_swigt__p_char,\n  &_swigt__p_int,\n  &_swigt__p_long_long,\n  &_swigt__p_short,\n  &_swigt__p_signed_char,\n  &_swigt__p_unsigned_char,\n  &_swigt__p_unsigned_int,\n  &_swigt__p_unsigned_long_long,\n  &_swigt__p_unsigned_short,\n};\n\nstatic swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_long_long[] = {  {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_short[] = {  {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_signed_char[] = {  {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_unsigned_char[] = {  {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_unsigned_int[] = {  {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_unsigned_long_long[] = {  {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};\nstatic swig_cast_info _swigc__p_unsigned_short[] = {  {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};\n\nstatic swig_cast_info *swig_cast_initial[] = {\n  _swigc__p_char,\n  _swigc__p_int,\n  _swigc__p_long_long,\n  _swigc__p_short,\n  _swigc__p_signed_char,\n  _swigc__p_unsigned_char,\n  _swigc__p_unsigned_int,\n  _swigc__p_unsigned_long_long,\n  _swigc__p_unsigned_short,\n};\n\n\n/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */\n\nstatic swig_const_info swig_const_table[] = {\n{0, 0, 0, 0.0, 0, 0}};\n\n#ifdef __cplusplus\n}\n#endif\n/* -----------------------------------------------------------------------------\n * Type initialization:\n * This problem is tough by the requirement that no dynamic\n * memory is used. Also, since swig_type_info structures store pointers to\n * swig_cast_info structures and swig_cast_info structures store pointers back\n * to swig_type_info structures, we need some lookup code at initialization.\n * The idea is that swig generates all the structures that are needed.\n * The runtime then collects these partially filled structures.\n * The SWIG_InitializeModule function takes these initial arrays out of\n * swig_module, and does all the lookup, filling in the swig_module.types\n * array with the correct data and linking the correct swig_cast_info\n * structures together.\n *\n * The generated swig_type_info structures are assigned statically to an initial\n * array. We just loop through that array, and handle each type individually.\n * First we lookup if this type has been already loaded, and if so, use the\n * loaded structure instead of the generated one. Then we have to fill in the\n * cast linked list. The cast data is initially stored in something like a\n * two-dimensional array. Each row corresponds to a type (there are the same\n * number of rows as there are in the swig_type_initial array). Each entry in\n * a column is one of the swig_cast_info structures for that type.\n * The cast_initial array is actually an array of arrays, because each row has\n * a variable number of columns. So to actually build the cast linked list,\n * we find the array of casts associated with the type, and loop through it\n * adding the casts to the list. The one last trick we need to do is making\n * sure the type pointer in the swig_cast_info struct is correct.\n *\n * First off, we lookup the cast->type name to see if it is already loaded.\n * There are three cases to handle:\n *  1) If the cast->type has already been loaded AND the type we are adding\n *     casting info to has not been loaded (it is in this module), THEN we\n *     replace the cast->type pointer with the type pointer that has already\n *     been loaded.\n *  2) If BOTH types (the one we are adding casting info to, and the\n *     cast->type) are loaded, THEN the cast info has already been loaded by\n *     the previous module so we just ignore it.\n *  3) Finally, if cast->type has not already been loaded, then we add that\n *     swig_cast_info to the linked list (because the cast->type) pointer will\n *     be correct.\n * ----------------------------------------------------------------------------- */\n\n#ifdef __cplusplus\nextern \"C\" {\n#if 0\n} /* c-mode */\n#endif\n#endif\n\n#if 0\n#define SWIGRUNTIME_DEBUG\n#endif\n\n\nSWIGRUNTIME void\nSWIG_InitializeModule(void *clientdata) {\n  size_t i;\n  swig_module_info *module_head, *iter;\n  int found, init;\n  \n  /* check to see if the circular list has been setup, if not, set it up */\n  if (swig_module.next==0) {\n    /* Initialize the swig_module */\n    swig_module.type_initial = swig_type_initial;\n    swig_module.cast_initial = swig_cast_initial;\n    swig_module.next = &swig_module;\n    init = 1;\n  } else {\n    init = 0;\n  }\n  \n  /* Try and load any already created modules */\n  module_head = SWIG_GetModule(clientdata);\n  if (!module_head) {\n    /* This is the first module loaded for this interpreter */\n    /* so set the swig module into the interpreter */\n    SWIG_SetModule(clientdata, &swig_module);\n    module_head = &swig_module;\n  } else {\n    /* the interpreter has loaded a SWIG module, but has it loaded this one? */\n    found=0;\n    iter=module_head;\n    do {\n      if (iter==&swig_module) {\n        found=1;\n        break;\n      }\n      iter=iter->next;\n    } while (iter!= module_head);\n    \n    /* if the is found in the list, then all is done and we may leave */\n    if (found) return;\n    /* otherwise we must add out module into the list */\n    swig_module.next = module_head->next;\n    module_head->next = &swig_module;\n  }\n  \n  /* When multiple interpreters are used, a module could have already been initialized in\n       a different interpreter, but not yet have a pointer in this interpreter.\n       In this case, we do not want to continue adding types... everything should be\n       set up already */\n  if (init == 0) return;\n  \n  /* Now work on filling in swig_module.types */\n#ifdef SWIGRUNTIME_DEBUG\n  printf(\"SWIG_InitializeModule: size %d\\n\", swig_module.size);\n#endif\n  for (i = 0; i < swig_module.size; ++i) {\n    swig_type_info *type = 0;\n    swig_type_info *ret;\n    swig_cast_info *cast;\n    \n#ifdef SWIGRUNTIME_DEBUG\n    printf(\"SWIG_InitializeModule: type %d %s\\n\", i, swig_module.type_initial[i]->name);\n#endif\n    \n    /* if there is another module already loaded */\n    if (swig_module.next != &swig_module) {\n      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);\n    }\n    if (type) {\n      /* Overwrite clientdata field */\n#ifdef SWIGRUNTIME_DEBUG\n      printf(\"SWIG_InitializeModule: found type %s\\n\", type->name);\n#endif\n      if (swig_module.type_initial[i]->clientdata) {\n        type->clientdata = swig_module.type_initial[i]->clientdata;\n#ifdef SWIGRUNTIME_DEBUG\n        printf(\"SWIG_InitializeModule: found and overwrite type %s \\n\", type->name);\n#endif\n      }\n    } else {\n      type = swig_module.type_initial[i];\n    }\n    \n    /* Insert casting types */\n    cast = swig_module.cast_initial[i];\n    while (cast->type) {\n      /* Don't need to add information already in the list */\n      ret = 0;\n#ifdef SWIGRUNTIME_DEBUG\n      printf(\"SWIG_InitializeModule: look cast %s\\n\", cast->type->name);\n#endif\n      if (swig_module.next != &swig_module) {\n        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);\n#ifdef SWIGRUNTIME_DEBUG\n        if (ret) printf(\"SWIG_InitializeModule: found cast %s\\n\", ret->name);\n#endif\n      }\n      if (ret) {\n        if (type == swig_module.type_initial[i]) {\n#ifdef SWIGRUNTIME_DEBUG\n          printf(\"SWIG_InitializeModule: skip old type %s\\n\", ret->name);\n#endif\n          cast->type = ret;\n          ret = 0;\n        } else {\n          /* Check for casting already in the list */\n          swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);\n#ifdef SWIGRUNTIME_DEBUG\n          if (ocast) printf(\"SWIG_InitializeModule: skip old cast %s\\n\", ret->name);\n#endif\n          if (!ocast) ret = 0;\n        }\n      }\n      \n      if (!ret) {\n#ifdef SWIGRUNTIME_DEBUG\n        printf(\"SWIG_InitializeModule: adding cast %s\\n\", cast->type->name);\n#endif\n        if (type->cast) {\n          type->cast->prev = cast;\n          cast->next = type->cast;\n        }\n        type->cast = cast;\n      }\n      cast++;\n    }\n    /* Set entry in modules->types array equal to the type */\n    swig_module.types[i] = type;\n  }\n  swig_module.types[i] = 0;\n  \n#ifdef SWIGRUNTIME_DEBUG\n  printf(\"**** SWIG_InitializeModule: Cast List ******\\n\");\n  for (i = 0; i < swig_module.size; ++i) {\n    int j = 0;\n    swig_cast_info *cast = swig_module.cast_initial[i];\n    printf(\"SWIG_InitializeModule: type %d %s\\n\", i, swig_module.type_initial[i]->name);\n    while (cast->type) {\n      printf(\"SWIG_InitializeModule: cast type %s\\n\", cast->type->name);\n      cast++;\n      ++j;\n    }\n    printf(\"---- Total casts: %d\\n\",j);\n  }\n  printf(\"**** SWIG_InitializeModule: Cast List ******\\n\");\n#endif\n}\n\n/* This function will propagate the clientdata field of type to\n* any new swig_type_info structures that have been added into the list\n* of equivalent types.  It is like calling\n* SWIG_TypeClientData(type, clientdata) a second time.\n*/\nSWIGRUNTIME void\nSWIG_PropagateClientData(void) {\n  size_t i;\n  swig_cast_info *equiv;\n  static int init_run = 0;\n  \n  if (init_run) return;\n  init_run = 1;\n  \n  for (i = 0; i < swig_module.size; i++) {\n    if (swig_module.types[i]->clientdata) {\n      equiv = swig_module.types[i]->cast;\n      while (equiv) {\n        if (!equiv->converter) {\n          if (equiv->type && !equiv->type->clientdata)\n          SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);\n        }\n        equiv = equiv->next;\n      }\n    }\n  }\n}\n\n#ifdef __cplusplus\n#if 0\n{\n  /* c-mode */\n#endif\n}\n#endif\n\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n  \n  /* Python-specific SWIG API */\n#define SWIG_newvarlink()                             SWIG_Python_newvarlink()\n#define SWIG_addvarlink(p, name, get_attr, set_attr)  SWIG_Python_addvarlink(p, name, get_attr, set_attr)\n#define SWIG_InstallConstants(d, constants)           SWIG_Python_InstallConstants(d, constants)\n  \n  /* -----------------------------------------------------------------------------\n   * global variable support code.\n   * ----------------------------------------------------------------------------- */\n  \n  typedef struct swig_globalvar {\n    char       *name;                  /* Name of global variable */\n    PyObject *(*get_attr)(void);       /* Return the current value */\n    int       (*set_attr)(PyObject *); /* Set the value */\n    struct swig_globalvar *next;\n  } swig_globalvar;\n  \n  typedef struct swig_varlinkobject {\n    PyObject_HEAD\n    swig_globalvar *vars;\n  } swig_varlinkobject;\n  \n  SWIGINTERN PyObject *\n  swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {\n#if PY_VERSION_HEX >= 0x03000000\n    return PyUnicode_InternFromString(\"<Swig global variables>\");\n#else\n    return PyString_FromString(\"<Swig global variables>\");\n#endif\n  }\n  \n  SWIGINTERN PyObject *\n  swig_varlink_str(swig_varlinkobject *v) {\n#if PY_VERSION_HEX >= 0x03000000\n    PyObject *str = PyUnicode_InternFromString(\"(\");\n    PyObject *tail;\n    PyObject *joined;\n    swig_globalvar *var;\n    for (var = v->vars; var; var=var->next) {\n      tail = PyUnicode_FromString(var->name);\n      joined = PyUnicode_Concat(str, tail);\n      Py_DecRef(str);\n      Py_DecRef(tail);\n      str = joined;\n      if (var->next) {\n        tail = PyUnicode_InternFromString(\", \");\n        joined = PyUnicode_Concat(str, tail);\n        Py_DecRef(str);\n        Py_DecRef(tail);\n        str = joined;\n      }\n    }\n    tail = PyUnicode_InternFromString(\")\");\n    joined = PyUnicode_Concat(str, tail);\n    Py_DecRef(str);\n    Py_DecRef(tail);\n    str = joined;\n#else\n    PyObject *str = PyString_FromString(\"(\");\n    swig_globalvar *var;\n    for (var = v->vars; var; var=var->next) {\n      PyString_ConcatAndDel(&str,PyString_FromString(var->name));\n      if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(\", \"));\n    }\n    PyString_ConcatAndDel(&str,PyString_FromString(\")\"));\n#endif\n    return str;\n  }\n  \n  SWIGINTERN int\n  swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {\n    char *tmp;\n    PyObject *str = swig_varlink_str(v);\n    fprintf(fp,\"Swig global variables \");\n    fprintf(fp,\"%s\\n\", tmp = SWIG_Python_str_AsChar(str));\n    SWIG_Python_str_DelForPy3(tmp);\n    Py_DECREF(str);\n    return 0;\n  }\n  \n  SWIGINTERN void\n  swig_varlink_dealloc(swig_varlinkobject *v) {\n    swig_globalvar *var = v->vars;\n    while (var) {\n      swig_globalvar *n = var->next;\n      free(var->name);\n      free(var);\n      var = n;\n    }\n  }\n  \n  SWIGINTERN PyObject *\n  swig_varlink_getattr(swig_varlinkobject *v, char *n) {\n    PyObject *res = NULL;\n    swig_globalvar *var = v->vars;\n    while (var) {\n      if (strcmp(var->name,n) == 0) {\n        res = (*var->get_attr)();\n        break;\n      }\n      var = var->next;\n    }\n    if (res == NULL && !PyErr_Occurred()) {\n      PyErr_Format(PyExc_AttributeError, \"Unknown C global variable '%s'\", n);\n    }\n    return res;\n  }\n  \n  SWIGINTERN int\n  swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {\n    int res = 1;\n    swig_globalvar *var = v->vars;\n    while (var) {\n      if (strcmp(var->name,n) == 0) {\n        res = (*var->set_attr)(p);\n        break;\n      }\n      var = var->next;\n    }\n    if (res == 1 && !PyErr_Occurred()) {\n      PyErr_Format(PyExc_AttributeError, \"Unknown C global variable '%s'\", n);\n    }\n    return res;\n  }\n  \n  SWIGINTERN PyTypeObject*\n  swig_varlink_type(void) {\n    static char varlink__doc__[] = \"Swig var link object\";\n    static PyTypeObject varlink_type;\n    static int type_init = 0;\n    if (!type_init) {\n      const PyTypeObject tmp = {\n        /* PyObject header changed in Python 3 */\n#if PY_VERSION_HEX >= 0x03000000\n        PyVarObject_HEAD_INIT(NULL, 0)\n#else\n        PyObject_HEAD_INIT(NULL)\n        0,                                  /* ob_size */\n#endif\n        (char *)\"swigvarlink\",              /* tp_name */\n        sizeof(swig_varlinkobject),         /* tp_basicsize */\n        0,                                  /* tp_itemsize */\n        (destructor) swig_varlink_dealloc,  /* tp_dealloc */\n        (printfunc) swig_varlink_print,     /* tp_print */\n        (getattrfunc) swig_varlink_getattr, /* tp_getattr */\n        (setattrfunc) swig_varlink_setattr, /* tp_setattr */\n        0,                                  /* tp_compare */\n        (reprfunc) swig_varlink_repr,       /* tp_repr */\n        0,                                  /* tp_as_number */\n        0,                                  /* tp_as_sequence */\n        0,                                  /* tp_as_mapping */\n        0,                                  /* tp_hash */\n        0,                                  /* tp_call */\n        (reprfunc) swig_varlink_str,        /* tp_str */\n        0,                                  /* tp_getattro */\n        0,                                  /* tp_setattro */\n        0,                                  /* tp_as_buffer */\n        0,                                  /* tp_flags */\n        varlink__doc__,                     /* tp_doc */\n        0,                                  /* tp_traverse */\n        0,                                  /* tp_clear */\n        0,                                  /* tp_richcompare */\n        0,                                  /* tp_weaklistoffset */\n#if PY_VERSION_HEX >= 0x02020000\n        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */\n#endif\n#if PY_VERSION_HEX >= 0x02030000\n        0,                                  /* tp_del */\n#endif\n#if PY_VERSION_HEX >= 0x02060000\n        0,                                  /* tp_version */\n#endif\n#ifdef COUNT_ALLOCS\n        0,0,0,0                             /* tp_alloc -> tp_next */\n#endif\n      };\n      varlink_type = tmp;\n      type_init = 1;\n#if PY_VERSION_HEX < 0x02020000\n      varlink_type.ob_type = &PyType_Type;\n#else\n      if (PyType_Ready(&varlink_type) < 0)\n      return NULL;\n#endif\n    }\n    return &varlink_type;\n  }\n  \n  /* Create a variable linking object for use later */\n  SWIGINTERN PyObject *\n  SWIG_Python_newvarlink(void) {\n    swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());\n    if (result) {\n      result->vars = 0;\n    }\n    return ((PyObject*) result);\n  }\n  \n  SWIGINTERN void \n  SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {\n    swig_varlinkobject *v = (swig_varlinkobject *) p;\n    swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));\n    if (gv) {\n      size_t size = strlen(name)+1;\n      gv->name = (char *)malloc(size);\n      if (gv->name) {\n        strncpy(gv->name,name,size);\n        gv->get_attr = get_attr;\n        gv->set_attr = set_attr;\n        gv->next = v->vars;\n      }\n    }\n    v->vars = gv;\n  }\n  \n  SWIGINTERN PyObject *\n  SWIG_globals(void) {\n    static PyObject *_SWIG_globals = 0; \n    if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();  \n    return _SWIG_globals;\n  }\n  \n  /* -----------------------------------------------------------------------------\n   * constants/methods manipulation\n   * ----------------------------------------------------------------------------- */\n  \n  /* Install Constants */\n  SWIGINTERN void\n  SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {\n    PyObject *obj = 0;\n    size_t i;\n    for (i = 0; constants[i].type; ++i) {\n      switch(constants[i].type) {\n      case SWIG_PY_POINTER:\n        obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);\n        break;\n      case SWIG_PY_BINARY:\n        obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));\n        break;\n      default:\n        obj = 0;\n        break;\n      }\n      if (obj) {\n        PyDict_SetItemString(d, constants[i].name, obj);\n        Py_DECREF(obj);\n      }\n    }\n  }\n  \n  /* -----------------------------------------------------------------------------*/\n  /* Fix SwigMethods to carry the callback ptrs when needed */\n  /* -----------------------------------------------------------------------------*/\n  \n  SWIGINTERN void\n  SWIG_Python_FixMethods(PyMethodDef *methods,\n    swig_const_info *const_table,\n    swig_type_info **types,\n    swig_type_info **types_initial) {\n    size_t i;\n    for (i = 0; methods[i].ml_name; ++i) {\n      const char *c = methods[i].ml_doc;\n      if (c && (c = strstr(c, \"swig_ptr: \"))) {\n        int j;\n        swig_const_info *ci = 0;\n        const char *name = c + 10;\n        for (j = 0; const_table[j].type; ++j) {\n          if (strncmp(const_table[j].name, name, \n              strlen(const_table[j].name)) == 0) {\n            ci = &(const_table[j]);\n            break;\n          }\n        }\n        if (ci) {\n          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;\n          if (ptr) {\n            size_t shift = (ci->ptype) - types;\n            swig_type_info *ty = types_initial[shift];\n            size_t ldoc = (c - methods[i].ml_doc);\n            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;\n            char *ndoc = (char*)malloc(ldoc + lptr + 10);\n            if (ndoc) {\n              char *buff = ndoc;\n              strncpy(buff, methods[i].ml_doc, ldoc);\n              buff += ldoc;\n              strncpy(buff, \"swig_ptr: \", 10);\n              buff += 10;\n              SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);\n              methods[i].ml_doc = ndoc;\n            }\n          }\n        }\n      }\n    }\n  } \n  \n#ifdef __cplusplus\n}\n#endif\n\n/* -----------------------------------------------------------------------------*\n *  Partial Init method\n * -----------------------------------------------------------------------------*/\n\n#ifdef __cplusplus\nextern \"C\"\n#endif\n\nSWIGEXPORT \n#if PY_VERSION_HEX >= 0x03000000\nPyObject*\n#else\nvoid\n#endif\nSWIG_init(void) {\n  PyObject *m, *d, *md;\n#if PY_VERSION_HEX >= 0x03000000\n  static struct PyModuleDef SWIG_module = {\n# if PY_VERSION_HEX >= 0x03020000\n    PyModuleDef_HEAD_INIT,\n# else\n    {\n      PyObject_HEAD_INIT(NULL)\n      NULL, /* m_init */\n      0,    /* m_index */\n      NULL, /* m_copy */\n    },\n# endif\n    (char *) SWIG_name,\n    NULL,\n    -1,\n    SwigMethods,\n    NULL,\n    NULL,\n    NULL,\n    NULL\n  };\n#endif\n  \n#if defined(SWIGPYTHON_BUILTIN)\n  static SwigPyClientData SwigPyObject_clientdata = {\n    0, 0, 0, 0, 0, 0, 0\n  };\n  static PyGetSetDef this_getset_def = {\n    (char *)\"this\", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL\n  };\n  static SwigPyGetSet thisown_getset_closure = {\n    (PyCFunction) SwigPyObject_own,\n    (PyCFunction) SwigPyObject_own\n  };\n  static PyGetSetDef thisown_getset_def = {\n    (char *)\"thisown\", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure\n  };\n  PyObject *metatype_args;\n  PyTypeObject *builtin_pytype;\n  int builtin_base_count;\n  swig_type_info *builtin_basetype;\n  PyObject *tuple;\n  PyGetSetDescrObject *static_getset;\n  PyTypeObject *metatype;\n  SwigPyClientData *cd;\n  PyObject *public_interface, *public_symbol;\n  PyObject *this_descr;\n  PyObject *thisown_descr;\n  int i;\n  \n  (void)builtin_pytype;\n  (void)builtin_base_count;\n  (void)builtin_basetype;\n  (void)tuple;\n  (void)static_getset;\n  \n  /* metatype is used to implement static member variables. */\n  metatype_args = Py_BuildValue(\"(s(O){})\", \"SwigPyObjectType\", &PyType_Type);\n  assert(metatype_args);\n  metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL);\n  assert(metatype);\n  Py_DECREF(metatype_args);\n  metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro;\n  assert(PyType_Ready(metatype) >= 0);\n#endif\n  \n  /* Fix SwigMethods to carry the callback ptrs when needed */\n  SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);\n  \n#if PY_VERSION_HEX >= 0x03000000\n  m = PyModule_Create(&SWIG_module);\n#else\n  m = Py_InitModule((char *) SWIG_name, SwigMethods);\n#endif\n  md = d = PyModule_GetDict(m);\n  (void)md;\n  \n  SWIG_InitializeModule(0);\n  \n#ifdef SWIGPYTHON_BUILTIN\n  SwigPyObject_stype = SWIG_MangledTypeQuery(\"_p_SwigPyObject\");\n  assert(SwigPyObject_stype);\n  cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;\n  if (!cd) {\n    SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;\n    SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce();\n  } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) {\n    PyErr_SetString(PyExc_RuntimeError, \"Import error: attempted to load two incompatible swig-generated modules.\");\n# if PY_VERSION_HEX >= 0x03000000\n    return NULL;\n# else\n    return;\n# endif\n  }\n  \n  /* All objects have a 'this' attribute */\n  this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);\n  (void)this_descr;\n  \n  /* All objects have a 'thisown' attribute */\n  thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);\n  (void)thisown_descr;\n  \n  public_interface = PyList_New(0);\n  public_symbol = 0;\n  (void)public_symbol;\n  \n  PyDict_SetItemString(md, \"__all__\", public_interface);\n  Py_DECREF(public_interface);\n  for (i = 0; SwigMethods[i].ml_name != NULL; ++i)\n  SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);\n  for (i = 0; swig_const_table[i].name != 0; ++i)\n  SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);\n#endif\n  \n  SWIG_InstallConstants(d,swig_const_table);\n  \n#if PY_VERSION_HEX >= 0x03000000\n  return m;\n#else\n  return;\n#endif\n}\n\n"
  },
  {
    "path": "library_c/lib/blinkt.c",
    "content": "#include <bcm2835.h>\n#include <stdint.h>\n#include <stdio.h>\n#include <string.h>\n#include <linux/types.h>\n#include <signal.h>\n#include <unistd.h>\n#include \"blinkt.h\"\n\n#define APA_SOF 0b11100000\n\n#define DEFAULT_BRIGHTNESS 7\n#define NUM_LEDS 8\n\n#define MOSI 23\n#define SCLK 24\n\n#ifdef TEST\nvolatile int running = 0;\n#endif\n\nint x;\n\nuint32_t leds[NUM_LEDS] = {};\n\n#ifdef TEST\nvoid sigint_handler(int dummy){\n\trunning = 0;\n\treturn;\n}\n#endif\n\nvoid clear(){\n\tfor(x = 0; x < NUM_LEDS; x++){\n\t\tleds[x] = DEFAULT_BRIGHTNESS;\n\t}\t\n}\n\nvoid set_pixel(uint8_t led, uint8_t r, uint8_t g, uint8_t b){\n\tif(led >= NUM_LEDS) return;\n\n\tleds[led] = rgbb(r,g,b,leds[led] & 0b11111);\n}\n\nvoid set_pixel_brightness(uint8_t led, uint8_t brightness){\n\tif(led >= NUM_LEDS) return;\n\t\n\tleds[led] = (leds[led] & 0xFFFFFF00) | (brightness & 0b11111);\n}\n\nvoid set_pixel_uint32(uint8_t led, uint32_t color){\n\tif(led >= NUM_LEDS) return;\n\n\tleds[led] = color;\n}\n\nuint32_t rgbb(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness){\n\tuint32_t result = 0;\n\tresult = (brightness & 0b11111);\n\tresult |= ((uint32_t)r << 24);\n\tresult |= ((uint32_t)g << 16);\n\tresult |= ((uint16_t)b << 8);\n\treturn result;\n}\n\nuint32_t rgb(uint8_t r, uint8_t g, uint8_t b){\n\treturn rgbb(r, g, b, DEFAULT_BRIGHTNESS);\n}\n\ninline static void write_byte(uint8_t byte){\n\tint n;\n\tfor(n = 0; n < 8; n++){\n\t\tbcm2835_gpio_write(MOSI, (byte & (1 << (7-n))) > 0);\n\t\tbcm2835_gpio_write(SCLK, HIGH);\n\t\tbcm2835_gpio_write(SCLK, LOW);\n\t}\n\n}\n\nvoid show(void){\n\twrite_byte(0);\n\twrite_byte(0);\n\twrite_byte(0);\n\twrite_byte(0);\n\tfor(x = 0; x < NUM_LEDS; x++){\n\t\twrite_byte(APA_SOF | (leds[x] & 0b11111));\n\t\twrite_byte((leds[x] >> 8 ) & 0xFF);\n\t\twrite_byte((leds[x] >> 16) & 0xFF);\n\t\twrite_byte((leds[x] >> 24) & 0xFF);\n\t}\n\twrite_byte(0xff);\n\t//write_byte(0xff);\n\t//write_byte(0xff);\n\t//write_byte(0xff);\n}\n\nvoid stop(void){\n\tbcm2835_spi_end();\n\n\tbcm2835_close();\n}\n\n\nint start(void){\n\n\tif(!bcm2835_init()) return 1;\n\n#ifdef TEST\n\tprintf(\"GPIO Initialized\\n\");\n#endif\n\n\tbcm2835_gpio_fsel(MOSI, BCM2835_GPIO_FSEL_OUTP);\n\tbcm2835_gpio_write(MOSI, LOW);\n\tbcm2835_gpio_fsel(SCLK, BCM2835_GPIO_FSEL_OUTP);\n\tbcm2835_gpio_write(SCLK, LOW);\n\n\tclear();\n\n\treturn 0;\n\n}\n\n#ifdef TEST\nint main(){\n\n\tint z;\n\tint y = 0;\n\n\trunning = 1;\n\n\tsignal(SIGINT, sigint_handler);\n\n\tif (start()){\n\t\tprintf(\"Unable to start apa102\\n\");\n\t\treturn 1;\n\t}\n\n\tprintf(\"Running test cycle\\n\");\n\n\tint col = 0;\n\n\twhile(running){\n\n\t\tfor(z = 0; z < NUM_LEDS; z++){\t\t\n\t\t\tswitch(col){\n\t\t\t\tcase 0: set_pixel_uint32(z, rgb(y,0,0)); break;\n\t\t\t\tcase 1: set_pixel_uint32(z, rgb(0,y,0)); break;\n\t\t\t\tcase 2: set_pixel_uint32(z, rgb(0,0,y)); break;\n\t\t\t}\n\t\t}\n\n\t\tshow();\n\n\t\tusleep(1000);\n\n\t\ty+=1;\n                if(y>254) col++;\n                col%=3;\n\t\ty%=255;\n\n\t}\n\n\n\tclear();\n\n\tusleep(1000);\n\n\tstop();\n\n\treturn 0;\n\n}\n#endif\n"
  },
  {
    "path": "library_c/lib/blinkt.h",
    "content": "void clear(void);\nvoid set_pixel_uint32(uint8_t led, uint32_t color);\nvoid set_pixel(uint8_t led, uint8_t r, uint8_t g, uint8_t b);\nvoid set_pixel_brightness(uint8_t led, uint8_t brightness);\nuint32_t rgbb(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness);\nuint32_t rgb(uint8_t r, uint8_t g, uint8_t b);\nvoid stop(void);\nint start(void);\nvoid show(void);\n"
  },
  {
    "path": "library_c/setup.py",
    "content": "#!/usr/bin/env python\n\nfrom setuptools import setup, find_packages, Extension\n\n_blinkt = Extension(\n\t'_blinkt',\n\tinclude_dirs=['lib'],\n\tlibraries=['bcm2835'],\n\tsources=['lib/blinkt.c','blinkt_wrap.c']\n)\n\nsetup(\n\tname = 'blinkt_c',\n\tversion = '0.0.1',\n\tauthor = \"Philip Howard\",\n\tauthor_email = \"phil@pimoroni.com\",\n\turl = \"\",\n\tdescription = \"\",\n\tlong_description = \"\",\n\text_modules = [ _blinkt ],\n\tpy_modules = [\"blinkt\"],\n\tinstall_requires = [],\n\theaders=['lib/blinkt.h']\n)\n"
  },
  {
    "path": "packaging/CHANGELOG",
    "content": "blinkt (0.1.2) STABLE; urgency=low\n\n  * BugFix: Added sleep to data output, see: https://github.com/pimoroni/blinkt/issues/62\n\n -- Phil Howard <phil@pimoroni.com>  Wed, 23 May 2018 00:00:00 +0000\n\nblinkt (0.1.1) STABLE; urgency=low\n\n  * New: Added `get_pixel` to return colour and brightness of a single pixel\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 20 Feb 2018 00:00:00 +0000\n\nblinkt (0.1.0) STABLE; urgency=low\n\n  * Removed try/except from RPi.GPIO import, output was misleading at best\n  * Reverted default behaviour of clear on exit\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 06 Sep 2016 00:00:00 +0000\n\nblinkt (0.0.9) UNRELEASED; urgency=low\n\n  * Added set_all method to set all pixels\n  * Changed default behaviour of clear on exit to reduce module side-effects\n  * Move GPIO initialisation to show() to reduce module side-effects\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 06 Sep 2016 00:00:00 +0000\n\nblinkt (0.0.8) UNRELEASED; urgency=low\n\n  * Tweaked some methods to show intent as implementation detail only\n  * Added docstrings detailing public methods\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 06 Sep 2016 00:00:00 +0000\n\nblinkt (0.0.7) UNRELEASED; urgency=low\n\n  * Fixed bug with APA102 pixels that have a small, black die (vs the larger, paler one)\n\n -- Phil Howard <phil@pimoroni.com>  Wed, 24 Aug 2016 00:00:00 +0000\n\nblinkt (0.0.6) UNRELEASED; urgency=low\n\n  * set_clear_on_exit now method\n\n -- Phil Howard <phil@pimoroni.com>  Thu, 11 Aug 2016 00:00:00 +0000\n\nblinkt (0.0.5) UNRELEASED; urgency=low\n\n  * Range clamping and coercion to integers\n\n -- Phil Howard <phil@pimoroni.com>  Wed, 22 Jun 2016 00:00:00 +0000\n\nblinkt (0.0.4) UNRELEASED; urgency=low\n\n  * Various bug fixes\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 18:00:00 +0000\n\nblinkt (0.0.3) UNRELEASED; urgency=low\n\n  * Switch to Python\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 12:00:00 +0000\n\nblinkt (0.0.2) UNRELEASED; urgency=low\n\n  * Bug fixes for C Library\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 06:00:00 +0000\n\nblinkt (0.0.1) UNRELEASED; urgency=low\n\n  * Original C Library\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 00:00:00 +0000\n"
  },
  {
    "path": "packaging/debian/README",
    "content": "README\n\nBlinkt! provides eight super-bright RGB LED indicators. Ideal for adding visual notifications to your Raspberry Pi.\n\nLearn more: https://shop.pimoroni.com/products/blinkt\nFor examples run: `curl -sS get.pimoroni.com/blinkt | bash`\n"
  },
  {
    "path": "packaging/debian/changelog",
    "content": "blinkt (0.1.2) STABLE; urgency=low\n\n  * BugFix: Added sleep to data output, see: https://github.com/pimoroni/blinkt/issues/62\n\n -- Phil Howard <phil@pimoroni.com>  Wed, 23 May 2018 00:00:00 +0000\n\nblinkt (0.1.1) STABLE; urgency=low\n\n  * New: Added `get_pixel` to return colour and brightness of a single pixel\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 20 Feb 2018 00:00:00 +0000\n\nblinkt (0.1.0) STABLE; urgency=low\n\n  * Removed try/except from RPi.GPIO import, output was misleading at best\n  * Reverted default behaviour of clear on exit\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 06 Sep 2016 00:00:00 +0000\n\nblinkt (0.0.9) UNRELEASED; urgency=low\n\n  * Added set_all method to set all pixels\n  * Changed default behaviour of clear on exit to reduce module side-effects\n  * Move GPIO initialisation to show() to reduce module side-effects\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 06 Sep 2016 00:00:00 +0000\n\nblinkt (0.0.8) UNRELEASED; urgency=low\n\n  * Tweaked some methods to show intent as implementation detail only\n  * Added docstrings detailing public methods\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 06 Sep 2016 00:00:00 +0000\n\nblinkt (0.0.7) UNRELEASED; urgency=low\n\n  * Fixed bug with APA102 pixels that have a small, black die (vs the larger, paler one)\n\n -- Phil Howard <phil@pimoroni.com>  Wed, 24 Aug 2016 00:00:00 +0000\n\nblinkt (0.0.6) UNRELEASED; urgency=low\n\n  * set_clear_on_exit now method\n\n -- Phil Howard <phil@pimoroni.com>  Thu, 11 Aug 2016 00:00:00 +0000\n\nblinkt (0.0.5) UNRELEASED; urgency=low\n\n  * Range clamping and coercion to integers\n\n -- Phil Howard <phil@pimoroni.com>  Wed, 22 Jun 2016 00:00:00 +0000\n\nblinkt (0.0.4) UNRELEASED; urgency=low\n\n  * Various bug fixes\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 18:00:00 +0000\n\nblinkt (0.0.3) UNRELEASED; urgency=low\n\n  * Switch to Python\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 12:00:00 +0000\n\nblinkt (0.0.2) UNRELEASED; urgency=low\n\n  * Bug fixes for C Library\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 06:00:00 +0000\n\nblinkt (0.0.1) UNRELEASED; urgency=low\n\n  * Original C Library\n\n -- Phil Howard <phil@pimoroni.com>  Tue, 21 Jun 2016 00:00:00 +0000\n"
  },
  {
    "path": "packaging/debian/clean",
    "content": "*.egg-info/*\n"
  },
  {
    "path": "packaging/debian/compat",
    "content": "9\n"
  },
  {
    "path": "packaging/debian/control",
    "content": "Source: blinkt\nMaintainer: Phil Howard <phil@pimoroni.com>\nHomepage: https://github.com/pimoroni/blinkt\nSection: python\nPriority: extra\nBuild-Depends: debhelper (>= 9.0.0), dh-python, python-all (>= 2.7), python-setuptools, python3-all (>= 3.4), python3-setuptools\nStandards-Version: 3.9.6\nX-Python-Version: >= 2.7\nX-Python3-Version: >= 3.4\n\nPackage: python-blinkt\nArchitecture: all\nSection: python\nDepends: ${misc:Depends}, ${python:Depends}, python-rpi.gpio\nSuggests: python-psutil, python-requests\nDescription: Python library for the Pimoroni Blinkt!\n Blinkt! provides eight super-bright RGB LED indicators.\n Ideal for adding visual notifications to your Raspberry Pi.\n .\n This is the Python 2 version of the package.\n\nPackage: python3-blinkt\nArchitecture: all\nSection: python\nDepends: ${misc:Depends}, ${python3:Depends}, python3-rpi.gpio\nSuggests: python3-psutil, python3-requests\nDescription: Python library for the Pimoroni Blinkt!\n Blinkt! provides eight super-bright RGB LED indicators.\n Ideal for adding visual notifications to your Raspberry Pi.\n .\n This is the Python 3 version of the package.\n"
  },
  {
    "path": "packaging/debian/copyright",
    "content": "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\nUpstream-Name: blinkt\nSource: https://github.com/pimoroni/blinkt\n\nFiles: *\nCopyright: 2016 Pimoroni Ltd <phil@pimoroni.com>\nLicense: MIT\n\nLicense: MIT\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n .\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n .\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n"
  },
  {
    "path": "packaging/debian/docs",
    "content": ""
  },
  {
    "path": "packaging/debian/rules",
    "content": "#!/usr/bin/make -f\n# -*- makefile -*-\n\n#export DH_VERBOSE=1\nexport DH_OPTIONS\n\n%:\n\tdh $@ --with python2,python3 --buildsystem=python_distutils\n\noverride_dh_auto_install:\n\tpython setup.py install --root debian/python-blinkt --install-layout=deb\n\tpython3 setup.py install --root debian/python3-blinkt --install-layout=deb\n"
  },
  {
    "path": "packaging/debian/source/format",
    "content": "3.0 (native)\n"
  },
  {
    "path": "packaging/debian/source/options",
    "content": "extend-diff-ignore = \"^[^/]+\\.egg-info/\"\n"
  },
  {
    "path": "packaging/makeall.sh",
    "content": "#!/bin/bash\n\n# script control variables\n\nreponame=\"\" # leave this blank for auto-detection\nlibname=\"\" # leave this blank for auto-detection\npackagename=\"\" # leave this blank for auto-selection\n\ndebianlog=\"debian/changelog\"\ndebcontrol=\"debian/control\"\ndebcopyright=\"debian/copyright\"\ndebrules=\"debian/rules\"\ndebreadme=\"debian/README\"\n\ndebdir=\"$(pwd)\"\nrootdir=\"$(dirname $debdir)\"\nlibdir=\"$rootdir/library\"\n\nFLAG=false\n\n# function define\n\nsuccess() {\n    echo \"$(tput setaf 2)$1$(tput sgr0)\"\n}\n\ninform() {\n    echo \"$(tput setaf 6)$1$(tput sgr0)\"\n}\n\nwarning() {\n    echo \"$(tput setaf 1)$1$(tput sgr0)\"\n}\n\nnewline() {\n    echo \"\"\n}\n\n# assessing repo and library variables\n\nif [ -z \"$reponame\" ] || [ -z \"$libname\" ]; then\n    inform \"detecting reponame and libname...\"\nelse\n    inform \"using reponame and libname overrides\"\nfi\n\nif [ -z \"$reponame\" ]; then\n    if [[ $rootdir == *\"python\"* ]]; then\n        repodir=\"$(dirname $rootdir)\"\n        reponame=\"$(basename $repodir)\"\n    else\n        repodir=\"$rootdir\"\n        reponame=\"$(basename $repodir)\"\n    fi\n    reponame=$(echo \"$reponame\" | tr \"[A-Z]\" \"[a-z]\")\nfi\n\nif [ -z \"$libname\" ]; then\n    cd \"$libdir\"\n    libname=$(grep \"name\" setup.py | tr -d \"[:space:]\" | cut -c 7- | rev | cut -c 3- | rev)\n    libname=$(echo \"$libname\" | tr \"[A-Z]\" \"[a-z]\") && cd \"$debdir\"\nfi\n\nif [ -z \"$packagename\" ]; then\n    packagename=\"$libname\"\nfi\n\necho \"reponame is $reponame and libname is $libname\"\necho \"output packages will be python-$packagename and python3-$packagename\"\n\n# checking generating changelog file\n\n./makelog.sh\nversion=$(head -n 1 \"$libdir/CHANGELOG.txt\")\necho \"building $libname version $version\"\n\n# checking debian/changelog file\n\ninform \"checking debian/changelog file...\"\n\nif ! head -n 1 $debianlog | grep \"$libname\" &> /dev/null; then\n    warning \"library not mentioned in header!\" && FLAG=true\nelif head -n 1 $debianlog | grep \"UNRELEASED\"; then\n    warning \"this changelog is not going to generate a release!\"\n    warning \"change distribution to 'stable'\" && FLAG=true\nfi\n\n# checking debian/copyright file\n\ninform \"checking debian/copyright file...\"\n\nif ! grep \"^Source\" $debcopyright | grep \"$reponame\" &> /dev/null; then\n    warning \"$(grep \"^Source\" $debcopyright)\" && FLAG=true\nfi\n\nif ! grep \"^Upstream-Name\" $debcopyright | grep \"$libname\" &> /dev/null; then\n    warning \"$(grep \"^Upstream-Name\" $debcopyright)\" && FLAG=true\nfi\n\n# checking debian/control file\n\ninform \"checking debian/control file...\"\n\nif ! grep \"^Source\" $debcontrol | grep \"$libname\" &> /dev/null; then\n    warning \"$(grep \"^Source\" $debcontrol)\" && FLAG=true\nfi\n\nif ! grep \"^Homepage\" $debcontrol | grep \"$reponame\" &> /dev/null; then\n    warning \"$(grep \"^Homepage\" $debcontrol)\" && FLAG=true\nfi\n\nif ! grep \"^Package: python-$packagename\" $debcontrol &> /dev/null; then\n    warning \"$(grep \"^Package: python-\" $debcontrol)\" && FLAG=true\nfi\n\nif ! grep \"^Package: python3-$packagename\" $debcontrol &> /dev/null; then\n    warning \"$(grep \"^Package: python3-\" $debcontrol)\" && FLAG=true\nfi\n\nif ! grep \"^Priority: extra\" $debcontrol &> /dev/null; then\n    warning \"$(grep \"^Priority\" $debcontrol)\" && FLAG=true\nfi\n\n\n# checking debian/rules file\n\ninform \"checking debian/rules file...\"\n\nif ! grep \"debian/python-$packagename\" $debrules &> /dev/null; then\n    warning \"$(grep \"debian/python-\" $debrules)\" && FLAG=true\nfi\n\nif ! grep \"debian/python3-$packagename\" $debrules &> /dev/null; then\n    warning \"$(grep \"debian/python3-\" $debrules)\" && FLAG=true\nfi\n\n# checking debian/README file\n\ninform \"checking debian/readme file...\"\n\nif ! grep -e \"$libname\" -e \"$reponame\" $debreadme &> /dev/null; then\n    warning \"README does not seem to mention product, repo or lib!\" && FLAG=true\nfi\n\n# summary of checks pre build\n\nif $FLAG; then\n    warning \"Check all of the above and correct!\" && exit 1\nelse\n    inform \"we're good to go... bulding!\"\nfi\n\n# building deb and final checks\n\n./makedeb.sh\n\ninform \"running lintian...\"\nlintian -v $(find -name \"python*$version*.deb\")\nlintian -v $(find -name \"python3*$version*.deb\")\n\ninform \"checking signatures...\"\ngpg --verify $(find -name \"*$version*changes\")\ngpg --verify $(find -name \"*$version*dsc\")\n\nexit 0\n"
  },
  {
    "path": "packaging/makedeb.sh",
    "content": "#!/bin/bash\n\ngettools=\"no\" # if set to yes downloads the tools required\nsetup=\"yes\" # if set to yes populates library folder\nbuildeb=\"yes\" # if set to yes builds the deb files\ncleanup=\"yes\" # if set to yes cleans up build files\npkgfiles=( \"build\" \"changes\" \"deb\" \"dsc\" \"tar.xz\" )\n\nif [ $gettools == \"yes\" ]; then\n    sudo apt-get update && sudo apt-get install build-essential debhelper devscripts dh-make dh-python dput gnupg\n    sudo apt-get install python-all python-setuptools python3-all python3-setuptools\n    sudo apt-get install python-mock python-sphinx python-sphinx-rtd-theme\n    sudo pip install Sphinx --upgrade && sudo pip install sphinx_rtd_theme --upgrade\nfi\n\nif [ $setup == \"yes\" ]; then\n    rm -R ../library/build ../library/debian &> /dev/null\n    cp -R ./debian ../library/ && cp -R ../sphinx ../library/doc\nfi\n\ncd ../library\n\nif [ $buildeb == \"yes\" ]; then\n    debuild -aarmhf\n    for file in ${pkgfiles[@]}; do\n        rm ../packaging/*.$file &> /dev/null\n        mv ../*.$file ../packaging\n    done\n    rm -R ../documentation/html &> /dev/null\n    cp -R ./build/sphinx/html ../documentation\nfi\n\nif [ $cleanup == \"yes\" ]; then\n    debuild clean\n    rm -R ./build ./debian ./doc &> /dev/null\nfi\n\nexit 0\n"
  },
  {
    "path": "packaging/makedoc.sh",
    "content": "#!/bin/bash\n\ngettools=\"no\" # if set to yes downloads the tools required\nsetup=\"yes\" # if set to yes populates library folder\nbuildoc=\"yes\" # if set to yes builds the deb files\ncleanup=\"yes\" # if set to yes cleans up build files\npkgfiles=( \"build\" \"changes\" \"deb\" \"dsc\" \"tar.xz\" )\n\nif [ $gettools == \"yes\" ]; then\n    sudo apt-get update && sudo apt-get install build-essential debhelper devscripts dh-make dh-python\n    sudo apt-get install python-all python-setuptools python3-all python3-setuptools\n    sudo apt-get install python-mock python-sphinx python-sphinx-rtd-theme\n    sudo pip install Sphinx --upgrade && sudo pip install sphinx_rtd_theme --upgrade\nfi\n\nif [ $setup == \"yes\" ]; then\n    rm -R ../library/build ../library/debian &> /dev/null\n    cp -R ./debian ../library/ && cp -R ../sphinx ../library/doc\nfi\n\ncd ../library\n\nif [ $buildoc == \"yes\" ]; then\n    debuild\n    for file in ${pkgfiles[@]}; do\n        rm ../*.$file &> /dev/null\n    done\n    rm -R ../documentation/html &> /dev/null\n    cp -R ./build/sphinx/html ../documentation\nfi\n\nif [ $cleanup == \"yes\" ]; then\n    debuild clean\n    rm -R ./build ./debian ./doc &> /dev/null\nfi\n\nexit 0\n"
  },
  {
    "path": "packaging/makelog.sh",
    "content": "#!/bin/bash\n\n# script control variables\n\nlibname=\"\" # leave this blank for auto-detection\nsibname=() # name of sibling in packages list\nversionwarn=\"yes\" # set to anything but 'yes' to turn off warning\n\ndebdir=\"$(pwd)\"\nrootdir=\"$(dirname $debdir)\"\nlibdir=\"$rootdir/library\"\n\nmainlog=\"CHANGELOG\"\ndebianlog=\"debian/changelog\"\npypilog=\"$libdir/CHANGELOG.txt\"\n\n# function define\n\nsuccess() {\n    echo \"$(tput setaf 2)$1$(tput sgr0)\"\n}\n\ninform() {\n    echo \"$(tput setaf 6)$1$(tput sgr0)\"\n}\n\nwarning() {\n    echo \"$(tput setaf 1)$1$(tput sgr0)\"\n}\n\nnewline() {\n    echo \"\"\n}\n\n# generate debian changelog\n\ncat $mainlog > $debianlog\ninform \"seeded debian changelog\"\n\n# generate pypi changelog\n\nsed -e \"/--/d\" -e \"s/  \\*/\\*/\" \\\n    -e \"s/.*\\([0-9].[0-9].[0-9]\\).*/\\1/\" \\\n    -e '/[0-9].[0-9].[0-9]/ a\\\n-----' $mainlog | cat -s > $pypilog\n\nversion=$(head -n 1 $pypilog)\ninform \"pypi changelog generated\"\n\n# touch up version in setup.py file\n\nif [ -n $(grep version \"$libdir/setup.py\" &> /dev/null) ]; then\n    inform \"touched up version in setup.py\"\n    sed -i \"s/'[0-9].[0-9].[0-9]'/'$version'/\" \"$libdir/setup.py\"\nelse\n    warning \"couldn't touch up version in setup, no match found\"\nfi\n\n# touch up version in lib or package siblings\n\nif [ -z \"$libname\" ]; then\n    cd \"$libdir\"\n    libname=$(grep \"name\" setup.py | tr -d \"[:space:]\" | cut -c 7- | rev | cut -c 3- | rev)\n    libname=$(echo \"$libname\" | tr \"[A-Z]\" \"[a-z]\") && cd \"$debdir\"\n    sibname+=( \"$libname\" )\nelif [ \"$libname\" != \"package\" ]; then\n    sibname+=( \"$libname\" )\nfi\n\nfor sibling in ${sibname[@]}; do\n    if grep -e \"__version__\" \"$libdir/$sibling.py\" &> /dev/null; then\n        sed -i \"s/__version__ = '[0-9].[0-9].[0-9]'/__version__ = '$version'/\" \"$libdir/$sibling.py\"\n        inform \"touched up version in $sibling.py\"\n    elif grep -e \"__version__\" \"$libdir/$sibling/__init__.py\" &> /dev/null; then\n        sed -i \"s/__version__ = '[0-9].[0-9].[0-9]'/__version__ = '$version'/\" \"$libdir/$sibling/__init__.py\"\n        inform \"touched up version in $sibling/__init__.py\"\n    elif [ \"$versionwarn\" == \"yes\" ]; then\n        warning \"couldn't touch up __version__ in $sibling, no match found\"\n    fi\ndone\n\nexit 0\n"
  },
  {
    "path": "projects/mqtt/mqtt.py",
    "content": "#!/usr/bin/env python\n\nfrom sys import exit\nimport argparse\nimport time\n\ntry:\n    import paho.mqtt.client as mqtt\nexcept ImportError:\n    raise ImportError(\"This example requires the paho-mqtt module\\nInstall with: sudo pip install paho-mqtt\")\n\nimport blinkt\n\n\nMQTT_SERVER = \"localhost\"\nMQTT_PORT = 1883\nMQTT_TOPIC = \"pimoroni/blinkt\"\n\n# Set these to use authorisation\nMQTT_USER = None\nMQTT_PASS = None\n\ndescription = \"\"\"\\\nMQTT Blinkt! Control\n\nThis example uses MQTT messages from {server} on port {port} to control Blinkt!\n\nIt will monitor the {topic} topic by default, and understands the following messages:\n\nrgb,<pixel>,<r>,<g>,<b> - Set a single pixel to an RGB colour. Example: rgb,1,255,0,255\nclr - Clear Blinkt!\nbri,<val> - Set global brightness (for val in range 0.0-1.0)\n\nYou can use the online MQTT tester at http://www.hivemq.com/demos/websocket-client/ to send messages.\n\nUse {server} as the host, and port 80 (Eclipse's websocket port). Set the topic to topic: {topic}\n\"\"\".format(\n    server=MQTT_SERVER,\n    port=MQTT_PORT,\n    topic=MQTT_TOPIC\n)\nparser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter)\nparser.add_argument('-H', '--host', default=MQTT_SERVER,\n                    help='MQTT broker to connect to')\nparser.add_argument('-P', '--port', default=MQTT_PORT, type=int,\n                    help='port on MQTT broker to connect to')\nparser.add_argument('-T', '--topic', action='append',\n                    help='MQTT topic to subscribe to; can be repeated for multiple topics')\nparser.add_argument('-u', '--user',\n                    help='MQTT broker user name')\nparser.add_argument('-p', '--pass', dest='pw',\n                    help='MQTT broker password')\nparser.add_argument('-q', '--quiet', default=False, action='store_true',\n                    help='Minimal output (eg for running as a daemon)')\nparser.add_argument('-g', '--green-hack', default=False, action='store_true',\n                    help='Apply hack to green channel to improve colour saturation')\nparser.add_argument('--timeout', default='0',\n                    help='Pixel timeout(s).  Pixel will blank if last update older than X seconds. May be a single number or comma-separated list. Use 0 for no timeout')\nparser.add_argument('-D', '--daemon', metavar='PIDFILE',\n                    help='Run as a daemon (implies -q)')\n\nargs = parser.parse_args()\n\n# Get timeout list into expected form\nargs.timeout = args.timeout.split(',')\n\nif len(args.timeout) == 1:\n    args.timeout = args.timeout * blinkt.NUM_PIXELS\nelif len(args.timeout) != blinkt.NUM_PIXELS:\n    print(\"--timeout list must be {} elements long\".format(blinkt.NUM_PIXELS))\n    exit(1)\n\ntry:\n    args.timeout = [int(x) for x in args.timeout]\nexcept ValueError as e:\n    print(\"Bad timeout value: {}\".format(e))\n    exit(1)\n\nargs.timeout = [x and x or 0 for x in args.timeout]\nargs.min_timeout = min(args.timeout)\n\nif args.daemon:\n    import signal\n    try:\n        import daemon\n    except ImportError:\n        raise ImportError(\"--daemon requires the daemon module.  Install with: sudo pip install python-daemon\")\n    try:\n        import lockfile.pidlockfile\n    except ImportError:\n        raise ImportError(\"--daemon requires the lockfile module.  Install with: sudo pip install lockfile\")\n\nif not args.topic:\n    args.topic = [MQTT_TOPIC]\n\n\nclass PixelClient(mqtt.Client):\n    def __init__(self, prog_args, *args, **kwargs):\n        super(PixelClient, self).__init__(*args, **kwargs)\n        self.args = prog_args\n        self.update_time = [None] * blinkt.NUM_PIXELS\n        self.on_connect = self.on_connect\n        self.on_message = self.on_message\n\n        blinkt.set_clear_on_exit()\n        # Some stuff doesn't get set up until the first time show() is called\n        blinkt.show()\n\n        if self.args.user is not None and self.args.pw is not None:\n            self.username_pw_set(username=self.args.user, password=self.args.pw)\n        self.connect(self.args.host, self.args.port, 60)\n\n    def cmd_clear(self):\n        blinkt.clear()\n        blinkt.show()\n\n    def cmd_brightness(self, bri):\n        try:\n            bri = float(bri)\n        except ValueError:\n            print(\"Malformed command brightness, expected float, got: {}\".format(str(bri)))\n            return\n        blinkt.set_brightness(bri)\n        blinkt.show()\n\n    def cmd_rgb(self, pixel, data):\n        try:\n            if pixel == \"*\":\n                pixel = None\n            else:\n                pixel = int(pixel)\n                if pixel > 7:\n                    print(\"Pixel out of range: {}\".format(str(pixel)))\n                    return\n\n            r, g, b = [int(x) & 0xff for x in data]\n            if self.args.green_hack:\n                # Green is about twice the luminosity for a given value\n                # than red or blue, so apply a hackish linear compensation\n                # here taking care of corner cases at 0 and 255.  To do it\n                # properly, it should really be a curve but this approximation\n                # is quite a lot better than nothing.\n                if r not in [0, 255]:\n                    r = r + 1\n                if g not in [0]:\n                    g = g / 2 + 1\n                if b not in [0, 255]:\n                    b = b + 1\n\n            if not self.args.quiet:\n                print('rgb', pixel, r, g, b)\n\n        except ValueError:\n            print(\"Malformed RGB command: {} {}\".format(str(pixel), str(data)))\n            return\n\n        if pixel is None:\n            for x in range(blinkt.NUM_PIXELS):\n                blinkt.set_pixel(x, r, g, b)\n                self.update_time[x] = time.time()\n        else:\n            blinkt.set_pixel(pixel, r, g, b)\n            self.update_time[pixel] = time.time()\n\n        blinkt.show()\n\n    def on_connect(self, client, userdata, flags, rc):\n        if not self.args.quiet:\n            print(\"Connected to {s}:{p} listening for topics {t} with result code {r}.\\nSee {c} --help for options.\".format(\n                s=self.args.host,\n                p=self.args.port,\n                t=', '.join(self.args.topic),\n                r=rc,\n                c=parser.prog\n            ))\n\n        for topic in self.args.topic:\n            client.subscribe(topic)\n\n    def on_message(self, client, userdata, msg):\n\n        data = msg.payload.decode('utf-8').strip().split(',')\n        command = data.pop(0)\n        print(command, data)\n\n        if command == \"clr\" and len(data) == 0:\n            self.cmd_clear()\n            return\n\n        if command == \"bri\" and len(data) == 1:\n            self.cmd_brightness(data[0])\n            return\n\n        if command == \"rgb\" and len(data) == 4:\n            self.cmd_rgb(data[0], data[1:])\n            return\n\n    def blank_timed_out_pixels(self):\n        now = time.time()\n        to_upt_pairs = zip(self.args.timeout, self.update_time)\n        for pixel, (to, uptime) in enumerate(to_upt_pairs):\n            if to is not None and uptime is not None and uptime < now - to:\n                blinkt.set_pixel(pixel, 0, 0, 0)\n                self.update_time[pixel] = None\n        blinkt.show()\n\n    def loop(self, timeout=1.0, max_packets=1):\n        self.blank_timed_out_pixels()\n        return super(PixelClient, self).loop(timeout, max_packets)\n\n\ndef sigterm(signum, frame):\n    client._thread_terminate = True\n\n\nif args.daemon:\n    # Monkey-patch daemon so's the daemon starts reasonably quickly.  FDs don't\n    # strictly speaking need closing anyway because we haven't opened any (yet).\n    daemon.daemon.get_maximum_file_descriptors = lambda: 32\n    args.quiet = True\n    pidlf = lockfile.pidlockfile.PIDLockFile(args.daemon)\n    with daemon.DaemonContext(\n            pidfile=pidlf,\n            signal_map={signal.SIGTERM: sigterm}):\n        client = PixelClient(args)\n        client.loop_forever()\nelse:\n    client = PixelClient(args)\n    client.loop_forever()\n"
  },
  {
    "path": "sphinx/_static/custom.css",
    "content": ".rst-content a, .rst-content a:focus {\n    color:#13c0d7;\n}\n.rst-content a:visited, .rst-content a:active {\n    color:#87319a;\n}\n.rst-content .highlighted {\n\tbackground:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAJElEQVQIW2P8//9/PSMjYyMDEmAEsdElwILoEnBBZAkUQZgEABMWE4Kzp1KUAAAAAElFTkSuQmCC),rgba(246,167,4,0.2);\n}\n.wy-side-nav-search {\n    background:#333333;\n}\n.wy-nav-side {\n    background:#444444;\n}\n.rst-content dl:not(.docutils) dt {\n    background:#e7fafd;\n    border-top:solid 3px #13c0d7;\n    color:rgba(0,0,0,0.5);\n}\n.rst-content .viewcode-link, .rst-content .viewcode-back {\n    color:#00b09b;\n}\ncode.literal {\n    color:#e63c2e;\n}\n.rst-content #module-blinkt {\n    margin-bottom:24px;\n}\n.rst-content #module-blinkt dl:not(.docutils) dt {\n    border:none;\n    background:#f0f0f0;\n}\n.rst-content #module-blinkt dl:not(.docutils) dd {\n    display:none;\n}\n.rst-content #module-blinkt dl:not(.docutils) {\n    margin-bottom:0;\n}"
  },
  {
    "path": "sphinx/_templates/breadcrumbs.html",
    "content": ""
  },
  {
    "path": "sphinx/_templates/layout.html",
    "content": "{% extends \"!layout.html\" %}\n{% block extrahead %}\n\t<link rel=\"stylesheet\" href=\"{{ pathto(\"_static/custom.css\", True) }}\" type=\"text/css\">\n{% endblock %}"
  },
  {
    "path": "sphinx/conf.py",
    "content": "#-*- coding: utf-8 -*-\n\nimport sys\nimport site\n\nimport mock\n\n\nPACKAGE_NAME = u\"Blinkt!\"\nPACKAGE_HANDLE = \"Blinkt\"\nPACKAGE_MODULE = \"blinkt\"\n\n# Prompte /usr/local/lib to the front of sys.path\n#sys.path.insert(0,site.getsitepackages()[0])\n\nimport sphinx_rtd_theme\n\nsys.modules['RPi'] = mock.Mock()\nsys.modules['RPi.GPIO'] = mock.Mock()\n\nsys.path.insert(0, '../library/')\n\nimport blinkt\n\n\nfrom sphinx.ext import autodoc\n\n\nclass OutlineMethodDocumenter(autodoc.MethodDocumenter):\n    objtype = 'method'\n\n    def add_content(self, more_content, no_docstring=False):\n        return\n\nclass OutlineFunctionDocumenter(autodoc.FunctionDocumenter):\n    objtype = 'function'\n\n    def add_content(self, more_content, no_docstring=False):\n        return\n\nclass ModuleOutlineDocumenter(autodoc.ModuleDocumenter):\n    objtype = 'moduleoutline'\n\n    def __init__(self, directive, name, indent=u''):\n        # Monkey path the Method and Function documenters\n        sphinx_app.add_autodocumenter(OutlineMethodDocumenter)\n        sphinx_app.add_autodocumenter(OutlineFunctionDocumenter)\n        autodoc.ModuleDocumenter.__init__(self, directive, name, indent)\n\n    def __del__(self):\n        # Return the Method and Function documenters to normal\n        sphinx_app.add_autodocumenter(autodoc.MethodDocumenter)\n        sphinx_app.add_autodocumenter(autodoc.FunctionDocumenter)\n\n\ndef setup(app):\n    global sphinx_app\n    sphinx_app = app\n    app.add_autodocumenter(ModuleOutlineDocumenter)\n\n    ModuleOutlineDocumenter.objtype = 'module'\n\n# -- General configuration ------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#\n# needs_sphinx = '1.0'\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\n# ones.\nextensions = [\n    'sphinx.ext.autodoc',\n    'sphinx.ext.autosummary',\n    'sphinx.ext.viewcode',\n]\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = ['_templates']\n\n# The suffix(es) of source filenames.\n# You can specify multiple suffix as a list of string:\n#\n# source_suffix = ['.rst', '.md']\nsource_suffix = '.rst'\n\n# The encoding of source files.\n#\n# source_encoding = 'utf-8-sig'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = PACKAGE_NAME\ncopyright = u'2017, Pimoroni Ltd'\nauthor = u'Phil Howard'\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = u'{}'.format(blinkt.__version__)\n# The full version, including alpha/beta/rc tags.\nrelease = u'{}'.format(blinkt.__version__)\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#\n# This is also used if you do content translation via gettext catalogs.\n# Usually you set \"language\" from the command line for these cases.\nlanguage = None\n\n# There are two options for replacing |today|: either, you set today to some\n# non-false value, then it is used:\n#\n# today = ''\n#\n# Else, today_fmt is used as the format for a strftime call.\n#\n# today_fmt = '%B %d, %Y'\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\n# This patterns also effect to html_static_path and html_extra_path\nexclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']\n\n# The reST default role (used for this markup: `text`) to use for all\n# documents.\n#\n# default_role = None\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\n#\n# add_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\n#\n# add_module_names = True\n\n# If true, sectionauthor and moduleauthor directives will be shown in the\n# output. They are ignored by default.\n#\n# show_authors = False\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# A list of ignored prefixes for module index sorting.\n# modindex_common_prefix = []\n\n# If true, keep warnings as \"system message\" paragraphs in the built documents.\n# keep_warnings = False\n\n# If true, `todo` and `todoList` produce output, else they produce nothing.\ntodo_include_todos = False\n\n\n# -- Options for HTML output ----------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\n#\nhtml_theme = 'sphinx_rtd_theme'\n#html_theme = 'alabaster'\n\n# Theme options are theme-specific and customize the look and feel of a theme\n# further.  For a list of options available for each theme, see the\n# documentation.\n#\nhtml_theme_options = {\n    'collapse_navigation': False,\n    'display_version': True\n}\n\n# Add any paths that contain custom themes here, relative to this directory.\nhtml_theme_path = [\n    '_themes',\n    sphinx_rtd_theme.get_html_theme_path()\n]\n\n# The name for this set of Sphinx documents.\n# \"<project> v<release> documentation\" by default.\n#\n# html_title = PACKAGE_NAME + u' v0.1.2'\n\n# A shorter title for the navigation bar.  Default is the same as html_title.\n#\n# html_short_title = None\n\n# The name of an image file (relative to this directory) to place at the top\n# of the sidebar.\n#\nhtml_logo = 'shop-logo.png'\n\n# The name of an image file (relative to this directory) to use as a favicon of\n# the docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32\n# pixels large.\n#\nhtml_favicon = 'favicon.png'\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = ['_static']\n\n# Add any extra paths that contain custom files (such as robots.txt or\n# .htaccess) here, relative to this directory. These files are copied\n# directly to the root of the documentation.\n#\n# html_extra_path = []\n\n# If not None, a 'Last updated on:' timestamp is inserted at every page\n# bottom, using the given strftime format.\n# The empty string is equivalent to '%b %d, %Y'.\n#\n# html_last_updated_fmt = None\n\n# If true, SmartyPants will be used to convert quotes and dashes to\n# typographically correct entities.\n#\n# html_use_smartypants = True\n\n# Custom sidebar templates, maps document names to template names.\n#\n# html_sidebars = {}\n\n# Additional templates that should be rendered to pages, maps page names to\n# template names.\n#\n# html_additional_pages = {}\n\n# If false, no module index is generated.\n#\n# html_domain_indices = True\n\n# If false, no index is generated.\n#\nhtml_use_index = False\n\n# If true, the index is split into individual pages for each letter.\n#\n# html_split_index = False\n\n# If true, links to the reST sources are added to the pages.\n#\nhtml_show_sourcelink = False\n\n# If true, \"Created using Sphinx\" is shown in the HTML footer. Default is True.\n#\nhtml_show_sphinx = False\n\n# If true, \"(C) Copyright ...\" is shown in the HTML footer. Default is True.\n#\n# html_show_copyright = True\n\n# If true, an OpenSearch description file will be output, and all pages will\n# contain a <link> tag referring to it.  The value of this option must be the\n# base URL from which the finished HTML is served.\n#\n# html_use_opensearch = ''\n\n# This is the file name suffix for HTML files (e.g. \".xhtml\").\n# html_file_suffix = None\n\n# Language to be used for generating the HTML full-text search index.\n# Sphinx supports the following languages:\n#   'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'\n#   'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'\n#\n# html_search_language = 'en'\n\n# A dictionary with options for the search language support, empty by default.\n# 'ja' uses this config value.\n# 'zh' user can custom change `jieba` dictionary path.\n#\n# html_search_options = {'type': 'default'}\n\n# The name of a javascript file (relative to the configuration directory) that\n# implements a search results scorer. If empty, the default will be used.\n#\n# html_search_scorer = 'scorer.js'\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = PACKAGE_HANDLE + 'doc'\n\n# -- Options for LaTeX output ---------------------------------------------\n\nlatex_elements = {\n     # The paper size ('letterpaper' or 'a4paper').\n     #\n     # 'papersize': 'letterpaper',\n\n     # The font size ('10pt', '11pt' or '12pt').\n     #\n     # 'pointsize': '10pt',\n\n     # Additional stuff for the LaTeX preamble.\n     #\n     # 'preamble': '',\n\n     # Latex figure (float) alignment\n     #\n     # 'figure_align': 'htbp',\n}\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title,\n#  author, documentclass [howto, manual, or own class]).\nlatex_documents = [\n    (master_doc, PACKAGE_HANDLE + '.tex', PACKAGE_NAME + u' Documentation',\n     u'Phil Howard', 'manual'),\n]\n\n# The name of an image file (relative to this directory) to place at the top of\n# the title page.\n#\n# latex_logo = None\n\n# For \"manual\" documents, if this is true, then toplevel headings are parts,\n# not chapters.\n#\n# latex_use_parts = False\n\n# If true, show page references after internal links.\n#\n# latex_show_pagerefs = False\n\n# If true, show URL addresses after external links.\n#\n# latex_show_urls = False\n\n# Documents to append as an appendix to all manuals.\n#\n# latex_appendices = []\n\n# It false, will not define \\strong, \\code, \titleref, \\crossref ... but only\n# \\sphinxstrong, ..., \\sphinxtitleref, ... To help avoid clash with user added\n# packages.\n#\n# latex_keep_old_macro_names = True\n\n# If false, no module index is generated.\n#\n# latex_domain_indices = True\n\n\n# -- Options for manual page output ---------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [\n    (master_doc,  PACKAGE_MODULE, PACKAGE_NAME + u' Documentation',\n     [author], 1)\n]\n\n# If true, show URL addresses after external links.\n#\n# man_show_urls = False\n\n\n# -- Options for Texinfo output -------------------------------------------\n\n# Grouping the document tree into Texinfo files. List of tuples\n# (source start file, target name, title, author,\n#  dir menu entry, description, category)\ntexinfo_documents = [\n    (master_doc, PACKAGE_HANDLE, PACKAGE_NAME + u' Documentation',\n     author, PACKAGE_HANDLE, 'One line description of project.',\n     'Miscellaneous'),\n]\n\n# Documents to append as an appendix to all manuals.\n#\n# texinfo_appendices = []\n\n# If false, no module index is generated.\n#\n# texinfo_domain_indices = True\n\n# How to display URL addresses: 'footnote', 'no', or 'inline'.\n#\n# texinfo_show_urls = 'footnote'\n\n# If true, do not generate a @detailmenu in the \"Top\" node's menu.\n#\n# texinfo_no_detailmenu = False\n"
  },
  {
    "path": "sphinx/index.rst",
    "content": ".. role:: python(code)\n   :language: python\n\n.. toctree::\n   :titlesonly:\n   :maxdepth: 0\n\nWelcome\n-------\n\nThis documentation will guide you through the methods available in the Blinkt! python library.\n\nBlinkt! is a tiny Raspberry Pi add-on with 8, APA102, RGB LEDs which you can drive\nindependently for notifications, lighting effects, animation effects and more!\n\n* More information - https://shop.pimoroni.com/products/blinkt\n* Get the code - https://github.com/pimoroni/blinkt\n* Get started - https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-blinkt\n* Get help - http://forums.pimoroni.com/c/support\n\nAt A Glance\n-----------\n\n.. automoduleoutline:: blinkt\n   :members:\n\nSet A Single Pixel\n------------------\n\nThe bread and butter of Blintk! is setting pixels. You can set any of the 8 pixels\non your Blinkt! to one of around 16 million colours!\n\nThe :python:`brightness` argument is completely optional. Omit it to keep the last\nbrightness value set for that particular pixel.\n\n.. automodule:: blinkt\n   :noindex:\n   :members: set_pixel\n\nSet All Pixels\n--------------\n\nSometimes you need to set all the pixels to the same colour. This convinience method\ndoes just that!\n\n.. automodule:: blinkt\n   :noindex:\n   :members: set_all\n\nShow\n----\n\nNone of your pixels will appear on Blinkt! until you :python:`show()` them. This method writes\nall the pixel data out to your device.\n\n.. automodule:: blinkt\n   :noindex:\n   :members: show\n\nClear\n-----\n\nExactly the same as calling :python:`set_all(0,0,0)`, clear sets all the pixels to black.\n\nYou must also call :python:`show()` if you want to turn Blinkt! off.\n\n.. automodule:: blinkt\n   :noindex:\n   :members: clear\n\nEnable/Disable Clear On Exit\n----------------------------\n\nSometimes you want a script that runs and quits, leaving a pattern up on Blinkt!\n\n.. automodule:: blinkt\n   :noindex:\n   :members: set_clear_on_exit\n\nGet A Single Pixel\n------------------\n\n.. automodule:: blinkt\n   :noindex:\n   :members: get_pixel\n\nConstants\n---------\n\nBlinkt! has 8 pixels. Simple. Use the constant :python:`blinkt.NUM_PIXELS` when you're iterating over pixels,\nso you can avoid a *magic number* in your code.\n\n:python:`blinkt.NUM_PIXELS = 8`\n"
  }
]