fix further encoding bugs

This commit is contained in:
Stefan Sterz 2016-02-28 21:44:26 +01:00
parent 5e2ab4326a
commit 5213deaa78
1 changed files with 4 additions and 4 deletions

View File

@ -78,11 +78,11 @@ Arduino.prototype.processWriteBuffer = function () {
Arduino.prototype.valueToLastFour = function(val) {
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)));
val = val%Math.pow(2,8*i);
val = val % Math.pow(2,8*i);
}
return encodedVal;
@ -91,7 +91,7 @@ Arduino.prototype.valueToLastFour = function(val) {
Arduino.prototype.valueToFirstTwo = function(val) {
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)));
val = val%Math.pow(2,8*i);