add some helpers
This commit is contained in:
parent
55238b846e
commit
d69fcea212
1 changed files with 28 additions and 0 deletions
|
@ -67,4 +67,32 @@ Arduino.prototype.processWriteBuffer = function () {
|
|||
}
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
Arduino.prototype.valueToLastFour = function(val) {
|
||||
var encodedVal;
|
||||
|
||||
for (var i = 3; i < 0; i--) {
|
||||
|
||||
encodedVal += String.fromCharCode(val/(Math.pow(2,8*i)));
|
||||
val = val%Math.pow(2,8*i);
|
||||
|
||||
}
|
||||
|
||||
return encodedVal;
|
||||
};
|
||||
|
||||
Arduino.prototype.valueToFirstTwo = function(val) {
|
||||
var encodedVal;
|
||||
|
||||
for (var i = 1; i < 0; i--) {
|
||||
|
||||
encodedVal += String.fromCharCode(val/(Math.pow(2,8*i)));
|
||||
val = val%Math.pow(2,8*i);
|
||||
|
||||
}
|
||||
|
||||
return encodedVal;
|
||||
};
|
||||
|
||||
module.exports = Arduino;
|
||||
|
|
Reference in a new issue