Skip to content

Commit

Permalink
argebnrst
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Sep 5, 2017
0 parents commit cc80cfa
Show file tree
Hide file tree
Showing 18 changed files with 20,332 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
@@ -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*
2,164 changes: 2,164 additions & 0 deletions README.md

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions electron/denon.js
@@ -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)
)
)
}
40 changes: 40 additions & 0 deletions electron/index.js
@@ -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)
})
})

0 comments on commit cc80cfa

Please sign in to comment.