Merge pull request #397 from Microsoft/showFix

fix problem with showNumber and showString on negative interval
This commit is contained in:
Tom Ball 2017-05-12 14:20:07 -07:00 committed by GitHub
commit 4fec614b50
2 changed files with 8 additions and 8 deletions

View File

@ -17,9 +17,8 @@ namespace basic {
//% async //% async
//% parts="ledmatrix" //% parts="ledmatrix"
void showNumber(int value, int interval = 150) { void showNumber(int value, int interval = 150) {
if (interval < 0) if (interval <= 0)
return; interval = 1;
ManagedString t(value); ManagedString t(value);
if (value < 0 || value >= 10) { if (value < 0 || value >= 10) {
uBit.display.scroll(t, interval); uBit.display.scroll(t, interval);
@ -55,8 +54,8 @@ namespace basic {
//% blockId=device_print_message //% blockId=device_print_message
//% parts="ledmatrix" //% parts="ledmatrix"
void showString(StringData *text, int interval = 150) { void showString(StringData *text, int interval = 150) {
if (interval < 0) if (interval <= 0)
return; interval = 1;
ManagedString s(text); ManagedString s(text);
int l = s.length(); int l = s.length();
if (l == 0) { if (l == 0) {

View File

@ -234,15 +234,16 @@ namespace pxsim.ImageMethods {
namespace pxsim.basic { namespace pxsim.basic {
export function showNumber(x: number, interval: number) { export function showNumber(x: number, interval: number) {
if (interval < 0) return; if (interval <= 0)
interval = 1;
let leds = createImageFromString(x.toString()); let leds = createImageFromString(x.toString());
if (x < 0 || x >= 10) ImageMethods.scrollImage(leds, 1, interval); if (x < 0 || x >= 10) ImageMethods.scrollImage(leds, 1, interval);
else showLeds(leds, interval * 5); else showLeds(leds, interval * 5);
} }
export function showString(s: string, interval: number) { export function showString(s: string, interval: number) {
if (interval < 0) return; if (interval <= 0)
interval = 1;
if (s.length == 0) { if (s.length == 0) {
clearScreen(); clearScreen();
pause(interval * 5); pause(interval * 5);