raspberrypi-soundbox

1.9.0 • Public • Published

js-raspberrypi-soundbox

Control and monitor your DIY soundbox

Dependencies

Begin with an update

    sudo apt-get update

Python and git dependencies:

    sudo apt-get install python-dev python-pip git

WiringPi

    sudo apt-get install wiringpi
    sudo pip install wiringpi

Gaugette

    cd
    git clone https://github.com/guyc/py-gaugette.git
    cd py-gaugette
    sudo python setup.py install

Py-Spidev

    cd
    git clone https://github.com/doceme/py-spidev.git
    cd py-spidev
    sudo python setup.py install

Adafruit_I2C

    cd
    git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
    cd Adafruit_Python_GPIO
    sudo python setup.py install

Adafruit_Trellis_Python

    cd
    git clone https://github.com/kevincastejon/python-raspberrypi-adafruit-trellis.git
    cd python-raspberrypi-adafruit-trellis
    sudo python setup.py install

Installation

Then install this module that way:

    npm install raspberrypi-soundbox

Usage

const Soundbox = require('raspberrypi-soundbox');
const box = new Soundbox();

let brightness = 15;

box.setLEDs([1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1])
box.displayMessage('helo');
box.on('keyPressed',(keyId) => {
  box.setLED(keyId,box.getLED(keyId)?0:1)
});
box.on('keyReleased',(keyId) => {
  box.setLED(keyId,box.getLED(keyId)?0:1)
});
box.on('rotate',(delta) => {
  brightness+=delta;
  if (brightness<0) {
    brightness=0;
  } else if(brightness>15) {
    brightness=15;
  }
  box.setBrightness(brightness);
});
box.on('rotaryPressed',() => {
  console.log('rotaryPressed');
});
box.on('rotaryReleased',() => {
  console.log('rotaryReleased');
});

API

Constructor

optional parameters

! All pin numbers are based on WiringPi numerotation !

  • trellisAddress = 0x70 . The Trellis I2C address
  • trellisBus = 1 . The Trellis I2C bus
  • rotaryEncoderPinA = 1 . Rotary encoder first pin number
  • rotaryEncoderPinB = 0 . Rotary encoder second pin number
  • rotaryEncoderPinSwitch = 2 . Rotary switch pin number
  • lcdPinA = 29 . Lcd first pin number
  • lcdPinB = 28 . Lcd second pin number

Members (properties)

  • volume Volume level

Methods (functions)

  • displayMessage(message: string) Displays a message on the LCD screen
  • getLED(ledId: int) Returns the state of a specified led
  • getLEDs() Returns an array of leds states
  • playSound(path: string, callback: function) Plays a sound
  • setBrightness(value: int [0-15]) Defines the brightness of all the LEDs (Adafruit Trellis does not allow different brightness for each leds)

Readme

Keywords

none

Package Sidebar

Install

npm i raspberrypi-soundbox

Weekly Downloads

1

Version

1.9.0

License

MIT

Unpacked Size

10.6 kB

Total Files

6

Last publish

Collaborators

  • kevincastejon