Closed tekmaven closed 4 years ago
Which parts of the logic are you looking have in the library?
I want to plug in the notification parameters (color, intensity, etc) and get the resulting configuration value returned.
Sorry this took so long to get back to, but the real core of the notification calculation is these two functions:
const longToByteArray = function (/*long*/ long) {
// we want to represent the input as a 8-bytes array
var byteArray = [0, 0, 0, 0];
for (var index = 0; index < byteArray.length; index++) {
var byte = long & 0xff;
byteArray[index] = byte;
long = (long - byte) / 256;
}
return byteArray;
};
const byteArrayToLong = function (/*byte[]*/ byteArray) {
var value = 0;
for (var i = byteArray.length - 1; i >= 0; i--) {
value = value * 256 + byteArray[i];
}
return value;
};
You can pass an array of values in the order described in Inovelli's docuemts to the byteArrayToLong
function and it will give you the single value, while the other function, longToByteArray
, will take a single notification number and transfer it back into an array of configuration values. Since these two functions don't amount to too much I don't feel it necessary to create a library at this time. In the future, I may pursues this, but feel free to re-use any of the code or references if you would like to create a library based on this.
I really enjoy this tool! Great job!
I would like to use the logic with my own code. It would be awesome to provide this as an NPM package.