Don't go through uBit object if not needed

This commit is contained in:
Michal Moskal 2016-04-19 11:52:44 -07:00
parent 13bdcf762d
commit c54cd21efa
5 changed files with 12 additions and 10 deletions

View File

@ -58,7 +58,7 @@ namespace basic {
int l = s.length();
if (l == 0) {
uBit.display.clear();
uBit.sleep(interval * 5);
fiber_sleep(interval * 5);
} else if (l > 1) {
uBit.display.scroll(s, interval);
} else {
@ -98,7 +98,7 @@ namespace basic {
void forever_stub(void *a) {
while (true) {
runAction0((Action)a);
uBit.sleep(20);
fiber_sleep(20);
}
}
@ -123,6 +123,6 @@ namespace basic {
//% async block="pause (ms) %pause"
//% blockId=device_pause icon="\uf110"
void pause(int ms) {
uBit.sleep(ms);
fiber_sleep(ms);
}
}

View File

@ -132,7 +132,7 @@ namespace control {
//% weight=30 async help=control/reset
//% blockId="control_reset" block="reset"
void reset() {
uBit.reset();
microbit_reset();
}
/**

View File

@ -1,6 +1,7 @@
#include "ksbit.h"
#include <limits.h>
namespace String_ {
//%
StringData *charAt(StringData *s, int pos) {
@ -127,13 +128,13 @@ namespace Math_ {
//%
int random(int max) {
if (max == INT_MIN)
return -uBit.random(INT_MAX);
return -microbit_random(INT_MAX);
else if (max < 0)
return -uBit.random(-max);
return -microbit_random(-max);
else if (max == 0)
return 0;
else
return uBit.random(max);
return microbit_random(max);
}
//%
@ -298,6 +299,6 @@ namespace pxtrt {
//%
void panic(int code)
{
uBit.panic(code);
microbit_panic(code);
}
}

View File

@ -247,7 +247,7 @@ namespace input {
//% help=input/running-time weight=50
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
int runningTime() {
return uBit.systemTime();
return system_timer_current_time();
}
/**

View File

@ -180,8 +180,9 @@ namespace pins {
}
if (ms > 0) {
uBit.sleep(ms);
fiber_sleep(ms);
pitchPin->setAnalogValue(0);
// TODO why do we use wait_ms() here? it's a busy wait I think
wait_ms(5);
}
}