Merge pull request #97 from Microsoft/startup_delay
Startup delay for sensors to get values
This commit is contained in:
commit
13f8659b98
@ -13,6 +13,7 @@ namespace sensors.internal {
|
|||||||
|
|
||||||
control.runInBackground(() => {
|
control.runInBackground(() => {
|
||||||
let prev = query()
|
let prev = query()
|
||||||
|
changeHandler(prev, prev)
|
||||||
while (true) {
|
while (true) {
|
||||||
loops.pause(periodMs)
|
loops.pause(periodMs)
|
||||||
let curr = query()
|
let curr = query()
|
||||||
@ -183,7 +184,7 @@ namespace sensors.internal {
|
|||||||
Low = 3,
|
Low = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThresholdDetector {
|
export class ThresholdDetector {
|
||||||
public id: number;
|
public id: number;
|
||||||
private min: number;
|
private min: number;
|
||||||
private max: number;
|
private max: number;
|
||||||
|
@ -393,6 +393,10 @@ static void runPoller(Thread *thr) {
|
|||||||
// note that this is run without the user mutex held - it should not modify any state!
|
// note that this is run without the user mutex held - it should not modify any state!
|
||||||
TValue prev = pxt::runAction0(query);
|
TValue prev = pxt::runAction0(query);
|
||||||
|
|
||||||
|
startUser();
|
||||||
|
pxt::runAction2(thr->act, prev, prev);
|
||||||
|
stopUser();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
sleep_core_us(us);
|
sleep_core_us(us);
|
||||||
if (paniced)
|
if (paniced)
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
"description": "The EV3 library",
|
"description": "The EV3 library",
|
||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"README.md",
|
||||||
"ns.ts"
|
"ns.ts",
|
||||||
|
"startup.ts"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base": "file:../base",
|
"base": "file:../base",
|
||||||
|
4
libs/ev3/startup.ts
Normal file
4
libs/ev3/startup.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// This is the last thing executed before user code
|
||||||
|
|
||||||
|
// We pause for 100ms to give time to read sensor values, so they work in on_start block
|
||||||
|
loops.pause(100)
|
Loading…
Reference in New Issue
Block a user