Skip to main content

Python library for accessing the Razer Chroma SDK

Project description

pychroma

License Python Version

Python library for accessing the Razer Chroma SDK

pychroma provides general-purpose access to the Razer Chroma SDK REST API for control over the LEDs of Razer devices. The work environment is easy to set up and it features a sketch and (optionally) a controller. The sketch code structure is heavily inspired from p5js.org conventions. The controller allows having multiple sketches.

Features

  • Full controll over the LEDs via Chroma SDK
  • Low barrier to entry for educators and practitioners

Made for everyone

  • Simply use the sketch! This library is accessible and inclusive for artists, designers, educators and beginners
  • Gain more access by using the controller or handling the connection and devices all by yourself
  • If you want to have full control then fork this repository and edit the source code

Installation

This repo is tested on Python 3.8.3, requests 2.23.0 and pynput 1.6.8

With pip

pychroma can be installed using pip as follows:

pip install pychroma

From source

You can install from source by cloning the repository and running:

git clone https://github.com/morswin22/pychroma
cd pychroma
pip install .

When you update the repository, you should upgrade the pychroma installation and its dependencies as follows:

git pull
pip install --upgrade .

Run the examples

You can download the examples from the examples repo

Look at the README included with examples for more information

Tests

A series of tests are included for the library. Library tests can be found in the tests folder.

Here's the easiest way to run tests for the library:

python -m unittest discover -v -s ./tests -p test*.py

If you are using Visual Studio Code then you can use it's built in testing with python add-on

Quick Tour

Check out the wiki for detailed documentation.

Create a configuration file in JSON format.

{
  "chroma": {
    "developerName": "Your name",
    "developerContact": "Your email",
    "category": "application",
    "supportedDevices": ["keyboard"],
    "description": "Basic hello world sketch",
    "title": "Hello world!"
  }
}

Creating a sketch

from pychroma import Sketch

class MySketch(Sketch):
  config_path = 'path/to/config/file.json'

Example animation code

from pychroma import Sketch

class MySketch(Sketch):
  config_path = 'path/to/config/file.json'

  def setup(self):
    self.frame_rate = 30
    self.keyboard.color_mode('hsv')
    self.hue = 0

  def update(self):
    self.hue += 1
    if self.hue == 360:
      self.stop()

  def render(self):
    self.keyboard.set_static((self.hue, 100, 100))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pychroma-0.0.2.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distribution

pychroma-0.0.2-py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page