Skip to content

Commit

Permalink
Merge pull request #391 from mStirner/dev
Browse files Browse the repository at this point in the history
Fixing nightly bugs from dev system
  • Loading branch information
mStirner committed Dec 30, 2023
2 parents abc4dfb + 28108d5 commit 185a480
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
7 changes: 6 additions & 1 deletion components/endpoints/class.command.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,18 @@ module.exports = class Command {
* @param {Array} [params] Parameter array
* @param {Function} [cb] Callback
*/
trigger(params, cb = () => { }) {
trigger(params, cb) {

if (!cb && params instanceof Function) {
cb = params;
params = [];
}

if (!params && !cb) {
params = [];
cb = () => { };
}

let worker = this.#privates.get("handler");
let iface = interfaces.get(this.interface);

Expand Down
9 changes: 8 additions & 1 deletion components/scenes/makro-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ module.exports = {
"component": "endpoints",
"item": endpoint,
"method": "trigger",
"args": [command]
"args": [command, () => {

//console.log("Command executed adasdasdfasdfasdfasfdadsfasdf", err || success)
// how should this be catched?
// reject the makro execution if one command fails?
// or ignore it simple, and continue?

}]
});

resolve(_id);
Expand Down
28 changes: 28 additions & 0 deletions helper/map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @function map
* Maps a range to another range
*
* @param {Number} value
* @param {Number} low1
* @param {Number} high1
* @param {Number} low2
* @param {Number} high2
*
* @example
* ```js
* // convert hex to mb
* console.log(map(255, 0, 255, 0, 1024)); // 1024
* ```
*
* @example
* ```js
* console.log(map(128, 0, 255, 0, 1024)); // 512
* ```
*
* @returns {Number} Convert input number
*/
function map(value, low1, high1, low2, high2) {
return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
}

module.exports = map;
2 changes: 1 addition & 1 deletion system/component/class.item.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = class Item {
}
});

let labels = new Labels(...obj.labels);
let labels = new Labels(...obj.labels || []);

Object.defineProperty(this, "labels", {
get() {
Expand Down

0 comments on commit 185a480

Please sign in to comment.