pxt-calliope/libs/core/control.ts
Amerlander 918af4f3ac
Bump V3.0.22 (#110)
* change simulator svg

* change radio image

* Remove google fonts cdn

* change color of 'advanced' button

* font fix

* font fix 2

* display fix

* change fullsceen simulator bg

* Continuous servo

* handle continuous state

* adding shims

* update rendering for continuous servos

* fixing sim

* fix sig

* typo

* fix sim

* bump pxt

* bump pxt

* rerun travis

* Input blocks revision

- add Button and Pin event types
- merge onPinPressed & onPinReleased in new onPinEvent function
- create new onButtonEvent function

* update input blocks in docs and tests

* remove device_pin_release block

* Hide DAL.x behind Enum

* bring back deprecated blocks, but hide them

* shims and locales files

* fix input.input. typing

* remove buildpr

* bump V3

* update simulator aspect ratio

* add Loudness Block

* revoke loudness block

* Adds soundLevel

To be replaced by pxt-common-packages when DAL is updated.

* Remove P0 & P3 from AnalogPin

Co-authored-by: Juri <gitkraken@juriwolf.de>
2020-09-08 02:04:25 -07:00

75 lines
1.9 KiB
TypeScript

/**
* Runtime and event utilities.
*/
//% weight=1 color="#42495F" icon="\uf233"
//% advanced=true
namespace control {
/**
* Run other code in the parallel.
*/
//% hidden=1
export function runInParallel(a: () => void) {
control.inBackground(a);
}
/**
* Returns the value of a C++ runtime constant
*/
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
//% help=control/event-source-id
//% 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"
//% help=control/event-value-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)
}
}
export function fail(message: string) {
console.log("Fatal failure: ")
console.log(message)
panic(108)
}
/**
* Display warning in the simulator.
*/
//% shim=pxtrt::runtimeWarning
export function runtimeWarning(message: string) { }
}
/**
* Convert any value to text
* @param value value to be converted to text
*/
//% help=text/convert-to-text weight=1
//% block="convert $value=math_number to text"
//% blockId=variable_to_text blockNamespace="text"
function convertToText(value: any): string {
return "" + value;
}