Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom changes #26

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const stateKey = 'spotify_auth_state';
const lightService = require('./services/lights');
const spotifyService = require('./services/spotify');


function generateRandomString() {
var text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
Expand Down Expand Up @@ -126,7 +127,6 @@ app.get('/user', function(req, res) {
res.redirect('/');
return;
}

if(lightService.getLights()) {
res.redirect('/go');
return;
Expand All @@ -150,6 +150,44 @@ app.get('/go', function(req, res) {
spotifyService.getCurrentTrack(user);
});

app.get('/go/colour/:chosenColor', function(req, res) {
var colour = req.params.chosenColor;

var lights = require('./services/lights');
console.log('Changing color to ' + colour);
lights.setInitialColor(colour);

if(!user || !lightService.getLights()) {
res.redirect('/');
return;
}

res.render('ready', {
user: user
});

spotifyService.getCurrentTrack(user);
});

app.get('/go/mode/:chosenMode', function(req, res) {
var mode = req.params.chosenMode;

var lights = require('./services/lights');
console.log('Changing mode to ' + mode);
lights.setMode(mode);

if(!user || !lightService.getLights()) {
res.redirect('/');
return;
}

res.render('ready', {
user: user
});

spotifyService.getCurrentTrack(user);
});

app.get('/error', function(req, res) {
if(!req.query.msg) {
res.redirect('/');
Expand All @@ -162,6 +200,7 @@ app.get('/error', function(req, res) {
});

const port = process.env.PORT || 8888;
const ip = process.env.IP || 'localhost';
console.log('Listening on ' + port);
app.listen(port);
opn('http://localhost:' + port);
opn('http://' + ip + ':' + port); // localhost
8 changes: 8 additions & 0 deletions examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Chill
npm start -- --beatmode 1 --colourmode 3 --maxbrightness 45 --minbrightness 40 --minsaturation 80 --threshold 60 --colourrange 6 --defaultcolour tamisepose

# EDM
npm start -- --beatmode 1 --colourmode 3 --maxbrightness 50 --minbrightness 0 --minsaturation 88 --threshold 5 --colourrange 90 --defaultcolour red

# Inter
npm start -- --beatmode 1 --colourmode 3 --maxbrightness 45 --minbrightness 20 --minsaturation 80 --threshold 20 --colourrange 20 --defaultcolour blue
Loading