Various fixes (#548)
* adding running time micros * support for system micro seconds * restore display mode after plotting sprites * bump pxt
This commit is contained in:
parent
8d9c90884b
commit
cdbc34550a
@ -21,6 +21,7 @@ input.lightLevel();
|
||||
input.rotation(Rotation.Pitch);
|
||||
input.magneticForce(Dimension.X);
|
||||
input.runningTime();
|
||||
input.runningTimeMicros();
|
||||
input.setAccelerometerRange(AcceleratorRange.OneG);
|
||||
```
|
||||
|
||||
|
17
docs/reference/input/running-time-micros.md
Normal file
17
docs/reference/input/running-time-micros.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Running Time Micros
|
||||
|
||||
Find how long it has been since the program started in micro-seconds.
|
||||
|
||||
```sig
|
||||
input.runningTimeMicros();
|
||||
```
|
||||
|
||||
## Returns
|
||||
|
||||
* the [Number](/types/number) of microseconds since the program started.
|
||||
(One second is 1000000 microseconds.)
|
||||
|
||||
## See also
|
||||
|
||||
[show number](/reference/basic/show-number), [pause](/reference/basic/pause)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Running Time
|
||||
|
||||
Find how long it has been since the program started.
|
||||
Find how long it has been since the program started in milli-seconds.
|
||||
|
||||
```sig
|
||||
input.runningTime();
|
||||
|
@ -179,6 +179,7 @@
|
||||
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||
"input.runningTimeMicros": "Gets the number of microseconds elapsed since power on.",
|
||||
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
||||
"input.setAccelerometerRange|param|range": "a value describe the maximum strengh of acceleration measured",
|
||||
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
||||
|
@ -268,6 +268,7 @@
|
||||
"input.onPinReleased|block": "on pin %NAME|released",
|
||||
"input.pinIsPressed|block": "pin %NAME|is pressed",
|
||||
"input.rotation|block": "rotation (°)|%NAME",
|
||||
"input.runningTimeMicros|block": "running time (micros)",
|
||||
"input.runningTime|block": "running time (ms)",
|
||||
"input.setAccelerometerRange|block": "set accelerometer|range %range",
|
||||
"input.temperature|block": "temperature (°C)",
|
||||
|
@ -73,16 +73,11 @@ namespace game {
|
||||
_backgroundAnimation = true;
|
||||
control.inBackground(() => {
|
||||
led.stopAnimation();
|
||||
const dm = led.displayMode();
|
||||
if (dm != DisplayMode.BackAndWhite)
|
||||
led.setDisplayMode(DisplayMode.BackAndWhite);
|
||||
basic.showAnimation(`0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0`, 20);
|
||||
if (dm != DisplayMode.BackAndWhite)
|
||||
led.setDisplayMode(dm);
|
||||
_backgroundAnimation = false;
|
||||
});
|
||||
}
|
||||
@ -125,7 +120,6 @@ namespace game {
|
||||
unplugEvents();
|
||||
led.stopAnimation();
|
||||
led.setBrightness(255);
|
||||
led.setDisplayMode(DisplayMode.BackAndWhite);
|
||||
while (true) {
|
||||
for (let i = 0; i < 8; i++) {
|
||||
basic.clearScreen();
|
||||
@ -777,6 +771,9 @@ namespace game {
|
||||
_sprites[i]._plot(now);
|
||||
}
|
||||
_img.plotImage(0);
|
||||
// restore previous display mode
|
||||
if (dm != DisplayMode.Greyscale)
|
||||
led.setDisplayMode(dm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -339,13 +339,23 @@ namespace input {
|
||||
/**
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% help=input/running-time weight=50 blockGap=8
|
||||
//% blockId=device_get_running_time block="running time (ms)"
|
||||
//% advanced=true
|
||||
int runningTime() {
|
||||
return system_timer_current_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of microseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time-micros weight=49
|
||||
//% blockId=device_get_running_time_micros block="running time (micros)"
|
||||
//% advanced=true
|
||||
int runningTimeMicros() {
|
||||
return system_timer_current_time_us();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obsolete, compass calibration is automatic.
|
||||
*/
|
||||
|
10
libs/core/shims.d.ts
vendored
10
libs/core/shims.d.ts
vendored
@ -332,11 +332,19 @@ declare namespace input {
|
||||
/**
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% help=input/running-time weight=50 blockGap=8
|
||||
//% blockId=device_get_running_time block="running time (ms)"
|
||||
//% advanced=true shim=input::runningTime
|
||||
function runningTime(): number;
|
||||
|
||||
/**
|
||||
* Gets the number of microseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time-micros weight=49
|
||||
//% blockId=device_get_running_time_micros block="running time (micros)"
|
||||
//% advanced=true shim=input::runningTimeMicros
|
||||
function runningTimeMicros(): number;
|
||||
|
||||
/**
|
||||
* Obsolete, compass calibration is automatic.
|
||||
*/
|
||||
|
@ -38,6 +38,6 @@
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.14.1"
|
||||
"pxt-core": "0.14.3"
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,10 @@ namespace pxsim.input {
|
||||
return runtime.runningTime();
|
||||
}
|
||||
|
||||
export function runningTimeMicros(): number {
|
||||
return runtime.runningTimeUs();
|
||||
}
|
||||
|
||||
export function calibrateCompass() {
|
||||
// device calibrates...
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user