pxt-calliope/libs/core/control.ts
Peli de Halleux 2250aa9d4b
Upgrades (#14)
* enable tracing

* more config adjustments

* upgrading images

* upgrading input

* upgrading led

* upgraded pins api

* upgrade runtime

* upgrading pxt.h

* upgrading basic.cpp

* upgraded control

* upgraded control.ts

* upgrading core.cpp

* updating shims

* fixing merge issues

* upgrading BLE config
2017-12-14 11:00:47 -08:00

50 lines
1.4 KiB
TypeScript

/**
* Runtime and event utilities.
*/
//% weight=1 color="#42495F" icon="\uf233"
//% advanced=true
namespace control {
/**
* Returns the value of a C++ runtime constant
*/
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
//% shim=TD_ID advanced=true
export function eventSourceId(id: EventBusSource): number {
return id;
}
/**
* Returns the value of a C++ runtime constant
*/
//% weight=1 weight=19 blockId="control_event_value_id" block="%id"
//% shim=TD_ID advanced=true
export function eventValueId(id: EventBusValue): number {
return id;
}
/**
* Display specified error code and stop the program.
*/
//% shim=pxtrt::panic
export function panic(code: number) { }
/**
* If the condition is false, display msg on serial console, and panic with code 098.
*/
export function assert(condition: boolean, msg?: string) {
if (!condition) {
console.log("ASSERTION FAILED")
if (msg != null) {
console.log(msg)
}
panic(98)
}
}
/**
* Display warning in the simulator.
*/
//% shim=pxtrt::runtimeWarning
export function runtimeWarning(message: string) { }
}