From 487da05ecacd1c03c58b27d8ef8bd5fd7f85ac88 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Mon, 9 Jan 2017 10:58:24 +0000 Subject: [PATCH 1/3] Fix for https://github.com/Microsoft/pxt/issues/1057 --- libs/core/core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core/core.cpp b/libs/core/core.cpp index dffb6b2c..eb30e67d 100644 --- a/libs/core/core.cpp +++ b/libs/core/core.cpp @@ -76,7 +76,7 @@ namespace Boolean_ { } //% - bool bang(bool v) { return !v; } + bool bang(int v) { return v == 0; } } namespace Number_ { From cbc228dca355a52853e249fa9f758fa374f3bd61 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 9 Jan 2017 14:17:19 -0800 Subject: [PATCH 3/3] negative scroll fix fix for Microsoft/pxt#813 --- sim/state/ledmatrix.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sim/state/ledmatrix.ts b/sim/state/ledmatrix.ts index 5692c852..a62f2df2 100644 --- a/sim/state/ledmatrix.ts +++ b/sim/state/ledmatrix.ts @@ -53,9 +53,9 @@ namespace pxsim { } public shiftRight(cols: number) { - for (let x = this.width - 1; x <= 0; --x) + for (let x = this.width - 1; x >= 0; --x) for (let y = 0; y < 5; ++y) - this.set(x, y, x > cols ? this.get(x - cols, y) : 0); + this.set(x, y, x >= cols ? this.get(x - cols, y) : 0); } public clear(): void { @@ -195,11 +195,16 @@ namespace pxsim.ImageMethods { board().ledMatrixState.animationQ.enqueue({ interval: interval, frame: () => { - //TODO: support right to left. if (off >= leds.width || off < 0) return false; - stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride); - let c = Math.min(stride, leds.width - off); - leds.copyTo(off, c, display, 5 - stride) + if (stride > 0) { + display.shiftLeft(stride); + const c = Math.min(stride, leds.width - off); + leds.copyTo(off, c, display, 5 - stride) + } else { + display.shiftRight(-stride); + const c = Math.min(-stride, leds.width - off); + leds.copyTo(off, c, display, 0) + } off += stride; return true; },