loupedeck-commander 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,8 +42,8 @@ npm install -s loupedeck-commander
42
42
  Create a new configuration file with at least one profile or copy from here,
43
43
  and replace the image references with your own icons (90x90px size):
44
44
 
45
- - [config.json](https://gitlab.com/keckxde/loupedeck-commander/-/blob/main/config.json)
46
- - [profile-1.json](https://gitlab.com/keckxde/loupedeck-commander/-/blob/main/profile-1.json)
45
+ - [config.yaml](https://gitlab.com/keckxde/loupedeck-commander/-/blob/main/config.yaml)
46
+ - [profile-1.yaml](https://gitlab.com/keckxde/loupedeck-commander/-/blob/main/profile-1.yaml)
47
47
 
48
48
  Create a `index.mjs` file to open up your loupedeck connection:
49
49
 
@@ -51,7 +51,7 @@ Create a `index.mjs` file to open up your loupedeck connection:
51
51
  # save as index.mjs
52
52
  import { BaseLoupeDeckHandler } from 'loupedeck-commander'
53
53
 
54
- const handler = new BaseLoupeDeckHandler('config.json')
54
+ const handler = new BaseLoupeDeckHandler('config.yaml')
55
55
 
56
56
  /**
57
57
  * Stop the handlers when a signal like SIGINT or SIGTERM arrive
@@ -1,4 +1,4 @@
1
- import { readJSONFile, writeJSONFile,syncParams } from './utils.mjs'
1
+ import { readConfigFile as readConfigFile, writeJSONFile,syncParams, writeYAMLFile } from './utils.mjs'
2
2
 
3
3
  export class ApplicationConfig {
4
4
  application = 'undefined'
@@ -7,7 +7,8 @@ export class ApplicationConfig {
7
7
 
8
8
  loadFromFile (fileName) {
9
9
  console.info(`ApplicationConfig: Loading Config File ${fileName}`)
10
- const config = readJSONFile(fileName)
10
+ const config = readConfigFile(fileName)
11
+
11
12
 
12
13
  if (!config){
13
14
  console.info(`ApplicationConfig: Could not read/parse Config File ${fileName} - breaking here`)
@@ -66,7 +67,7 @@ class Profile {
66
67
 
67
68
  loadFromFile (fileName) {
68
69
  console.info(`ProfileConfig: Loading Profile File ${fileName}, Index ${this.#index}`)
69
- const config = readJSONFile(fileName)
70
+ const config = readConfigFile(fileName)
70
71
  if (config === undefined) {
71
72
  console.warn(`ProfileConfig: Cannot parse/load Profile File ${fileName}`)
72
73
  return false
@@ -105,7 +106,13 @@ class Profile {
105
106
  fileName = fileName.toLowerCase()
106
107
 
107
108
  console.info(`ProfileConfig: Save To Config File ${fileName}`)
108
- writeJSONFile(fileName, this)
109
+ if(fileName.endsWith('.json')) {
110
+ writeJSONFile(fileName, this)
111
+ writeYAMLFile(fileName.replace('.json','.yaml'), this)
112
+ }else if(fileName.endsWith('.yaml')) {
113
+ writeYAMLFile(fileName, this)
114
+ writeJSONFile(fileName.replace('.yaml','.json'), this)
115
+ }
109
116
  }
110
117
  }
111
118
 
@@ -219,7 +219,7 @@ export class BaseLoupeDeckHandler {
219
219
  const self = this
220
220
 
221
221
  // Register callback on monitored item change:
222
- opcuainterface.on("monitored item changed",(buttonID,nodeid,val) => { self.buttonStateChanged(buttonID,nodeid,val) })
222
+ opcuainterface.on("monitored item changed",(buttonID,attribute,nodeid,val) => { self.buttonStateChanged(buttonID,attribute,nodeid,val) })
223
223
  profileEmitter.on("profileChanged",(profileID) => { self.activateProfile(profileID) })
224
224
  profileEmitter.on("brightnessChanged",(brightness) => { self.changeBrightness(brightness) })
225
225
  profileEmitter.on("vibrate",(pattern) => { self.vibrate(pattern) })
@@ -364,14 +364,14 @@ export class BaseLoupeDeckHandler {
364
364
  /**
365
365
  * Handler for StateChanged through OPC/UA Interface - only connected with touch-buttons on center field (yet)
366
366
  */
367
- async buttonStateChanged(buttonID,nodeid,val) {
367
+ async buttonStateChanged(buttonID,attribute,nodeid,val) {
368
368
  let ok = false
369
369
  this.screenUpdate["center"] = true
370
370
  this.screenUpdate["left"] = true
371
371
  this.screenUpdate["right"] = true
372
372
 
373
- ok = await this.screens.center.changed(buttonID,nodeid,val)
374
- ok = await this.knobs.changed(buttonID,nodeid,val)
373
+ ok = await this.screens.center.buttonStateChanged(buttonID,attribute,nodeid,val)
374
+ ok = await this.knobs.buttonStateChanged(buttonID,attribute,nodeid,val)
375
375
 
376
376
  //await this.updateScreens()
377
377
  return ok
@@ -97,8 +97,13 @@ export class ButtonField {
97
97
  for (let i = 0; i < this.#keys.length; i++) {
98
98
  let key = this.#keys[i]
99
99
  if (!isNaN(key)) { key = parseInt(key, 10) }
100
+ // Ignore for myself (active element of the group)
100
101
  if (id === key) { continue }
101
- if (this.#buttons[key].group === this.#buttons[id].group) {
102
+ let toggleGroup = this.#buttons[id].getGroup()
103
+ // Ignore empty groups
104
+ if (toggleGroup === undefined || toggleGroup == "" ) { continue }
105
+ // Switch all other elements of the same group off:
106
+ if (this.#buttons[key].getGroup() === toggleGroup) {
102
107
  this.#buttons[key].setState(0)
103
108
  }
104
109
  }
@@ -115,10 +120,12 @@ export class ButtonField {
115
120
  * @param {*} nodeid
116
121
  * @param {*} val
117
122
  */
118
- async changed(buttonID,nodeid,val){
123
+ async buttonStateChanged(changedButtonID,attribute,nodeid,val){
124
+ // todo: filter for buttonID
119
125
  for (let i = 0; i < this.#keys.length; i++) {
120
- let bID = this.#keys[i]
121
- await this.#buttons[bID].changed(i,nodeid,val)
126
+ let buttonID = this.#keys[i]
127
+ if (changedButtonID == buttonID)
128
+ await this.#buttons[buttonID].buttonStateChanged(i,attribute,nodeid,val)
122
129
  }
123
130
  }
124
131