loupedeck-commander 1.2.10 → 1.2.11

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.
@@ -256,7 +256,7 @@ class ParametersConfig {
256
256
 
257
257
  class DefaultConfig {
258
258
  default = {
259
- "filter": "released",
259
+ // "filter": "released",
260
260
  "color": "#111111"
261
261
  }
262
262
 
@@ -83,10 +83,12 @@ export class BaseLoupeDeckHandler {
83
83
  try {
84
84
  console.info(`Closing Device`)
85
85
  this.stopping = true
86
- if (this.device){
86
+
87
+ /* if (this.device){
87
88
  this.device.vibrate(HAPTIC.DESCEND_MED)
88
89
  await new Promise(resolve => setTimeout(resolve, 250))
89
90
  }
91
+ */
90
92
  if (this.device){
91
93
  this.device.setBrightness(0)
92
94
  await new Promise(resolve => setTimeout(resolve, 250))
@@ -97,11 +99,14 @@ export class BaseLoupeDeckHandler {
97
99
  await new Promise(resolve => setTimeout(resolve, 2000))
98
100
  console.info(`Device Closed`)
99
101
  }
100
-
101
102
  console.info(`Stopping interfaces`)
102
103
  await StopInterfaces()
103
- await new Promise(resolve => setTimeout(resolve, 500))
104
- } catch (e) {}
104
+ await new Promise(resolve => setTimeout(resolve, 1000))
105
+
106
+ } catch (e) {
107
+ console.info(`e`,e)
108
+
109
+ }
105
110
 
106
111
  process.exit()
107
112
 
@@ -331,7 +331,8 @@ export class Button {
331
331
  ctx.font = '20px Verdana'
332
332
  ctx.textBaseline = 'top';
333
333
  ctx.textAlign = 'left';
334
- ctx.fillText(this.text,x+6,y+6)
334
+ let dynamicText = format(this.text, this.getParams(elem))
335
+ ctx.fillText(dynamicText,x+6,y+6)
335
336
  }
336
337
  }
337
338
 
@@ -382,7 +383,8 @@ export class Button {
382
383
  }
383
384
 
384
385
  released () {
385
- if (!this.getCurrentElement()) { return false }
386
+ let elem = this.getCurrentElement()
387
+ if (!elem) { return false }
386
388
  this.timeStampReleased = Date.now()
387
389
  this.timeHold = this.timeStampReleased - this.timeStampPressed
388
390
 
@@ -493,26 +495,7 @@ export class Button {
493
495
  return false
494
496
  }
495
497
 
496
- async runCommand () {
497
- const elem = this.getCurrentElement()
498
- // Only continue, if we have an element:
499
- if (!elem) {
500
- return
501
- }
502
- // Filter for Event Type:
503
- if (elem.filter && elem.filter != this.#event){
504
- return
505
- }
506
-
507
- if (elem.profile !== undefined) {
508
- profileEmitter.emit("profileChanged", elem.profile)
509
- }
510
-
511
- // Only continue, if we have an element, that contains some kind of command:
512
- if (!elem.cmd && !elem.http && !elem.opcua) {
513
- return
514
- }
515
-
498
+ getParams(elem){
516
499
  // Call an action - include dynamic parameters
517
500
  // and also all attributes of elem + global config
518
501
  const params = {
@@ -522,6 +505,9 @@ export class Button {
522
505
  id: this.id,
523
506
  key: this.key,
524
507
  event: this.#event,
508
+ pressed : this.#event == "pressed",
509
+ released : this.#event == "released",
510
+ rotated : this.#event == "rotated",
525
511
  state: this.#keys[this.#index],
526
512
  min: this.#min,
527
513
  max: this.#max,
@@ -532,7 +518,30 @@ export class Button {
532
518
  if (params.value === undefined)
533
519
  params.value = this.#value
534
520
 
521
+ return params
522
+ }
523
+
524
+ async runCommand () {
525
+ const elem = this.getCurrentElement()
526
+ // Only continue, if we have an element:
527
+ if (!elem) {
528
+ return
529
+ }
530
+ // Filter for Event Type:
531
+ if (elem.filter && elem.filter != this.#event){
532
+ return
533
+ }
534
+
535
+ if (elem.profile !== undefined) {
536
+ profileEmitter.emit("profileChanged", elem.profile)
537
+ }
538
+
539
+ // Only continue, if we have an element, that contains some kind of command:
540
+ if (!elem.cmd && !elem.http && !elem.opcua) {
541
+ return
542
+ }
535
543
 
544
+ let params = this.getParams(elem)
536
545
  let res = ''
537
546
  if ('cmd' in elem) {
538
547
  if (shellinterface){
package/config.json CHANGED
@@ -4,6 +4,10 @@
4
4
  {
5
5
  "name": "profile-1",
6
6
  "file": "profile-1.json"
7
+ },
8
+ {
9
+ "name": "profile-2",
10
+ "file": "profile-2.json"
7
11
  }
8
12
  ]
9
13
  }
@@ -39,19 +39,12 @@ export class OPCUAIf extends BaseIf {
39
39
  buttons
40
40
  constructor() {
41
41
  super()
42
-
43
- this.LogInfo(`OPCUAIf Constructed`);
44
42
  }
45
43
 
46
44
  async stop() {
47
45
  if (!this.#client)
48
46
  return
49
-
50
- this.LogInfo(`OPCUAIf Stopping\n`)
51
- await this.#client.closeSession(this.#session, true)
52
- await this.#client.disconnect()
53
- this.#connected = false
54
- this.#client = null
47
+ await this.Disconnect()
55
48
  this.LogInfo(`OPCUAIf Stopped\n`)
56
49
  }
57
50
 
@@ -223,7 +216,6 @@ export class OPCUAIf extends BaseIf {
223
216
 
224
217
  async Disconnect() {
225
218
  if (this.#client) {
226
- this.LogInfo(`OPCUAIf: Disconnect\n`);
227
219
  if (this.#session)
228
220
  await this.#client.closeSession(this.#session,true)
229
221
  this.#session = undefined
@@ -234,7 +226,6 @@ export class OPCUAIf extends BaseIf {
234
226
  async Connect(url) {
235
227
  let self = this
236
228
  if (this.#client){
237
- console.log("Closing session first")
238
229
  await this.Disconnect()
239
230
  }
240
231
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loupedeck-commander",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "A system to ease working with LoupeDeck devices using CMD-line, OPC/UA or HTTP-client interfaces",
5
5
  "main": "index.mjs",
6
6
  "scripts": {
package/profile-1.json CHANGED
@@ -24,14 +24,16 @@
24
24
  "off": {
25
25
  "color": "#000099",
26
26
  "image": "icons/home.png",
27
- "cmd": "echo \"{id} {state}\""
27
+ "cmd": "echo \"{id} {state} {pressed}\""
28
28
  },
29
29
  "on": {
30
30
  "color": "#00ff00",
31
31
  "image": "icons/home.png",
32
- "cmd": "echo \"{id} {state}\""
32
+ "cmd": "echo \"{id} {state} {pressed}\""
33
33
  }
34
34
  },
35
+ "minPressed" : 10000,
36
+ "text" : "{released}",
35
37
  "group": ""
36
38
  },
37
39
  "2": {
@@ -265,6 +267,6 @@
265
267
  "endpointurl": "opc.tcp://{hostname}:4840",
266
268
  "publishingInterval" : 200,
267
269
  "nodeid" : "ns=0;s=nodeID",
268
- "verbose": true
270
+ "verbose": false
269
271
  }
270
272
  }