Branje baterije in dogodki/s

master
root 2024-07-25 17:36:42 +00:00
parent 5cd54c0abf
commit e70e70a728
1 changed files with 21 additions and 2 deletions

View File

@ -36,7 +36,7 @@ const senzorCCkalibracija = {
}
const DEBUG = {
midi: true,
midi: false,
osc: false
}
@ -77,6 +77,12 @@ const muteMidi = {
3: 0
}
// Stetje prejetih paketov (na sekundo)
let cas = 0;
let baterija = 0;
let stPaketov = 0;
let stPaketovNaSekundo = 0;
// Midi controller input
const mi = new midi.Input()
mi.openVirtualPort("danijela-midi")
@ -178,7 +184,8 @@ oscWS.on('message', ({ address, args }) => {
const index = parseInt(m[1])
const addr = m[2]
if (addr == 'euler') {
if (addr == 'bat') {
baterija = args[0]
}
if (addr == 'accel') {
@ -236,6 +243,18 @@ oscWS.on('message', ({ address, args }) => {
posljiMidi(182, midiKanalSenzor[index], vrtenjeZmidi)
staroVrtenjeZMidi[index] = vrtenjeZmidi
}
// Vsako sekundo shranimo stevec
stPaketov += 1
if (Date.now() - cas > 1000) {
cas = Date.now()
stPaketovNaSekundo = stPaketov;
stPaketov = 0;
// 0.086 prazna baterija
}
console.log('st paketov na sekundo: ', stPaketovNaSekundo);
console.log('baterija: ', bat);
}
}
})