Giter Club home page Giter Club logo

pca9685-driver-http's Introduction

About

This is a simple, thin web interface layer for accessing PCA9685 controller via for example Raspberry Pi.

For other details, see PCA9685-driver.

Install

pip install PCA9685-driver-http

Do not use the run-dev-server.py in 'production', instead of this use uWSGI, or sg else.

Example config for uwsgi: (/etc/uwsgi/apps-enabled/PCA9685-driver-http.ini)

[uwsgi]
processes = 2
module = pca9685_driver_http.app:app
http-socket = :52042

The default user of the uwsgi process is www-data, so need to add the www-data user to the i2c group.

For example: usermod -G i2c -a www-data

API endpoints test examples with curl

curl http://localhost:52042/devices/lamp/led/7
# {"result": "ok", "value": 10}
curl http://localhost:52042/devices/lamp/led/7 -X PUT -d value=10 
# {"result": "ok"}
curl http://localhost:52042/devices/lamp/led
# {"result": "ok", "values": {"0": 4096, "1": 4096, "2": 4096, "3": 0, "4": 4096, "5": 0, "6": 0, "7": 10, "8": 4196, "9": 4096, "10": 4096, "11": 4096, "12": 4096, "13": 4096, "14": 4096, "15": 4096}}
curl http://localhost:52042/devices/lamp/led -X PUT -d "led[5]=10&led[6]=10"
# {"result": "ok"}
curl http://localhost:52042/devices/lamp/pwm-frequency
# {"result": "ok", "value": 1017}
curl http://localhost:52042/devices/lamp/pwm-frequency -X PUT -d value=1017
# {"result": "ok"}
curl http://localhost:52042/devices/lamp/led/42
# {"result": "error", "message": "led_number must be less than 15, got 42"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.