2016-04-06 01:54:09 +02:00
|
|
|
/**
|
|
|
|
* Runtime and event utilities.
|
|
|
|
*/
|
2016-03-26 05:13:09 +01:00
|
|
|
//% weight=1 color="#333333"
|
2016-03-10 23:01:04 +01:00
|
|
|
namespace control {
|
2016-03-30 02:11:17 +02:00
|
|
|
|
2016-03-10 23:01:04 +01:00
|
|
|
/**
|
2016-03-30 02:11:17 +02:00
|
|
|
* Returns the value of a C++ runtime constant
|
2016-03-10 23:01:04 +01:00
|
|
|
*/
|
2016-03-30 02:11:17 +02:00
|
|
|
//% weight=19 weight=19 blockId="control_event_source" block="%id"
|
|
|
|
export function eventSource(id: EventBusSource) : number {
|
|
|
|
return id;
|
|
|
|
}
|
2016-03-28 09:23:00 +02:00
|
|
|
/**
|
2016-03-30 02:11:17 +02:00
|
|
|
* Returns the value of a C++ runtime constant
|
2016-03-28 09:23:00 +02:00
|
|
|
*/
|
2016-03-30 02:11:17 +02:00
|
|
|
//% weight=19 weight=19 blockId="control_event_value" block="%id"
|
|
|
|
export function eventValue(id: EventBusValue) : number {
|
|
|
|
return id;
|
|
|
|
}
|
2016-04-12 04:44:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Display specified error code and stop the program.
|
|
|
|
*/
|
|
|
|
//% shim=pxrt::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)
|
|
|
|
}
|
|
|
|
}
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|