loupedeck-commander 1.2.11 → 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.
|
@@ -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}`)
|
|
@@ -84,6 +85,8 @@ export class BaseLoupeDeckHandler {
|
|
|
84
85
|
console.info(`Closing Device`)
|
|
85
86
|
this.stopping = true
|
|
86
87
|
|
|
88
|
+
clearInterval(this.IntervalID)
|
|
89
|
+
|
|
87
90
|
/* if (this.device){
|
|
88
91
|
this.device.vibrate(HAPTIC.DESCEND_MED)
|
|
89
92
|
await new Promise(resolve => setTimeout(resolve, 250))
|
|
@@ -168,7 +171,7 @@ export class BaseLoupeDeckHandler {
|
|
|
168
171
|
this.screenUpdate["center"] = true
|
|
169
172
|
this.screenUpdate["left"] = true
|
|
170
173
|
this.screenUpdate["right"] = true
|
|
171
|
-
await this.updateScreens()
|
|
174
|
+
//await this.updateScreens()
|
|
172
175
|
|
|
173
176
|
await this.buttons.draw(this.device)
|
|
174
177
|
// Initialize the Interfaces
|
|
@@ -212,7 +215,14 @@ export class BaseLoupeDeckHandler {
|
|
|
212
215
|
this.screenUpdate["center"] = true
|
|
213
216
|
this.screenUpdate["left"] = true
|
|
214
217
|
this.screenUpdate["right"] = true
|
|
215
|
-
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
|
+
|
|
216
226
|
|
|
217
227
|
console.info('✅ Done initializing')
|
|
218
228
|
}
|
|
@@ -224,6 +234,7 @@ export class BaseLoupeDeckHandler {
|
|
|
224
234
|
const keys = Object.keys(this.screenUpdate)
|
|
225
235
|
for (let i = 0; i < keys.length; i++) {
|
|
226
236
|
const screen = keys[i]
|
|
237
|
+
//ok = await this.screens.center.updateAllButtons()
|
|
227
238
|
await this.screens[screen].draw(this.device)
|
|
228
239
|
}
|
|
229
240
|
this.screenUpdate = {}
|
|
@@ -286,7 +297,7 @@ export class BaseLoupeDeckHandler {
|
|
|
286
297
|
if (this.screens[screen])
|
|
287
298
|
ok = await this.screens[screen].pressed(id)
|
|
288
299
|
}
|
|
289
|
-
await this.updateScreens()
|
|
300
|
+
//await this.updateScreens()
|
|
290
301
|
return ok
|
|
291
302
|
}
|
|
292
303
|
|
|
@@ -327,7 +338,7 @@ export class BaseLoupeDeckHandler {
|
|
|
327
338
|
if (this.screens[elem.screen])
|
|
328
339
|
ok = await this.screens[elem.screen].released(id)
|
|
329
340
|
}
|
|
330
|
-
await this.updateScreens()
|
|
341
|
+
//await this.updateScreens()
|
|
331
342
|
return ok
|
|
332
343
|
}
|
|
333
344
|
|
|
@@ -343,7 +354,7 @@ export class BaseLoupeDeckHandler {
|
|
|
343
354
|
ok = await this.screens.center.changed(buttonID,nodeid,val)
|
|
344
355
|
ok = await this.knobs.changed(buttonID,nodeid,val)
|
|
345
356
|
|
|
346
|
-
await this.updateScreens()
|
|
357
|
+
//await this.updateScreens()
|
|
347
358
|
return ok
|
|
348
359
|
}
|
|
349
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
|
|
@@ -377,8 +388,11 @@ export class Button {
|
|
|
377
388
|
pressed () {
|
|
378
389
|
this.timeStampPressed = Date.now()
|
|
379
390
|
|
|
380
|
-
this.#
|
|
391
|
+
if (this.#type != ButtonType.PUSH)
|
|
392
|
+
this.#index++
|
|
381
393
|
this.updateState(this.#index,"pressed")
|
|
394
|
+
//if (this.#type == ButtonType.PUSH)
|
|
395
|
+
// this.#index++
|
|
382
396
|
return true
|
|
383
397
|
}
|
|
384
398
|
|
|
@@ -388,12 +402,12 @@ export class Button {
|
|
|
388
402
|
this.timeStampReleased = Date.now()
|
|
389
403
|
this.timeHold = this.timeStampReleased - this.timeStampPressed
|
|
390
404
|
|
|
391
|
-
|
|
405
|
+
let bExecute = true
|
|
406
|
+
if (this.timeHold < this.#params.minPressed) {
|
|
392
407
|
// Update the State according to the not correct pressed state
|
|
393
|
-
console.log('Did not hold minimum time of ', this.minPressed, 'only', this.timeHold)
|
|
394
|
-
this.#index--
|
|
408
|
+
console.log('Did not hold minimum time of ', this.#params.minPressed, 'only', this.timeHold)
|
|
395
409
|
if (this.#index < 0) { this.#index = this.#keys.length - 1 }
|
|
396
|
-
|
|
410
|
+
bExecute = false
|
|
397
411
|
}
|
|
398
412
|
|
|
399
413
|
// Update the State according to the correctly pressed state
|
|
@@ -401,14 +415,20 @@ export class Button {
|
|
|
401
415
|
case ButtonType.TOGGLE:
|
|
402
416
|
// do nothing
|
|
403
417
|
break
|
|
418
|
+
case ButtonType.PUSH:
|
|
419
|
+
// do nothing
|
|
420
|
+
//break
|
|
404
421
|
default:
|
|
405
422
|
this.#index--
|
|
406
423
|
if (this.#index < 0) { this.#index = this.#keys.length - 1 }
|
|
407
|
-
|
|
408
424
|
break
|
|
409
425
|
}
|
|
410
426
|
|
|
411
|
-
|
|
427
|
+
if (this.#enforcedIndex>=0)
|
|
428
|
+
this.#index = this.#enforcedIndex
|
|
429
|
+
|
|
430
|
+
if (bExecute)
|
|
431
|
+
this.updateState(this.#index,"released")
|
|
412
432
|
|
|
413
433
|
return true // this.runCommand()
|
|
414
434
|
}
|
|
@@ -428,7 +448,7 @@ export class Button {
|
|
|
428
448
|
if (!this.getCurrentElement()) { return false }
|
|
429
449
|
|
|
430
450
|
this.#event = "rotated"
|
|
431
|
-
this.#value = calcDelta(this.#value, delta, this.#min, this.#max)
|
|
451
|
+
this.#value = calcDelta(this.#value, delta, this.#params.min, this.#params.max)
|
|
432
452
|
return this.runCommand()
|
|
433
453
|
}
|
|
434
454
|
|
|
@@ -439,11 +459,13 @@ export class Button {
|
|
|
439
459
|
}
|
|
440
460
|
|
|
441
461
|
this.#index = 0;
|
|
462
|
+
this.#enforcedIndex = -1;
|
|
442
463
|
for (let i = 0; i < this.#keys.length; i++) {
|
|
443
464
|
let key = this.#keys[i]
|
|
444
465
|
// check if the state-name is same as the value we get from outside:
|
|
445
466
|
if (val == key){
|
|
446
467
|
this.#index = i;
|
|
468
|
+
this.#enforcedIndex = this.#index;
|
|
447
469
|
break;
|
|
448
470
|
}
|
|
449
471
|
|
|
@@ -501,6 +523,7 @@ export class Button {
|
|
|
501
523
|
const params = {
|
|
502
524
|
text: this.getCurrentText(),
|
|
503
525
|
...this.#profile.parameters,
|
|
526
|
+
...this.#params,
|
|
504
527
|
...elem,
|
|
505
528
|
id: this.id,
|
|
506
529
|
key: this.key,
|
|
@@ -509,8 +532,6 @@ export class Button {
|
|
|
509
532
|
released : this.#event == "released",
|
|
510
533
|
rotated : this.#event == "rotated",
|
|
511
534
|
state: this.#keys[this.#index],
|
|
512
|
-
min: this.#min,
|
|
513
|
-
max: this.#max,
|
|
514
535
|
x: (this.#x %100),
|
|
515
536
|
y: (this.#y %100)
|
|
516
537
|
}
|
package/interfaces/httpif.mjs
CHANGED
package/interfaces/shellif.mjs
CHANGED