Skip to content

Commit

Permalink
add inc/dec brightness commands
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdadams committed Mar 19, 2023
1 parent dbbdb8b commit 18ca010
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
4 changes: 4 additions & 0 deletions companion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"maintainers": [
{
"name": "Jelle van Abbema"
},
{
"name": "Joseph Adams",
"email": "josephdadams@gmail.com"
}
],
"legacyIds": [],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mvr-helios",
"version": "2.0.0",
"version": "2.0.1",
"main": "src/index.js",
"scripts": {
"format": "prettier --write .",
Expand Down
80 changes: 80 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,86 @@ exports.updateActions = function () {
},
}

actions['inc_brightness'] = {
name: 'Increase Screen Brightness',
options: [
{
type: 'number',
label: 'Brightness Amount',
id: 'brightness',
min: 0,
max: 5,
default: 1,
step: 0.01,
required: true,
range: true,
},
],
callback: (event) => {
let object = {}
let curBrightness = self.brightness;

if (curBrightness == undefined) {
curBrightness = 50;
}

let newBrightness = curBrightness + event.options.brightness;

if (newBrightness > 100) {
newBrightness = 100;
}

self.brightness = newBrightness;

object['dev'] = {
display: {
brightness: newBrightness,
},
}
self.sendPatchRequest(object)
},
}

actions['dec_brightness'] = {
name: 'Decrease Screen Brightness',
options: [
{
type: 'number',
label: 'Brightness Amount',
id: 'brightness',
min: 0,
max: 5,
default: 1,
step: 0.01,
required: true,
range: true,
},
],
callback: (event) => {
let object = {}
let curBrightness = self.brightness;

if (curBrightness == undefined) {
curBrightness = 50;
}

let newBrightness = curBrightness - event.options.brightness;

if (newBrightness < 0) {
newBrightness = 0;
}

self.brightness = newBrightness;

object['dev'] = {
display: {
brightness: newBrightness,
},
}
self.sendPatchRequest(object)
},
}

actions['set_gamma'] = {
name: 'Screen Gamma',
options: [
Expand Down

0 comments on commit 18ca010

Please # to comment.