loupedeck-commander 1.2.10 → 1.2.12
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/common/ApplicationConfig.mjs +1 -1
- package/common/BaseLoupeDeckHandler.mjs +25 -9
- package/common/touchbuttons.mjs +80 -50
- package/config.json +4 -0
- package/interfaces/httpif.mjs +1 -1
- package/interfaces/opcuaif.mjs +1 -10
- package/interfaces/shellif.mjs +1 -1
- package/package.json +1 -1
- package/profile-1.json +5 -3
|
@@ -12,6 +12,7 @@ export class BaseLoupeDeckHandler {
|
|
|
12
12
|
knobs = {}
|
|
13
13
|
screenUpdate = {}
|
|
14
14
|
stopping = false
|
|
15
|
+
IntervalID = undefined
|
|
15
16
|
|
|
16
17
|
constructor (config) {
|
|
17
18
|
console.log(`INIT with config ${config}`)
|
|
@@ -83,10 +84,14 @@ export class BaseLoupeDeckHandler {
|
|
|
83
84
|
try {
|
|
84
85
|
console.info(`Closing Device`)
|
|
85
86
|
this.stopping = true
|
|
86
|
-
|
|
87
|
+
|
|
88
|
+
clearInterval(this.IntervalID)
|
|
89
|
+
|
|
90
|
+
/* if (this.device){
|
|
87
91
|
this.device.vibrate(HAPTIC.DESCEND_MED)
|
|
88
92
|
await new Promise(resolve => setTimeout(resolve, 250))
|
|
89
93
|
}
|
|
94
|
+
*/
|
|
90
95
|
if (this.device){
|
|
91
96
|
this.device.setBrightness(0)
|
|
92
97
|
await new Promise(resolve => setTimeout(resolve, 250))
|
|
@@ -97,11 +102,14 @@ export class BaseLoupeDeckHandler {
|
|
|
97
102
|
await new Promise(resolve => setTimeout(resolve, 2000))
|
|
98
103
|
console.info(`Device Closed`)
|
|
99
104
|
}
|
|
100
|
-
|
|
101
105
|
console.info(`Stopping interfaces`)
|
|
102
106
|
await StopInterfaces()
|
|
103
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
104
|
-
|
|
107
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
108
|
+
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.info(`e`,e)
|
|
111
|
+
|
|
112
|
+
}
|
|
105
113
|
|
|
106
114
|
process.exit()
|
|
107
115
|
|
|
@@ -163,7 +171,7 @@ export class BaseLoupeDeckHandler {
|
|
|
163
171
|
this.screenUpdate["center"] = true
|
|
164
172
|
this.screenUpdate["left"] = true
|
|
165
173
|
this.screenUpdate["right"] = true
|
|
166
|
-
await this.updateScreens()
|
|
174
|
+
//await this.updateScreens()
|
|
167
175
|
|
|
168
176
|
await this.buttons.draw(this.device)
|
|
169
177
|
// Initialize the Interfaces
|
|
@@ -207,7 +215,14 @@ export class BaseLoupeDeckHandler {
|
|
|
207
215
|
this.screenUpdate["center"] = true
|
|
208
216
|
this.screenUpdate["left"] = true
|
|
209
217
|
this.screenUpdate["right"] = true
|
|
210
|
-
await this.updateScreens()
|
|
218
|
+
//await this.updateScreens()
|
|
219
|
+
|
|
220
|
+
this.IntervalID = setInterval(() => {
|
|
221
|
+
// runs every 500ms seconds
|
|
222
|
+
this.screenUpdate["center"] = true
|
|
223
|
+
self.updateScreens()
|
|
224
|
+
}, 500);
|
|
225
|
+
|
|
211
226
|
|
|
212
227
|
console.info('✅ Done initializing')
|
|
213
228
|
}
|
|
@@ -219,6 +234,7 @@ export class BaseLoupeDeckHandler {
|
|
|
219
234
|
const keys = Object.keys(this.screenUpdate)
|
|
220
235
|
for (let i = 0; i < keys.length; i++) {
|
|
221
236
|
const screen = keys[i]
|
|
237
|
+
//ok = await this.screens.center.updateAllButtons()
|
|
222
238
|
await this.screens[screen].draw(this.device)
|
|
223
239
|
}
|
|
224
240
|
this.screenUpdate = {}
|
|
@@ -281,7 +297,7 @@ export class BaseLoupeDeckHandler {
|
|
|
281
297
|
if (this.screens[screen])
|
|
282
298
|
ok = await this.screens[screen].pressed(id)
|
|
283
299
|
}
|
|
284
|
-
await this.updateScreens()
|
|
300
|
+
//await this.updateScreens()
|
|
285
301
|
return ok
|
|
286
302
|
}
|
|
287
303
|
|
|
@@ -322,7 +338,7 @@ export class BaseLoupeDeckHandler {
|
|
|
322
338
|
if (this.screens[elem.screen])
|
|
323
339
|
ok = await this.screens[elem.screen].released(id)
|
|
324
340
|
}
|
|
325
|
-
await this.updateScreens()
|
|
341
|
+
//await this.updateScreens()
|
|
326
342
|
return ok
|
|
327
343
|
}
|
|
328
344
|
|
|
@@ -338,7 +354,7 @@ export class BaseLoupeDeckHandler {
|
|
|
338
354
|
ok = await this.screens.center.changed(buttonID,nodeid,val)
|
|
339
355
|
ok = await this.knobs.changed(buttonID,nodeid,val)
|
|
340
356
|
|
|
341
|
-
await this.updateScreens()
|
|
357
|
+
//await this.updateScreens()
|
|
342
358
|
return ok
|
|
343
359
|
}
|
|
344
360
|
|
package/common/touchbuttons.mjs
CHANGED
|
@@ -150,6 +150,7 @@ export class ButtonField {
|
|
|
150
150
|
let key = this.#keys[i]
|
|
151
151
|
if (!isNaN(key)) { key = parseInt(key, 10) }
|
|
152
152
|
if (id === key) { continue }
|
|
153
|
+
// console.log("group",this.#buttons[key].group,this.#buttons[id].group)
|
|
153
154
|
if (this.#buttons[key].group === this.#buttons[id].group) {
|
|
154
155
|
this.#buttons[key].setState(0)
|
|
155
156
|
}
|
|
@@ -199,13 +200,12 @@ export class Button {
|
|
|
199
200
|
|
|
200
201
|
#type = ButtonType.TOGGLE
|
|
201
202
|
|
|
202
|
-
#min = 0
|
|
203
|
-
#max = 100
|
|
204
203
|
#value = 50
|
|
205
204
|
#name = undefined
|
|
206
205
|
#nodeid = ""
|
|
207
206
|
|
|
208
207
|
#index = 0
|
|
208
|
+
#enforcedIndex = -1
|
|
209
209
|
#event
|
|
210
210
|
#keys
|
|
211
211
|
#states
|
|
@@ -228,8 +228,6 @@ export class Button {
|
|
|
228
228
|
timeStampReleased
|
|
229
229
|
// Time actually hold the button in ms
|
|
230
230
|
timeHold
|
|
231
|
-
// Minimum ammount of time in ms to press a button:
|
|
232
|
-
minPressed = 25
|
|
233
231
|
key = -1
|
|
234
232
|
|
|
235
233
|
constructor (id, width, height, data,key,profile) {
|
|
@@ -239,47 +237,58 @@ export class Button {
|
|
|
239
237
|
this.height = height
|
|
240
238
|
this.#index = 0
|
|
241
239
|
|
|
240
|
+
if (profile === undefined){
|
|
241
|
+
this.#profile = {}
|
|
242
|
+
this.#params = {
|
|
243
|
+
"min" : 0,
|
|
244
|
+
"max" : 100,
|
|
245
|
+
"minPressed": 25
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
}else{
|
|
249
|
+
this.#profile = profile
|
|
250
|
+
this.#params = profile.parameters
|
|
251
|
+
if (profile.parameters.min !== undefined)
|
|
252
|
+
this.#params.min = profile.parameters.min
|
|
253
|
+
if (profile.parameters.max !== undefined)
|
|
254
|
+
this.#params.max = profile.parameters.max
|
|
255
|
+
if (profile.parameters.minPressed !== undefined)
|
|
256
|
+
this.#params.minPressed = profile.parameters.minPressed
|
|
257
|
+
}
|
|
258
|
+
|
|
242
259
|
if (data && data.states) {
|
|
243
260
|
this.#data = data
|
|
244
|
-
|
|
245
|
-
this.group = data.group
|
|
246
|
-
|
|
247
261
|
this.#states = data.states
|
|
248
262
|
this.#keys = Object.keys(this.#states)
|
|
249
263
|
if (data.type) {
|
|
250
264
|
this.#type = data.type.toUpperCase()
|
|
265
|
+
console.log("TYPE",this.#type )
|
|
251
266
|
}
|
|
252
267
|
|
|
253
268
|
if (data.minPressed) {
|
|
254
|
-
this.minPressed = data.minPressed
|
|
269
|
+
this.#params.minPressed = data.minPressed
|
|
255
270
|
}
|
|
256
271
|
|
|
257
272
|
if (data.text) {
|
|
258
273
|
this.text = data.text
|
|
259
274
|
}
|
|
260
275
|
}
|
|
261
|
-
if (profile === undefined){
|
|
262
|
-
this.#profile = {}
|
|
263
|
-
this.#params = {}
|
|
264
|
-
}else{
|
|
265
|
-
this.#profile = profile
|
|
266
|
-
this.#params = profile.parameters
|
|
267
|
-
if (profile.parameters.min !== undefined)
|
|
268
|
-
this.#min = profile.parameters.min
|
|
269
|
-
if (profile.parameters.max !== undefined)
|
|
270
|
-
this.#max = profile.parameters.max
|
|
271
|
-
}
|
|
272
276
|
if (this.#states === undefined) {
|
|
273
277
|
this.#states = {}
|
|
274
278
|
this.#keys = []
|
|
275
279
|
}
|
|
276
280
|
if (data.nodeid){
|
|
277
|
-
this.#nodeid = format(data.nodeid, this
|
|
281
|
+
this.#nodeid = format(data.nodeid, this.getParams({}))
|
|
278
282
|
}
|
|
279
283
|
if (data.default) {
|
|
280
284
|
this.#index = this.#keys.indexOf(data.default)
|
|
281
285
|
}
|
|
282
286
|
|
|
287
|
+
if (data.group)
|
|
288
|
+
this.group = format(data.group, this.getParams({}))
|
|
289
|
+
else
|
|
290
|
+
this.group = key
|
|
291
|
+
|
|
283
292
|
}
|
|
284
293
|
|
|
285
294
|
setState (index = 0) {
|
|
@@ -314,6 +323,8 @@ export class Button {
|
|
|
314
323
|
|
|
315
324
|
const elem = this.getCurrentElement()
|
|
316
325
|
|
|
326
|
+
//console.log()
|
|
327
|
+
|
|
317
328
|
if (elem) {
|
|
318
329
|
if (elem.color) {
|
|
319
330
|
ctx.fillStyle = elem.color
|
|
@@ -331,7 +342,8 @@ export class Button {
|
|
|
331
342
|
ctx.font = '20px Verdana'
|
|
332
343
|
ctx.textBaseline = 'top';
|
|
333
344
|
ctx.textAlign = 'left';
|
|
334
|
-
|
|
345
|
+
let dynamicText = format(this.text, this.getParams(elem))
|
|
346
|
+
ctx.fillText(dynamicText,x+6,y+6)
|
|
335
347
|
}
|
|
336
348
|
}
|
|
337
349
|
|
|
@@ -376,22 +388,26 @@ export class Button {
|
|
|
376
388
|
pressed () {
|
|
377
389
|
this.timeStampPressed = Date.now()
|
|
378
390
|
|
|
379
|
-
this.#
|
|
391
|
+
if (this.#type != ButtonType.PUSH)
|
|
392
|
+
this.#index++
|
|
380
393
|
this.updateState(this.#index,"pressed")
|
|
394
|
+
//if (this.#type == ButtonType.PUSH)
|
|
395
|
+
// this.#index++
|
|
381
396
|
return true
|
|
382
397
|
}
|
|
383
398
|
|
|
384
399
|
released () {
|
|
385
|
-
|
|
400
|
+
let elem = this.getCurrentElement()
|
|
401
|
+
if (!elem) { return false }
|
|
386
402
|
this.timeStampReleased = Date.now()
|
|
387
403
|
this.timeHold = this.timeStampReleased - this.timeStampPressed
|
|
388
404
|
|
|
389
|
-
|
|
405
|
+
let bExecute = true
|
|
406
|
+
if (this.timeHold < this.#params.minPressed) {
|
|
390
407
|
// Update the State according to the not correct pressed state
|
|
391
|
-
console.log('Did not hold minimum time of ', this.minPressed, 'only', this.timeHold)
|
|
392
|
-
this.#index--
|
|
408
|
+
console.log('Did not hold minimum time of ', this.#params.minPressed, 'only', this.timeHold)
|
|
393
409
|
if (this.#index < 0) { this.#index = this.#keys.length - 1 }
|
|
394
|
-
|
|
410
|
+
bExecute = false
|
|
395
411
|
}
|
|
396
412
|
|
|
397
413
|
// Update the State according to the correctly pressed state
|
|
@@ -399,14 +415,20 @@ export class Button {
|
|
|
399
415
|
case ButtonType.TOGGLE:
|
|
400
416
|
// do nothing
|
|
401
417
|
break
|
|
418
|
+
case ButtonType.PUSH:
|
|
419
|
+
// do nothing
|
|
420
|
+
//break
|
|
402
421
|
default:
|
|
403
422
|
this.#index--
|
|
404
423
|
if (this.#index < 0) { this.#index = this.#keys.length - 1 }
|
|
405
|
-
|
|
406
424
|
break
|
|
407
425
|
}
|
|
408
426
|
|
|
409
|
-
|
|
427
|
+
if (this.#enforcedIndex>=0)
|
|
428
|
+
this.#index = this.#enforcedIndex
|
|
429
|
+
|
|
430
|
+
if (bExecute)
|
|
431
|
+
this.updateState(this.#index,"released")
|
|
410
432
|
|
|
411
433
|
return true // this.runCommand()
|
|
412
434
|
}
|
|
@@ -426,7 +448,7 @@ export class Button {
|
|
|
426
448
|
if (!this.getCurrentElement()) { return false }
|
|
427
449
|
|
|
428
450
|
this.#event = "rotated"
|
|
429
|
-
this.#value = calcDelta(this.#value, delta, this.#min, this.#max)
|
|
451
|
+
this.#value = calcDelta(this.#value, delta, this.#params.min, this.#params.max)
|
|
430
452
|
return this.runCommand()
|
|
431
453
|
}
|
|
432
454
|
|
|
@@ -437,11 +459,13 @@ export class Button {
|
|
|
437
459
|
}
|
|
438
460
|
|
|
439
461
|
this.#index = 0;
|
|
462
|
+
this.#enforcedIndex = -1;
|
|
440
463
|
for (let i = 0; i < this.#keys.length; i++) {
|
|
441
464
|
let key = this.#keys[i]
|
|
442
465
|
// check if the state-name is same as the value we get from outside:
|
|
443
466
|
if (val == key){
|
|
444
467
|
this.#index = i;
|
|
468
|
+
this.#enforcedIndex = this.#index;
|
|
445
469
|
break;
|
|
446
470
|
}
|
|
447
471
|
|
|
@@ -493,6 +517,31 @@ export class Button {
|
|
|
493
517
|
return false
|
|
494
518
|
}
|
|
495
519
|
|
|
520
|
+
getParams(elem){
|
|
521
|
+
// Call an action - include dynamic parameters
|
|
522
|
+
// and also all attributes of elem + global config
|
|
523
|
+
const params = {
|
|
524
|
+
text: this.getCurrentText(),
|
|
525
|
+
...this.#profile.parameters,
|
|
526
|
+
...this.#params,
|
|
527
|
+
...elem,
|
|
528
|
+
id: this.id,
|
|
529
|
+
key: this.key,
|
|
530
|
+
event: this.#event,
|
|
531
|
+
pressed : this.#event == "pressed",
|
|
532
|
+
released : this.#event == "released",
|
|
533
|
+
rotated : this.#event == "rotated",
|
|
534
|
+
state: this.#keys[this.#index],
|
|
535
|
+
x: (this.#x %100),
|
|
536
|
+
y: (this.#y %100)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (params.value === undefined)
|
|
540
|
+
params.value = this.#value
|
|
541
|
+
|
|
542
|
+
return params
|
|
543
|
+
}
|
|
544
|
+
|
|
496
545
|
async runCommand () {
|
|
497
546
|
const elem = this.getCurrentElement()
|
|
498
547
|
// Only continue, if we have an element:
|
|
@@ -513,26 +562,7 @@ export class Button {
|
|
|
513
562
|
return
|
|
514
563
|
}
|
|
515
564
|
|
|
516
|
-
|
|
517
|
-
// and also all attributes of elem + global config
|
|
518
|
-
const params = {
|
|
519
|
-
text: this.getCurrentText(),
|
|
520
|
-
...this.#profile.parameters,
|
|
521
|
-
...elem,
|
|
522
|
-
id: this.id,
|
|
523
|
-
key: this.key,
|
|
524
|
-
event: this.#event,
|
|
525
|
-
state: this.#keys[this.#index],
|
|
526
|
-
min: this.#min,
|
|
527
|
-
max: this.#max,
|
|
528
|
-
x: (this.#x %100),
|
|
529
|
-
y: (this.#y %100)
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (params.value === undefined)
|
|
533
|
-
params.value = this.#value
|
|
534
|
-
|
|
535
|
-
|
|
565
|
+
let params = this.getParams(elem)
|
|
536
566
|
let res = ''
|
|
537
567
|
if ('cmd' in elem) {
|
|
538
568
|
if (shellinterface){
|
package/config.json
CHANGED
package/interfaces/httpif.mjs
CHANGED
package/interfaces/opcuaif.mjs
CHANGED
|
@@ -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/interfaces/shellif.mjs
CHANGED
package/package.json
CHANGED
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":
|
|
270
|
+
"verbose": false
|
|
269
271
|
}
|
|
270
272
|
}
|