Skip to content

Commit

Permalink
Merge pull request #23 from resin-io-projects/0.5
Browse files Browse the repository at this point in the history
adapt to resinOS 2.0 and include stereo
  • Loading branch information
curcuz authored Apr 18, 2017
2 parents db58c30 + 8a4ceaa commit ab43f86
Show file tree
Hide file tree
Showing 33 changed files with 643 additions and 281 deletions.
24 changes: 20 additions & 4 deletions Dockerbin/asound.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
pcm.!default {
type hw card 0
pcm.hifiberry {
type hw card 0
}
ctl.!default {
type hw card 0

pcm.!default {
type plug
slave.pcm "dmixer"
}

pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hifiberry"
channels 2
}
}

ctl.dmixer {
type hw
card 0
}
10 changes: 6 additions & 4 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y \
alsa-utils \
gstreamer1.0-alsa \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-tools \
gstreamer1.0-libav \
haproxy \
mopidy-spotify \
Expand All @@ -39,8 +41,8 @@ RUN apt-get update && apt-get install -y \
# Enable haproxy
RUN echo 'ENABLED=1' >> /etc/default/haproxy

# Update setup-tools
RUN curl https://bootstrap.pypa.io/ez_setup.py -o - | python
# Update setup-tools and other deps
RUN pip install --upgrade pip packaging pyparsing setuptools

# Install Mopidy extensions
RUN pip install mopidy-gmusic Mopidy-YouTube mopidy-musicbox-webclient Mopidy-Local-SQLite Mopidy-ALSAMixer
Expand Down Expand Up @@ -77,8 +79,8 @@ COPY ./app ./
# Compile coffee
RUN ./node_modules/.bin/coffee -c ./src

# Disable haproxy service - we will manually start it later
RUN systemctl disable haproxy
# Disable haproxy and mopidy services - we will manually start it later
RUN systemctl disable haproxy mopidy

## Uncomment if you want systemd
ENV INITSYSTEM on
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ A Raspberry Pi based smart connected speaker based on [Mopidy](https://github.co
*__You can read about the making of the boombeastic and see more photos [here](https://resin.io/blog/the-making-of-boombeastic/)__*
## Parts list

## Mini
#### rpi2/2+/3 version
please refer to [this link](https://github.com/resin-io-playground/boombeastic/blob/master/docs/v1/mini/rpi3/bom.md)
#### rpi0 version
Expand All @@ -18,14 +19,21 @@ please refer to [this link](https://github.com/resin-io-playground/boombeastic/b
#### rpi0 version
please refer to [this link](https://github.com/resin-io-playground/boombeastic/blob/master/docs/v1/mini/rpi0/assembly.md)

## Stereo
#### rpi2/2+/3 version
please refer to [this link](https://github.com/resin-io-playground/boombeastic/blob/master/docs/v1/stereo/rpi3/bom.md)

## Getting started

**this application is compatible with resinOS 2.0+**

- Sign up on [resin.io](https://dashboard.resin.io/signup)
- go throught the [getting started guide](http://docs.resin.io/raspberrypi/nodejs/getting-started/) and create a new RPI zero application called `boombeasticmini`
- go throught the [getting started guide](http://docs.resin.io/raspberrypi/nodejs/getting-started/) and create a new Raspberry Pi application called `boombeastic`
- clone this repository to your local workspace
- set these variables in the `Fleet Configuration` application side tab

- `RESIN_HOST_CONFIG_dtoverlay` = `hifiberry-dac`
- `RESIN_HOST_CONFIG_device_tree_overlay` = `i2s-mmap`

- add the _resin remote_ to your local workspace using the useful shortcut in the dashboard UI ![remoteadd](https://raw.githubusercontent.com/resin-io-playground/boombeastic/master/docs/gitresinremote.png)
- `git push resin master`
Expand Down Expand Up @@ -59,6 +67,7 @@ PORTAL_SSID | `ResinAP` | the name of the Access Point that [wifi-connect](https
## Videos

* [YouTube 1](https://www.youtube.com/watch?v=EnLgmW8kyis)
* [YouTube 2](https://youtu.be/pKvJKaCDQW8)
* [Vine 1](https://vine.co/v/5g71nzHwXvr)

## Pictures
Expand All @@ -67,6 +76,10 @@ PORTAL_SSID | `ResinAP` | the name of the Access Point that [wifi-connect](https

---

![v1_stereo](https://raw.githubusercontent.com/resin-io-playground/boombeastic/master/docs/v1/stereo/photos/IMG_20170407_133846.jpg)

---

![v1_rpi3_2](https://raw.githubusercontent.com/resin-io-playground/boombeastic/master/docs/v1/mini/rpi3/photos/IMG_20160929_163751.jpg)

---
Expand Down
36 changes: 18 additions & 18 deletions app/bower.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "resin-wifi-connect",
"version": "0.0.0",
"homepage": "https://github.com/pcarranzav/resin-wifi-connect",
"authors": [
"Pablo Carranza Vélez <[email protected]>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"src/public/bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.3.5"
}
"name": "resin-wifi-connect",
"version": "2.0.0",
"homepage": "https://github.com/pcarranzav/resin-wifi-connect",
"authors": [
"Pablo Carranza Vélez <[email protected]>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"src/public/bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.3.5"
}
}
158 changes: 79 additions & 79 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
{
const fs = require('fs');
const ini = require('ini');
const exec = require('child_process').exec;
const chalk = require("chalk");
const request = require('request');
const display = require(__dirname + '/libs/ledmatrix/index.js');
const supervisor = require(__dirname + '/libs/supervisor/index.js');
const emoji = require(__dirname + '/libs/emoji/index.js');
const debug = require('debug')('main');
const fs = require('fs');
const ini = require('ini');
const exec = require('child_process').exec;
const chalk = require("chalk");
const request = require('request');
const display = require(__dirname + '/libs/ledmatrix/index.js');
const supervisor = require(__dirname + '/libs/supervisor/index.js');
const emoji = require(__dirname + '/libs/emoji/index.js');
const debug = require('debug')('main');

let mopidy = ini.parse(fs.readFileSync('/etc/mopidy/mopidy.conf', 'utf-8'));
console.log(chalk.cyan('configuring Mopidy from env vars...'));
let updating = false;
let mopidy = ini.parse(fs.readFileSync('/etc/mopidy/mopidy.conf', 'utf-8'));
console.log(chalk.cyan('configuring Mopidy from env vars...'));
let updating = false;

// http config
mopidy.http.port = parseInt(process.env.MOPIDY_HTTP_PORT) || 8080;
// mpd config
mopidy.mpd.port = parseInt(process.env.MOPIDY_MPD_PORT) || 6680;
// audio config
mopidy.audio.mixer_volume = parseInt(process.env.MOPIDY_AUDIO_MIXER_VOLUME) || 50;
// Google Play Music config
mopidy.gmusic.enabled = process.env.MOPIDY_GMUSIC_ENABLED === '1' ? true : false;
mopidy.gmusic.username = process.env.MOPIDY_GMUSIC_USERNAME || "none";
mopidy.gmusic.password = process.env.MOPIDY_GMUSIC_PASSWORD || "none";
mopidy.gmusic.all_access = process.env.MOPIDY_GMUSIC_ALL_ACCESS === '1' ? true : false;
// Spotify config
mopidy.spotify.enabled = process.env.MOPIDY_SPOTIFY_ENABLED === '1' ? true : false;
mopidy.spotify.username = process.env.MOPIDY_SPOTIFY_USERNAME || "none";
mopidy.spotify.password = process.env.MOPIDY_SPOTIFY_PASSWORD || "none";
// Soundcloud config
mopidy.soundcloud.enabled = process.env.MOPIDY_SOUNDCLOUD_ENABLED === '1' ? true : false;
mopidy.soundcloud.auth_token = process.env.MOPIDY_SOUNDCLOUD_AUTH_TOKEN || "none";
// YouTube config
mopidy.youtube.enabled = process.env.MOPIDY_YOUTUBE_ENABLED === '1' ? true : false;
// http config
mopidy.http.port = parseInt(process.env.MOPIDY_HTTP_PORT) || 8080;
// mpd config
mopidy.mpd.port = parseInt(process.env.MOPIDY_MPD_PORT) || 6680;
// audio config
mopidy.audio.mixer_volume = parseInt(process.env.MOPIDY_AUDIO_MIXER_VOLUME) || 50;
// Google Play Music config
mopidy.gmusic.enabled = process.env.MOPIDY_GMUSIC_ENABLED === '1' ? true : false;
mopidy.gmusic.username = process.env.MOPIDY_GMUSIC_USERNAME || "none";
mopidy.gmusic.password = process.env.MOPIDY_GMUSIC_PASSWORD || "none";
mopidy.gmusic.all_access = process.env.MOPIDY_GMUSIC_ALL_ACCESS === '1' ? true : false;
// Spotify config
mopidy.spotify.enabled = process.env.MOPIDY_SPOTIFY_ENABLED === '1' ? true : false;
mopidy.spotify.username = process.env.MOPIDY_SPOTIFY_USERNAME || "none";
mopidy.spotify.password = process.env.MOPIDY_SPOTIFY_PASSWORD || "none";
// Soundcloud config
mopidy.soundcloud.enabled = process.env.MOPIDY_SOUNDCLOUD_ENABLED === '1' ? true : false;
mopidy.soundcloud.auth_token = process.env.MOPIDY_SOUNDCLOUD_AUTH_TOKEN || "none";
// YouTube config
mopidy.youtube.enabled = process.env.MOPIDY_YOUTUBE_ENABLED === '1' ? true : false;

fs.writeFileSync('/etc/mopidy/mopidy.conf', ini.stringify(mopidy));
console.log(chalk.cyan('starting Mopidy - HTTP port:' + mopidy.http.port + ' (proxy on port 80); MPD port:' + mopidy.mpd.port));
display.init(() => {
'use strict';
display.image(display.presets.splash);
});
exec('systemctl start mopidy', (error, stdout, stderr) => {
'use strict';
if (error) {
console.log(chalk.red(`exec error: ${error}`));
return;
}
console.log(chalk.green(`stdout: ${stdout}`));
console.log(chalk.red(`stderr: ${stderr}`));
});
fs.writeFileSync('/etc/mopidy/mopidy.conf', ini.stringify(mopidy));
console.log(chalk.cyan('starting Mopidy - HTTP port:' + mopidy.http.port + ' (proxy on port 80); MPD port:' + mopidy.mpd.port));
display.init(() => {
'use strict';
display.image(display.presets.splash);
});
exec('systemctl start mopidy', (error, stdout, stderr) => {
'use strict';
if (error) {
console.log(chalk.red(`exec error: ${error}`));
return;
}
console.log(chalk.green(`stdout: ${stdout}`));
console.log(chalk.red(`stderr: ${stderr}`));
});

supervisor.start(500, () => {
'use strict';
supervisor.on('status', (status) => {
console.log(chalk.white('Supervisor status update: ' + status));
switch (status) {
case "Idle":
display.image(display.presets.smile);
break;
case "Installing":
display.image(display.presets.busy);
break;
case "Downloading":
display.image(display.presets.download);
break;
case "Starting":
display.image(display.presets.fwd);
break;
case "Stopping":
display.image(display.presets.stop);
break;
}
});
supervisor.start(500, () => {
'use strict';
supervisor.on('status', (status) => {
console.log(chalk.white('Supervisor status update: ' + status));
switch (status) {
case "Idle":
display.image(display.presets.smile);
break;
case "Installing":
display.image(display.presets.busy);
break;
case "Downloading":
display.image(display.presets.download);
break;
case "Starting":
display.image(display.presets.fwd);
break;
case "Stopping":
display.image(display.presets.stop);
break;
}
});
});

emoji.start(() => {
'use strict';
emoji.on('emoji', (emoji) => {
console.log(chalk.magenta('new emoji received! applying...'));
display.image(emoji);
});
emoji.on('reset', (emoji) => {
console.log(chalk.magenta('emoji reset request received! applying...'));
display.image(display.presets.smile);
});
emoji.start(() => {
'use strict';
emoji.on('emoji', (emoji) => {
console.log(chalk.magenta('new emoji received! applying...'));
display.image(emoji);
});
emoji.on('reset', (emoji) => {
console.log(chalk.magenta('emoji reset request received! applying...'));
display.image(display.presets.smile);
});
});

}
Loading

0 comments on commit ab43f86

Please sign in to comment.