fix further encoding bugs

This commit is contained in:
Shannon Sterz 2016-02-28 21:44:26 +01:00
parent 5e2ab4326a
commit 5213deaa78

View file

@ -78,11 +78,11 @@ Arduino.prototype.processWriteBuffer = function () {
Arduino.prototype.valueToLastFour = function(val) { Arduino.prototype.valueToLastFour = function(val) {
var encodedVal = ""; var encodedVal = "";
for (var i = 3; i > 0; i--) { for (var i = 3; i >= 0; i--) {
encodedVal += String.fromCharCode(val/(Math.pow(2,8*i))); encodedVal += String.fromCharCode(val/(Math.pow(2,8*i)));
val = val%Math.pow(2,8*i); val = val % Math.pow(2,8*i);
} }
return encodedVal; return encodedVal;
@ -91,7 +91,7 @@ Arduino.prototype.valueToLastFour = function(val) {
Arduino.prototype.valueToFirstTwo = function(val) { Arduino.prototype.valueToFirstTwo = function(val) {
var encodedVal = ""; var encodedVal = "";
for (var i = 1; i > 0; i--) { for (var i = 1; i >= 0; i--) {
encodedVal += String.fromCharCode(val/(Math.pow(2,8*i))); encodedVal += String.fromCharCode(val/(Math.pow(2,8*i)));
val = val%Math.pow(2,8*i); val = val%Math.pow(2,8*i);