generated from thinkode/modelRepository
23-os2l (#32)
Implements the OS2L feature (tested with Virtual DJ). Graphics improvements. Reviewed-on: #32
This commit was merged in pull request #32.
This commit is contained in:
@@ -120,6 +120,32 @@ function unloadPeripheral (peripheralInfo) {
|
||||
needProjectSave.set(true)
|
||||
}
|
||||
|
||||
// A peripheral event has been emitted
|
||||
function onPeripheralEvent(sn, event) {
|
||||
// If not exists, add it to the map
|
||||
// eventEmitted key to true for 0.2 sec
|
||||
|
||||
peripherals.update((storedPeripherals) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
[sn]: {
|
||||
...storedPeripherals[sn],
|
||||
eventEmitted: true
|
||||
},
|
||||
}})
|
||||
|
||||
setTimeout(() => {
|
||||
peripherals.update((storedPeripherals) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
[sn]: {
|
||||
...storedPeripherals[sn],
|
||||
eventEmitted: false
|
||||
},
|
||||
}})
|
||||
}, 200);
|
||||
}
|
||||
|
||||
let initialized = false
|
||||
|
||||
export function initRuntimeEvents(){
|
||||
@@ -143,6 +169,9 @@ export function initRuntimeEvents(){
|
||||
|
||||
// Handle a peripheral unloaded from the project
|
||||
EventsOn('UNLOAD_PERIPHERAL', unloadPeripheral)
|
||||
|
||||
// Handle a peripheral event
|
||||
EventsOn('PERIPHERAL_EVENT_EMITTED', onPeripheralEvent)
|
||||
}
|
||||
|
||||
export function destroyRuntimeEvents(){
|
||||
@@ -166,4 +195,7 @@ export function destroyRuntimeEvents(){
|
||||
|
||||
// Handle a peripheral unloaded from the project
|
||||
EventsOff('UNLOAD_PERIPHERAL')
|
||||
|
||||
// Handle a peripheral event
|
||||
EventsOff('PERIPHERAL_EVENT_EMITTED')
|
||||
}
|
||||
Reference in New Issue
Block a user