Skip to content
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
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class braviaInstance extends InstanceBase {
inputs: [],
webAppState: false,
webAppUrl: '',
color: NaN,
brightness: NaN,
contrast: NaN,
sharpness: NaN,
Comment on lines +38 to +41
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make volumeLevel NaN too if this is the best bet? Or undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 0 has meaning, I set it to NaN as the default value, but perhaps it should be undefined instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined feels a better fit to me. Can you update volume too to match.

}

this.CHOICES_INPUTS = [
Expand Down
37 changes: 37 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
const PICTURE_SETTINGS = [
{ id: 'color', label: 'Color', default: 50, min: 0, max: 100 },
{ id: 'brightness', label: 'Brightness', default: 40, min: 0, max: 50 },
{ id: 'contrast', label: 'Contrast', default: 90, min: 0, max: 100 },
{ id: 'sharpness', label: 'Sharpness', default: 50, min: 0, max: 100 },
]

module.exports = {
PICTURE_SETTINGS,
initActions: function () {
let self = this
let actions = {}
Expand Down Expand Up @@ -151,6 +159,35 @@ module.exports = {
},
}

PICTURE_SETTINGS.forEach((setting) => {
actions['set_' + setting.id] = {
name: setting.label,
options: [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may as well add the step setting they provide and populate the option with that too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was sort of meaning pull it out of their config via the API, but maybe that's more effort than it's worth.

{
type: 'number',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the right answer here, but whilst number is technically correct, it sadly currently excludes variable support, meaning people couldn't e.g. use this to set the value via a rotary encoder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think we should do?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I don't know, I think our three options are:

  1. Stay with number, nicer UI with steps and min/max
  2. Switch to text, can enable variables, but probably need external value validation
  3. Do both with some fancy switch and isVisible toggling of two different fields

Maybe 1 makes sense just to start going for now. I think Companion centrally may improve the behaviour around that soon (it's just a shame they haven't done so already...).

label: setting.label,
id: 'value',
default: setting.default,
min: setting.min,
max: setting.max,
step: 1,
},
],
callback: async function (action) {
let opt = action.options
let params = {
settings: [
{
target: setting.id,
value: opt.value.toString(),
},
],
}
self.sendCommand('video', 'setPictureQualitySettings', params)
},
}
})

self.setActionDefinitions(actions)
},
}
8 changes: 8 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = {
self.sendCommand('audio', 'getVolumeInformation', {}, 'volume')
self.sendCommand('avContent', 'getPlayingContentInfo', {}, 'input')
self.sendCommand('appControl', 'getWebAppStatus', {}, 'webapp')
self.sendCommand('video', 'getPictureQualitySettings', { target: '' }, 'picture')
},

sendCommand: function (service, method, params, request = undefined) {
Expand Down Expand Up @@ -104,6 +105,13 @@ module.exports = {
self.DATA.webAppState = data.result[0].active
self.DATA.webAppUrl = data.result[0].url
break
case 'picture':
data.result[0].forEach((setting) => {
if (['color', 'brightness', 'contrast', 'sharpness'].includes(setting.target)) {
self.DATA[setting.target] = parseInt(setting.currentValue)
}
})
break
default:
break
}
Expand Down
33 changes: 33 additions & 0 deletions src/presets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { combineRgb } = require('@companion-module/base')
const { PICTURE_SETTINGS } = require('./actions')

module.exports = {
initPresets: function () {
Expand Down Expand Up @@ -313,6 +314,38 @@ module.exports = {
}
}

const PICTURE_SETTINGS = [
{ id: 'color', label: 'Color', default: 50 },
{ id: 'brightness', label: 'Brightness', default: 40 },
{ id: 'contrast', label: 'Contrast', default: 90 },
{ id: 'sharpness', label: 'Sharpness', default: 50 },
]

Comment on lines +317 to +323
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we're now using the ones from actions:

Suggested change
const PICTURE_SETTINGS = [
{ id: 'color', label: 'Color', default: 50 },
{ id: 'brightness', label: 'Brightness', default: 40 },
{ id: 'contrast', label: 'Contrast', default: 90 },
{ id: 'sharpness', label: 'Sharpness', default: 50 },
]

PICTURE_SETTINGS.forEach((setting) => {
presets[setting.id] = {
category: 'Picture Settings',
name: setting.label,
type: 'button',
style: {
text: setting.label,
size: '14',
color: foregroundColor,
bgcolor: foregroundColorBlack,
},
steps: [
{
down: [
{
actionId: 'set_' + setting.id,
options: { value: setting.default },
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I normally provide say 5 presets from 0-100 with those values in the option and on the button (plus the feedback to show they're selected). Personally for me this preset is a bit pointless on it's own (and hard to test as an end user, as nothing will change).

},
],
up: [],
},
],
}
})

self.setPresetDefinitions(presets)
},
}
8 changes: 8 additions & 0 deletions src/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module.exports = {
variables.push({ variableId: 'input', name: 'Current Input' })
variables.push({ variableId: 'webAppState', name: 'Current Web App State' })
variables.push({ variableId: 'webAppUrl', name: 'Current Web App URL' })
variables.push({ variableId: 'color', name: 'Picture Settings - Color' })
variables.push({ variableId: 'brightness', name: 'Picture Settings - Brightness' })
variables.push({ variableId: 'contrast', name: 'Picture Settings - Contrast' })
variables.push({ variableId: 'sharpness', name: 'Picture Settings - Sharpness' })

self.setVariableDefinitions(variables)
},
Expand All @@ -25,6 +29,10 @@ module.exports = {
input: self.DATA.input,
webAppState: self.DATA.webAppState ? 'Active' : 'Inactive',
webAppUrl: self.DATA.webAppUrl,
color: self.DATA.color,
brightness: self.DATA.brightness,
contrast: self.DATA.contrast,
sharpness: self.DATA.sharpness,
})
} catch (error) {
self.log('error', 'Error setting variables: ' + error)
Expand Down