pxt-calliope/libs/core/basic.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

93 lines
2.6 KiB
TypeScript

/**
Well known colors
*/
enum Colors {
//% blockIdentity=basic.color
//% block=red
Red = 0x00FF0000,
//% blockIdentity=basic.color
//% block=orange
Orange = 0x00FFA500,
//% blockIdentity=basic.color
//% block=yellow
Yellow = 0x00FFFF00,
//% blockIdentity=basic.color
//% block=green
Green = 0x0000FF00,
//% blockIdentity=basic.color
//% block=blue
Blue = 0x000000FF,
//% blockIdentity=basic.color
//% block=indigo
Indigo = 0x004b0082,
//% blockIdentity=basic.color
//% block=violet
Violet = 0x008a2be2,
//% blockIdentity=basic.color
//% block=purple
Purple = 0x00FF00FF,
//% blockIdentity=basic.color
//% block=white
White = 0xFFFFFFFF,
//% blockIdentity=basic.color
//% block=off
Off = 0x00000000,
}
/**
* Provides access to basic micro:bit functionality.
*/
//% color=#54C9C9 weight=100
namespace basic {
/**
* Converts the color name to a number
*/
//% blockId=color_id block="%c" shim=TD_ID
export function color(c: Colors): number {
return c;
}
/**
* Converts red, green, blue channels into a RGB color
* @param red value of the red channel between 0 and 255. eg: 255
* @param green value of the green channel between 0 and 255. eg: 255
* @param blue value of the blue channel between 0 and 255. eg: 255
* @param white value of the white channel between 0 and 255. eg: 0
*/
//% weight=1
//% blockId="core_rgb" block="red %red|green %green|blue %blue|white %white"
export function rgbw(red: number, green: number, blue: number, white:number): number {
return ((white & 0xFF) << 24) | ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | (blue & 0xFF);
}
/**
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
* @param interval speed of scroll; eg: 150, 100, 200, -100
*/
//% help=basic/show-number
//% weight=96
//% blockId=device_show_number block="show|number %number" blockGap=8
//% async
//% parts="ledmatrix" interval.defl=150
export function showNumber(value: number, interval?: number) {
showString(Math.roundWithPrecision(value, 2).toString(), interval);
}
}
/**
* Pause for the specified time in milliseconds
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
*/
function pause(ms: number): void {
basic.pause(ms);
}
/**
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute
*/
function forever(a: () => void): void {
basic.forever(a);
}