I can't figure out how to use the setTimeout() function and my brain is about to explode. So, I give up.
Can you please describe what you mean exactly by the word callback? In documentation you say that it's a function to be executed. What function? The one that needs to be delayed? (ie. the send() function?)
} if (value === 1 && option_1 === 127) {
send('/note', 6, myString1, 127)
send('/note', 2, 85, 127) // this needs to be delayed
}
(in context)
var num = getProp('this', 'id').replace(/[^0-9]/g,'');
var option_1 = get("option_1")
var option_2 = get("option_2")
let myString1 = parseFloat(num)-1;
// (when the push button is 1)
if (value === 1 && option_1 === 1) {
send('/note', 6, myString1, 127)
} else if (value === 1 && option_1 === 127) {
send('/note', 6, myString1, 127)
send('/note', 2, 85, 127) // this needs to be delayed
// (when the push button is 0)
} else if (value === 0 && option_2 === 1) {
send('/note', 2, 86, 127)
} else if (value === 0 && option_2 === 2) {
send('/note', 2, 87, 127)
} else if (value === 0 && option_2 === 3) {
send('/note', 2, 88, 127)
}
Here's what I've tried:
(copiable code)
var num = getProp('this', 'id').replace(/[^0-9]/g,'');
var option_1 = get("option_1")
var option_2 = get("option_2")
let myString1 = parseFloat(num)-1;
// I've created a function
function actNP() {
send('/note', 2, 85, 127)
}
if (value === 1 && option_1 === 1) {
send('/note', 6, myString1, 127)
// And I've referenced it here:
} else if (value === 1 && option_1 === 127) {
send('/note', 6, myString1, 127)
setTimeout(1, actNP(), 50)
} else if (value === 0 && option_2 === 1) {
send('/note', 2, 86, 127)
} else if (value === 0 && option_2 === 2) {
send('/note', 2, 87, 127)
} else if (value === 0 && option_2 === 3) {
send('/note', 2, 88, 127)
}