Move files from main kindscript repo
This commit is contained in:
4
libs/microbit/README.md
Normal file
4
libs/microbit/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# core
|
||||
|
||||
The core library.
|
||||
|
83
libs/microbit/basic.ts
Normal file
83
libs/microbit/basic.ts
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=190 weight=100
|
||||
namespace basic {
|
||||
|
||||
/**
|
||||
* 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=functions/show-number
|
||||
//% weight=96
|
||||
//% shim=micro_bit::scrollNumber
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% async
|
||||
export function showNumber(value: number, interval: number = 150): void { }
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds TODO
|
||||
* @param interval TODO
|
||||
*/
|
||||
//% help=functions/show-leds
|
||||
//% weight=95 blockGap=8
|
||||
//% shim=micro_bit::showLeds
|
||||
//% imageLiteral=1 async
|
||||
//% blockId=device_show_leds
|
||||
//% block="show leds" icon="\uf00a"
|
||||
export function showLeds(leds: string, interval: number = 400): void { }
|
||||
|
||||
/**
|
||||
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
|
||||
* @param text the text to scroll on the screen, eg: "Hello!"
|
||||
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=functions/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% shim=micro_bit::scrollString async
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
export function showString(text: string, interval: number = 150): void { }
|
||||
|
||||
/**
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=functions/clear-screen weight=79
|
||||
//% shim=micro_bit::clearScreen
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||
export function clearScreen(): void { }
|
||||
|
||||
/**
|
||||
* Shows a sequence of LED screens as an animation.
|
||||
* @param leds TODO
|
||||
* @param interval TODO
|
||||
*/
|
||||
//% help=functions/show-animation shim=micro_bit::showAnimation imageLiteral=1 async
|
||||
export function showAnimation(leds: string, interval: number = 400): void { }
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds TODO
|
||||
*/
|
||||
//% help=functions/plot-leds weight=80 shim=micro_bit::plotLeds imageLiteral=1
|
||||
export function plotLeds(leds: string): void { }
|
||||
|
||||
/**
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/forever weight=55 blockGap=8
|
||||
//% blockId=device_forever block="forever" icon="\uf01e" shim=micro_bit::forever
|
||||
export function forever(body: () => void): void { }
|
||||
|
||||
/**
|
||||
* Pause for the specified time in milliseconds
|
||||
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
|
||||
*/
|
||||
//% help=functions/pause weight=54
|
||||
//% shim=micro_bit::pause async block="pause (ms) %pause"
|
||||
//% blockId=device_pause icon="\uf110"
|
||||
export function pause(ms: number): void { }
|
||||
}
|
13
libs/microbit/control.ts
Normal file
13
libs/microbit/control.ts
Normal file
@ -0,0 +1,13 @@
|
||||
namespace control {
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
//% help=functions/in-background shim=micro_bit::runInBackground
|
||||
*/
|
||||
export function inBackground(body: Action): void { }
|
||||
|
||||
/**
|
||||
* Resets the BBC micro:bit.
|
||||
*/
|
||||
//% weight=1 shim=uBit.reset async help=functions/reset
|
||||
export function reset() : void { }
|
||||
}
|
236
libs/microbit/core.d.ts
vendored
Normal file
236
libs/microbit/core.d.ts
vendored
Normal file
@ -0,0 +1,236 @@
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.
|
||||
*/
|
||||
//% shim=collection::count
|
||||
length: number;
|
||||
|
||||
/**
|
||||
* Appends new elements to an array.
|
||||
* @param items New elements of the Array.
|
||||
*/
|
||||
//% shim=collection::add
|
||||
push(item: T): void;
|
||||
|
||||
/**
|
||||
* Removes the last element from an array and returns it.
|
||||
*/
|
||||
//% helper=arrayPop
|
||||
pop(): T;
|
||||
|
||||
/**
|
||||
* Reverses the elements in an Array.
|
||||
*/
|
||||
//% helper=arrayReverse
|
||||
reverse(): void;
|
||||
|
||||
/**
|
||||
* Removes the first element from an array and returns it.
|
||||
*/
|
||||
//% helper=arrayShift
|
||||
shift(): T;
|
||||
|
||||
/**
|
||||
* Returns a section of an array.
|
||||
* @param start The beginning of the specified portion of the array.
|
||||
* @param end The end of the specified portion of the array.
|
||||
*/
|
||||
//% helper=arraySlice
|
||||
slice(start: number, end: number): T[];
|
||||
|
||||
/** Removes the first occurence of an object. Returns true if removed. */
|
||||
//% shim=collection::remove
|
||||
removeElement(element:T) : boolean;
|
||||
|
||||
/** Removes the object at position index. */
|
||||
//% shim=collection::remove_at
|
||||
removeAt(idx:number) : void;
|
||||
|
||||
|
||||
/**
|
||||
* Removes elements from an array.
|
||||
* @param start The zero-based location in the array from which to start removing elements.
|
||||
* @param deleteCount The number of elements to remove.
|
||||
*/
|
||||
//% helper=arraySplice
|
||||
splice(start: number, deleteCount: number): void;
|
||||
|
||||
/**
|
||||
* Inserts new elements at the start of an array.
|
||||
* @param items Elements to insert at the start of the Array.
|
||||
*/
|
||||
//% helper=arrayUnshift
|
||||
unshift(item:T): void;
|
||||
|
||||
/**
|
||||
* Returns the index of the first occurrence of a value in an array.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
|
||||
*/
|
||||
//% shim=collection::index_of
|
||||
indexOf(searchElement: T, fromIndex?: number): number;
|
||||
|
||||
|
||||
[n: number]: T;
|
||||
}
|
||||
|
||||
|
||||
interface String {
|
||||
|
||||
/**
|
||||
* Returns the character at the specified index.
|
||||
* @param pos The zero-based index of the desired character.
|
||||
*/
|
||||
//% shim=string::at
|
||||
charAt(pos: number): string;
|
||||
|
||||
/**
|
||||
* Returns the Unicode value of the character at the specified location.
|
||||
* @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.
|
||||
*/
|
||||
//% shim=string::code_at
|
||||
charCodeAt(index: number): number;
|
||||
|
||||
/**
|
||||
* Returns a string that contains the concatenation of two or more strings.
|
||||
* @param strings The strings to append to the end of the string.
|
||||
*/
|
||||
//% shim=string::concat
|
||||
concat(other: string): string;
|
||||
|
||||
/**
|
||||
* Returns the position of the first occurrence of a substring.
|
||||
* @param searchString The substring to search for in the string
|
||||
* @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.
|
||||
*/
|
||||
indexOf(searchString: string, position?: number): number;
|
||||
|
||||
/**
|
||||
* Returns the last occurrence of a substring in the string.
|
||||
* @param searchString The substring to search for.
|
||||
* @param position The index at which to begin searching. If omitted, the search begins at the end of the string.
|
||||
*/
|
||||
lastIndexOf(searchString: string, position?: number): number;
|
||||
|
||||
/**
|
||||
* Determines whether two strings are equivalent in the current locale.
|
||||
* @param that String to compare to target string
|
||||
*/
|
||||
localeCompare(that: string): number;
|
||||
|
||||
/**
|
||||
* Returns a section of a string.
|
||||
* @param start The index to the beginning of the specified portion of stringObj.
|
||||
* @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end.
|
||||
* If this value is not specified, the substring continues to the end of stringObj.
|
||||
*/
|
||||
slice(start?: number, end?: number): string;
|
||||
|
||||
/**
|
||||
* Returns the substring at the specified location within a String object.
|
||||
* @param start The zero-based index number indicating the beginning of the substring.
|
||||
* @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end.
|
||||
* If end is omitted, the characters from start through the end of the original string are returned.
|
||||
*/
|
||||
substring(start: number, end?: number): string;
|
||||
|
||||
/** Converts all the alphabetic characters in a string to lowercase. */
|
||||
toLowerCase(): string;
|
||||
|
||||
/** Converts all the alphabetic characters in a string to uppercase. */
|
||||
toUpperCase(): string;
|
||||
|
||||
/** Returns the length of a String object. */
|
||||
//% shim=string::count
|
||||
length: number;
|
||||
|
||||
//% shim=string::at
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts A string to an integer.
|
||||
* @param s A string to convert into a number.
|
||||
*/
|
||||
//% shim=string::to_number
|
||||
declare function parseInt(s: string): number;
|
||||
|
||||
interface Object {}
|
||||
interface Function {}
|
||||
interface IArguments {}
|
||||
interface RegExp {}
|
||||
|
||||
interface Boolean {
|
||||
/**
|
||||
* Returns a string representation of an object.
|
||||
*/
|
||||
//% shim=boolean::to_string
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
declare namespace String {
|
||||
/**
|
||||
* Make a string from the given ASCII character code.
|
||||
*/
|
||||
//% shim=number::to_character
|
||||
export function fromCharCode(code:number): string;
|
||||
}
|
||||
|
||||
interface Number {
|
||||
/**
|
||||
* Returns a string representation of an object.
|
||||
*/
|
||||
//% shim=number::to_string
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
declare namespace Math {
|
||||
/**
|
||||
* Returns the absolute value of a number (the value without regard to whether it is positive or negative).
|
||||
* For example, the absolute value of -5 is the same as the absolute value of 5.
|
||||
* @param x A numeric expression for which the absolute value is needed.
|
||||
*/
|
||||
//% shim=math::abs
|
||||
export function abs(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the sign of the x, indicating whether x is positive, negative or zero.
|
||||
* @param x The numeric expression to test
|
||||
*/
|
||||
//% shim=math::sign
|
||||
export function sign(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the larger of two supplied numeric expressions.
|
||||
*/
|
||||
//% shim=math::max
|
||||
export function max(a:number, b:number): number;
|
||||
|
||||
/**
|
||||
* Returns the smaller of two supplied numeric expressions.
|
||||
*/
|
||||
//% shim=math::min
|
||||
export function min(a:number, b:number): number;
|
||||
|
||||
/**
|
||||
* Returns the value of a base expression taken to a specified power.
|
||||
* @param x The base value of the expression.
|
||||
* @param y The exponent value of the expression.
|
||||
*/
|
||||
//% shim=math::pow
|
||||
export function pow(x: number, y: number): number;
|
||||
|
||||
/** Returns a pseudorandom number between 0 and `max`. */
|
||||
//% shim=math::random
|
||||
export function random(max:number): number;
|
||||
|
||||
/**
|
||||
* Returns the square root of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
//% shim=math::sqrt
|
||||
export function sqrt(x: number): number;
|
||||
}
|
50
libs/microbit/images.ts
Normal file
50
libs/microbit/images.ts
Normal file
@ -0,0 +1,50 @@
|
||||
//% color=45 weight=31
|
||||
namespace images {
|
||||
/**
|
||||
* Creates an image that fits on the LED screen.
|
||||
*/
|
||||
//% weight=75
|
||||
//% blockId=device_build_image block="create image" imageLiteral=1
|
||||
export function createImage(leds: string): Image {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an image with 2 frames.
|
||||
*/
|
||||
//% weight=74
|
||||
//% blockId=device_build_big_image block="create big image" imageLiteral=2
|
||||
export function createBigImage(leds: string): Image {
|
||||
return null;
|
||||
}
|
||||
|
||||
export class Image {
|
||||
/**
|
||||
* Shows an frame from the image at offset ``x offset``.
|
||||
* @param xOffset TODO
|
||||
*/
|
||||
//% help=functions/show-image weight=80 shim=micro_bit::showImage
|
||||
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
||||
public showImage(xOffset: number): void {}
|
||||
|
||||
/**
|
||||
* Scrolls an image .
|
||||
* @param frameOffset x offset moved on each animation step, eg: 5, 1, -1
|
||||
* @param interval time between each animation step in milli seconds, eg: 200
|
||||
*/
|
||||
//% help=functions/show-image weight=79 shim=micro_bit::showImage async
|
||||
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
||||
public scrollImage(frameOffset: number, interval : number = 200) {
|
||||
}
|
||||
|
||||
public plotImage(xOffset: number): void {}
|
||||
|
||||
public clear(): void {}
|
||||
|
||||
public setPixelBrightness(x: number, y: number, v: number): void {}
|
||||
|
||||
public pixelBrightness(x: number, y: number): number {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
226
libs/microbit/input.ts
Normal file
226
libs/microbit/input.ts
Normal file
@ -0,0 +1,226 @@
|
||||
enum Button {
|
||||
//% enumval=MICROBIT_ID_BUTTON_A
|
||||
A,
|
||||
//% enumval=MICROBIT_ID_BUTTON_B
|
||||
B,
|
||||
//% enumval=MICROBIT_ID_BUTTON_AB
|
||||
//% blockId="A+B"
|
||||
AB,
|
||||
}
|
||||
|
||||
enum Dimension {
|
||||
//% enumval=0 blockId=x
|
||||
X,
|
||||
//% enumval=1 blockId=y
|
||||
Y,
|
||||
//% enumval=2 blockId=z
|
||||
Z,
|
||||
//% enumval=3 blockId=strength
|
||||
Strength,
|
||||
}
|
||||
|
||||
enum Rotation {
|
||||
//% enumval=0 blockId=pitch
|
||||
Pitch,
|
||||
//% enumval=1 blockId=roll
|
||||
Roll,
|
||||
}
|
||||
|
||||
enum TouchPins {
|
||||
//% enumval=uBit.io.P0
|
||||
P0,
|
||||
//% enumval=uBit.io.P1
|
||||
P1,
|
||||
//% enumval=uBit.io.P2
|
||||
P2,
|
||||
}
|
||||
|
||||
enum Gestures {
|
||||
//% blockId=shake enumval=MICROBIT_ACCELEROMETER_EVT_SHAKE
|
||||
Shake,
|
||||
//% blockId="logo up" enumval=MICROBIT_ACCELEROMETER_EVT_TILT_UP
|
||||
LogoUp,
|
||||
//% blockId="logo down" enumval=MICROBIT_ACCELEROMETER_EVT_TILT_DOWN
|
||||
LogoDown,
|
||||
//% blockId="screen up" enumval=MICROBIT_ACCELEROMETER_EVT_FACE_UP
|
||||
ScreenUp,
|
||||
//% blockId="screen down" enumval=MICROBIT_ACCELEROMETER_EVT_FACE_DOWN
|
||||
ScreenDown
|
||||
}
|
||||
|
||||
//% color=300 weight=99
|
||||
namespace input {
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
* @param button TODO
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-button-pressed weight=85
|
||||
//% shim=micro_bit::onButtonPressed
|
||||
//% blockId=device_button_event
|
||||
//% block="on button|%NAME|pressed"
|
||||
//% icon="\uf192"
|
||||
export function onButtonPressed(button: Button, body: Action): void { }
|
||||
|
||||
/**
|
||||
* Attaches code to run when the screen is facing up.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-gesture shim=micro_bit::on_event weight=84
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
export function onGesture(gesture: Gestures, body: Action): void { }
|
||||
|
||||
/**
|
||||
* Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.
|
||||
* @param name TODO
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-pin-pressed weight=83 shim=micro_bit::onPinPressed
|
||||
//% blockId=device_pin_event block="on pin|%NAME|pressed" icon="\uf094"
|
||||
export function onPinPressed(name: TouchPins, body: Action): void { }
|
||||
|
||||
/**
|
||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||
*/
|
||||
//% help=functions/button-is-pressed weight=57
|
||||
//% shim=micro_bit::isButtonPressed
|
||||
//% block="button|%NAME|is pressed"
|
||||
//% blockId=device_get_button2
|
||||
//% icon="\uf192" blockGap=8
|
||||
export function buttonIsPressed(button: Button): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current compass compass heading in degrees.
|
||||
*/
|
||||
//% help=functions/compass-heading
|
||||
//% weight=56 icon="\uf14e"
|
||||
//% shim=micro_bit::compassHeading
|
||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||
export function compassHeading(): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the temperature in Celsius degrees (°C).
|
||||
*/
|
||||
//% weight=55 icon="\uf06d"
|
||||
//% help=functions/temperature shim=uBit.thermometer.getTemperature
|
||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||
export function temperature(): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=functions/acceleration weight=54 icon="\uf135"
|
||||
//% shim=micro_bit::getAcceleration
|
||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||
export function acceleration(dimension: Dimension): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright. In the simulator, the ``acceleration y`` is used to emulate this value.
|
||||
*/
|
||||
//% help=functions/light-level weight=53 shim=micro_bit::lightLevel
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||
export function lightLevel(): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The pitch of the device, rotation along the ``x-axis``, in degrees.
|
||||
* @param kind TODO
|
||||
*/
|
||||
//% help=/functions/rotation weight=52 shim=micro_bit::getRotation
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||
export function rotation(kind: Rotation): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=functions/magnetic-force weight=51 shim=micro_bit::getMagneticForce
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||
export function magneticForce(dimension: Dimension): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=functions/running-time shim=micro_bit::getCurrentTime weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" blockGap=8 icon="\uf017"
|
||||
export function runningTime(): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obsolete, compass calibration is automatic.
|
||||
*/
|
||||
//% help=functions/calibrate weight=0 shim=TD_NOOP
|
||||
export function calibrate(): void { }
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name TODO
|
||||
*/
|
||||
//% help=functions/pin-is-pressed weight=58 shim=micro_bit::isPinTouched block="pin|%NAME|is pressed" icon="\uf094"
|
||||
export function pinIsPressed(name: TouchPins): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the screen is facing up.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-screen-up
|
||||
export function onScreenUp(body: Action): void {
|
||||
onGesture(Gestures.ScreenUp, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the screen is facing down.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-screen-down
|
||||
export function onScreenDown(body: Action): void {
|
||||
onGesture(Gestures.ScreenDown, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the device is shaken.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-shake
|
||||
export function onShake(body: Action): void {
|
||||
onGesture(Gestures.Shake, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the logo is oriented upwards and the board is vertical.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-logo-up
|
||||
export function onLogoUp(body: Action): void {
|
||||
onGesture(Gestures.LogoUp, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the logo is oriented downwards and the board is vertical.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=functions/on-logo-down
|
||||
export function onLogoDown(body: Action): void {
|
||||
onGesture(Gestures.LogoDown, body);
|
||||
}
|
||||
}
|
28
libs/microbit/mbit.ts
Normal file
28
libs/microbit/mbit.ts
Normal file
@ -0,0 +1,28 @@
|
||||
type Action = () => void;
|
||||
|
||||
namespace helpers {
|
||||
export function arraySplice<T>(arr: T[], start: number, len: number) {
|
||||
if (start < 0) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < len; ++i) {
|
||||
arr.removeAt(start)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace console {
|
||||
export function log(msg: string) {
|
||||
writeString(msg);
|
||||
writeString("\r\n");
|
||||
}
|
||||
|
||||
//% shim=micro_bit::serialSendString
|
||||
function writeString(text: string): void { }
|
||||
}
|
||||
|
||||
namespace math {
|
||||
export function clamp(min: number, max:number, value:number): number {
|
||||
return Math.min(max, Math.max(min, value));
|
||||
}
|
||||
}
|
76
libs/microbit/yelm.json
Normal file
76
libs/microbit/yelm.json
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "microbit",
|
||||
"description": "The microbit core library",
|
||||
"installedVersion": "xdvxev",
|
||||
"files": [
|
||||
"README.md",
|
||||
"core.d.ts",
|
||||
"mbit.ts",
|
||||
"images.ts",
|
||||
"basic.ts",
|
||||
"input.ts",
|
||||
"control.ts"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {},
|
||||
"target": {
|
||||
"id": "microbit",
|
||||
"name": "microbit",
|
||||
"cloud": true,
|
||||
"blocksprj": {
|
||||
"id": "blocksprj",
|
||||
"config": {
|
||||
"name": "{0} block",
|
||||
"dependencies": {
|
||||
"microbit": "*",
|
||||
"microbit-led": "*",
|
||||
"microbit-music": "*",
|
||||
"microbit-radio": "*",
|
||||
"microbit-game": "*",
|
||||
"microbit-pins": "*",
|
||||
"microbit-serial": "*"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.blocks",
|
||||
"main.blocks.ts",
|
||||
"README.md"
|
||||
]
|
||||
},
|
||||
"files": {
|
||||
"main.blocks": "<xml xmlns='http://www.w3.org/1999/xhtml'>\n</xml>\n",
|
||||
"main.blocks.ts": "\n",
|
||||
"README.md": "Describe your project here!"
|
||||
}
|
||||
},
|
||||
"tsprj": {
|
||||
"id": "tsprj",
|
||||
"config": {
|
||||
"name": "{0} bit",
|
||||
"dependencies": {
|
||||
"microbit": "*",
|
||||
"microbit-led": "*",
|
||||
"microbit-music": "*",
|
||||
"microbit-radio": "*",
|
||||
"microbit-game": "*",
|
||||
"microbit-pins": "*",
|
||||
"microbit-serial": "*"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
]
|
||||
},
|
||||
"files": {
|
||||
"main.ts": "basic.showString('Hi!')\n",
|
||||
"README.md": "Describe your project here!"
|
||||
}
|
||||
},
|
||||
"koduvscode": true,
|
||||
"compile": {
|
||||
"isNative": false,
|
||||
"hasHex": true
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user