Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chee
committed
Sep 5, 2017
0 parents
commit cc80cfa
Showing
18 changed files
with
20,332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const DenonAVR = require('denon-avr') | ||
const { | ||
up, | ||
down, | ||
left, | ||
right, | ||
enter, | ||
back | ||
} = require('../src/shared/buttons') | ||
|
||
module.exports = host => { | ||
// eslint-disable-next-line | ||
const telnet = new DenonAVR.transports.telnet({ | ||
host, | ||
debug: true | ||
}) | ||
|
||
const denon = new DenonAVR(telnet) | ||
|
||
denon.connect() | ||
|
||
const send = command => () => | ||
denon.send(command.toUpperCase()) | ||
|
||
const commands = { | ||
[up]: send('mncup'), | ||
[down]: send('mncdn'), | ||
[left]: send('mnclt'), | ||
[right]: send('mncrt'), | ||
[back]: send('mnrtn'), | ||
[enter]: send('mnent') | ||
} | ||
|
||
const handleButton = button => { | ||
commands[button] | ||
? commands[button]() | ||
: console.log(button) | ||
} | ||
|
||
return new Promise(resolve => | ||
denon.on('connect', () => | ||
resolve(handleButton) | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { | ||
app, | ||
BrowserWindow, | ||
ipcMain | ||
} = require('electron') | ||
|
||
let mainWindow | ||
|
||
function createWindow () { | ||
mainWindow = new BrowserWindow({width: 800, height: 600}) | ||
|
||
mainWindow.loadURL('http://localhost:3000') | ||
mainWindow.webContents.openDevTools() | ||
|
||
mainWindow.on('closed', function () { | ||
mainWindow = null | ||
}) | ||
} | ||
|
||
app.on('ready', createWindow) | ||
|
||
app.on('window-all-closed', function () { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', function () { | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) | ||
|
||
const denon = require('./denon') | ||
|
||
denon('192.168.0.16').then(handleButton => { | ||
ipcMain.on('button', (event, button) => { | ||
handleButton(button) | ||
}) | ||
}) |
Oops, something went wrong.