Skip to content

Commit

Permalink
feat(Program): Add vcgencmd to SignalProximity callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ovaar committed Dec 30, 2019
1 parent 70faaec commit b5775c0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/index.ts
@@ -1,7 +1,7 @@
import { Gpio } from 'onoff'
import SignalProximity from './gpio-proximity'
import BluetoothProximity from './bluetooth-proximity'

import { execSync } from 'child_process'
export namespace Proximity {
const bluetooth = new BluetoothProximity()
bluetooth.on('add', peripheral => {
Expand All @@ -15,9 +15,19 @@ export namespace Proximity {
const signalProximity = new SignalProximity(gpio4)
signalProximity.on('begin', function() {
console.log('Turn display ON')
try {
execSync('vcgencmd display_power 1')
} catch (error) {
console.error(error)
}
})
signalProximity.on('end', function() {
console.log('Turn display OFF')
try {
execSync('vcgencmd display_power 0')
} catch (error) {
console.error(error)
}
})

process.on('SIGINT', () => {
Expand Down

0 comments on commit b5775c0

Please sign in to comment.