Migrate LED shims
This commit is contained in:
parent
88acd9254d
commit
9820a035ce
11
libs/microbit/enums.d.ts
vendored
11
libs/microbit/enums.d.ts
vendored
@ -224,6 +224,17 @@ declare namespace control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
declare enum DisplayMode {
|
||||||
|
//% block="black and white"
|
||||||
|
BackAndWhite = 0, // DISPLAY_MODE_BLACK_AND_WHITE
|
||||||
|
//% block="greyscale"
|
||||||
|
Greyscale = 1, // DISPLAY_MODE_GREYSCALE
|
||||||
|
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
|
||||||
|
}
|
||||||
|
declare namespace led {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum DigitalPin {
|
declare enum DigitalPin {
|
||||||
P0 = 7, // MICROBIT_ID_IO_P0
|
P0 = 7, // MICROBIT_ID_IO_P0
|
||||||
P1 = 8, // MICROBIT_ID_IO_P1
|
P1 = 8, // MICROBIT_ID_IO_P1
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "ksbit.h"
|
#include "ksbit.h"
|
||||||
|
|
||||||
typedef ImageData* Image;
|
|
||||||
|
|
||||||
//% color=45 weight=31
|
//% color=45 weight=31
|
||||||
namespace images {
|
namespace images {
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
"control.ts",
|
"control.ts",
|
||||||
"control.cpp",
|
"control.cpp",
|
||||||
"game.ts",
|
"game.ts",
|
||||||
|
"led.cpp",
|
||||||
"led.ts",
|
"led.ts",
|
||||||
"music.ts",
|
"music.ts",
|
||||||
"pins.cpp",
|
"pins.cpp",
|
||||||
|
@ -8,3 +8,5 @@ namespace bitvm {
|
|||||||
|
|
||||||
MicroBitPin *getPin(int id);
|
MicroBitPin *getPin(int id);
|
||||||
using namespace bitvm::bitvm_micro_bit;
|
using namespace bitvm::bitvm_micro_bit;
|
||||||
|
typedef ImageData* Image;
|
||||||
|
|
||||||
|
104
libs/microbit/led.cpp
Normal file
104
libs/microbit/led.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#include "ksbit.h"
|
||||||
|
|
||||||
|
enum class DisplayMode_ {
|
||||||
|
//% block="black and white"
|
||||||
|
BackAndWhite = DISPLAY_MODE_BLACK_AND_WHITE,
|
||||||
|
//% block="greyscale"
|
||||||
|
Greyscale = DISPLAY_MODE_GREYSCALE,
|
||||||
|
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
|
||||||
|
};
|
||||||
|
|
||||||
|
//% color=3 weight=35
|
||||||
|
namespace led {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
|
* @param x TODO
|
||||||
|
* @param y TODO
|
||||||
|
*/
|
||||||
|
//% help=led/plot weight=78 shim=micro_bit::plot
|
||||||
|
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||||
|
void plot(int x, int y) {
|
||||||
|
uBit.display.image.setPixelValue(x, y, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
|
* @param x TODO
|
||||||
|
* @param y TODO
|
||||||
|
*/
|
||||||
|
//% help=led/unplot weight=77 shim=micro_bit::unPlot
|
||||||
|
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||||
|
void unplot(int x, int y) {
|
||||||
|
uBit.display.image.setPixelValue(x, y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.
|
||||||
|
* @param x TODO
|
||||||
|
* @param y TODO
|
||||||
|
*/
|
||||||
|
//% help=led/point weight=76 shim=micro_bit::point
|
||||||
|
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||||
|
bool point(int x, int y) {
|
||||||
|
int pix = uBit.display.image.getPixelValue(x, y);
|
||||||
|
return pix > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||||
|
*/
|
||||||
|
//% help=led/brightness weight=60 shim=micro_bit::getBrightness
|
||||||
|
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||||
|
int brightness() {
|
||||||
|
return uBit.display.getBrightness();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the screen brightness from 0 (off) to 255 (full bright).
|
||||||
|
* @param value the brightness value, eg:255, 127, 0
|
||||||
|
*/
|
||||||
|
//% help=led/set-brightness weight=59 shim=micro_bit::setBrightness
|
||||||
|
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||||
|
void setBrightness(int value) {
|
||||||
|
uBit.display.setBrightness(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels the current animation and clears other pending animations.
|
||||||
|
*/
|
||||||
|
//% weight=50 shim=uBit.display.stopAnimation help=led/stop-animation
|
||||||
|
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||||
|
void stopAnimation() {
|
||||||
|
uBit.display.stopAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
||||||
|
* @param mode TODO
|
||||||
|
*/
|
||||||
|
//% shim=micro_bit::setDisplayMode weight=1 help=/led/set-display-mode
|
||||||
|
void setDisplayMode(DisplayMode_ mode) {
|
||||||
|
uBit.display.setDisplayMode((DisplayMode)mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a screenshot of the LED screen and returns an image.
|
||||||
|
*/
|
||||||
|
//% shim=uBit.display.screenShot help=led/screenshot
|
||||||
|
Image screenshot() {
|
||||||
|
return uBit.display.screenShot().leakData();
|
||||||
|
/*
|
||||||
|
let Image img;
|
||||||
|
img = image.createImage("");
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
for (let j = 0; j < 5; j++) {
|
||||||
|
if (led.point(i, j)) {
|
||||||
|
img.setPixel(i, j, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return img;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
@ -1,64 +1,5 @@
|
|||||||
enum DisplayMode {
|
|
||||||
//% block="black and white"
|
|
||||||
BackAndWhite = 0,
|
|
||||||
//% block="greyscale"
|
|
||||||
Greyscale = 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
//% color=3 weight=35
|
//% color=3 weight=35
|
||||||
namespace led {
|
namespace led {
|
||||||
/**
|
|
||||||
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
|
||||||
* @param x TODO
|
|
||||||
* @param y TODO
|
|
||||||
*/
|
|
||||||
//% help=led/plot weight=78 shim=micro_bit::plot
|
|
||||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
|
||||||
export function plot(x: number, y: number): void { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
|
||||||
* @param x TODO
|
|
||||||
* @param y TODO
|
|
||||||
*/
|
|
||||||
//% help=led/unplot weight=77 shim=micro_bit::unPlot
|
|
||||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
|
||||||
export function unplot(x: number, y: number): void { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.
|
|
||||||
* @param x TODO
|
|
||||||
* @param y TODO
|
|
||||||
*/
|
|
||||||
//% help=led/point weight=76 shim=micro_bit::point
|
|
||||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
|
||||||
export function point(x: number, y: number): boolean {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
|
||||||
*/
|
|
||||||
//% help=led/brightness weight=60 shim=micro_bit::getBrightness
|
|
||||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
|
||||||
export function brightness(): number {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the screen brightness from 0 (off) to 255 (full bright).
|
|
||||||
* @param value the brightness value, eg:255, 127, 0
|
|
||||||
*/
|
|
||||||
//% help=led/set-brightness weight=59 shim=micro_bit::setBrightness
|
|
||||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
|
||||||
export function setBrightness(value: number): void { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancels the current animation and clears other pending animations.
|
|
||||||
*/
|
|
||||||
//% weight=50 shim=uBit.display.stopAnimation help=led/stop-animation
|
|
||||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
|
||||||
export function stopAnimation(): void { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a vertical bar graph based on the ``value`` and ``high`` value.
|
* Displays a vertical bar graph based on the ``value`` and ``high`` value.
|
||||||
@ -69,7 +10,7 @@ namespace led {
|
|||||||
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
|
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
|
||||||
export function plotBarGraph(value: number, high: number): void {
|
export function plotBarGraph(value: number, high: number): void {
|
||||||
|
|
||||||
writeString(value.toString() + "\r\n");
|
serial.writeString(value.toString() + "\r\n");
|
||||||
|
|
||||||
let v = Math.abs((value * 15) / high);
|
let v = Math.abs((value * 15) / high);
|
||||||
let k = 0;
|
let k = 0;
|
||||||
@ -87,19 +28,6 @@ namespace led {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a string to serial
|
|
||||||
*/
|
|
||||||
//% shim=micro_bit::serialSendString
|
|
||||||
function writeString(text: string): void { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
|
||||||
* @param mode TODO
|
|
||||||
*/
|
|
||||||
//% shim=micro_bit::setDisplayMode weight=1 help=/led/set-display-mode
|
|
||||||
export function setDisplayMode(mode: DisplayMode): void { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles a particular pixel
|
* Toggles a particular pixel
|
||||||
* @param x TODO
|
* @param x TODO
|
||||||
@ -182,25 +110,5 @@ namespace led {
|
|||||||
led.setBrightness(0);
|
led.setBrightness(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes a screenshot of the LED screen and returns an image.
|
|
||||||
*/
|
|
||||||
//% shim=uBit.display.screenShot help=led/screenshot
|
|
||||||
export function screenshot(): Image {
|
|
||||||
/*
|
|
||||||
let img: Image;
|
|
||||||
img = image.createImage("");
|
|
||||||
for (let i = 0; i < 5; i++) {
|
|
||||||
for (let j = 0; j < 5; j++) {
|
|
||||||
if (led.point(i, j)) {
|
|
||||||
img.setPixel(i, j, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return img;
|
|
||||||
*/
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
108
libs/microbit/shims.d.ts
vendored
108
libs/microbit/shims.d.ts
vendored
@ -174,7 +174,7 @@ declare namespace input {
|
|||||||
* @param name TODO
|
* @param name TODO
|
||||||
* @param body TODO
|
* @param body TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-pressed weight=83 shim=micro_bit::onPinPressed
|
//% help=input/on-pin-pressed weight=83
|
||||||
//% blockId=device_pin_event block="on pin|%NAME|pressed" icon="\uf094" shim=input::onPinPressed
|
//% blockId=device_pin_event block="on pin|%NAME|pressed" icon="\uf094" shim=input::onPinPressed
|
||||||
function onPinPressed(name: TouchPin, body: () => void): void;
|
function onPinPressed(name: TouchPin, body: () => void): void;
|
||||||
|
|
||||||
@ -182,7 +182,6 @@ declare namespace input {
|
|||||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||||
*/
|
*/
|
||||||
//% help=input/button-is-pressed weight=57
|
//% help=input/button-is-pressed weight=57
|
||||||
//% shim=micro_bit::isButtonPressed
|
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
//% blockId=device_get_button2
|
//% blockId=device_get_button2
|
||||||
//% icon="\uf192" blockGap=8 shim=input::buttonIsPressed
|
//% icon="\uf192" blockGap=8 shim=input::buttonIsPressed
|
||||||
@ -193,7 +192,6 @@ declare namespace input {
|
|||||||
*/
|
*/
|
||||||
//% help=input/compass-heading
|
//% help=input/compass-heading
|
||||||
//% weight=56 icon="\uf14e"
|
//% weight=56 icon="\uf14e"
|
||||||
//% shim=micro_bit::compassHeading
|
|
||||||
//% blockId=device_heading block="compass heading (°)" blockGap=8 shim=input::compassHeading
|
//% blockId=device_heading block="compass heading (°)" blockGap=8 shim=input::compassHeading
|
||||||
function compassHeading(): number;
|
function compassHeading(): number;
|
||||||
|
|
||||||
@ -201,7 +199,7 @@ declare namespace input {
|
|||||||
* Gets the temperature in Celsius degrees (°C).
|
* Gets the temperature in Celsius degrees (°C).
|
||||||
*/
|
*/
|
||||||
//% weight=55 icon="\uf06d"
|
//% weight=55 icon="\uf06d"
|
||||||
//% help=input/temperature shim=micro_bit::temperature
|
//% help=input/temperature
|
||||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8 shim=input::temperature
|
//% blockId=device_temperature block="temperature (°C)" blockGap=8 shim=input::temperature
|
||||||
function temperature(): number;
|
function temperature(): number;
|
||||||
|
|
||||||
@ -210,14 +208,13 @@ declare namespace input {
|
|||||||
* @param dimension TODO
|
* @param dimension TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/acceleration weight=54 icon="\uf135"
|
//% help=input/acceleration weight=54 icon="\uf135"
|
||||||
//% shim=micro_bit::getAcceleration
|
|
||||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 shim=input::acceleration
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 shim=input::acceleration
|
||||||
function acceleration(dimension: Dimension): number;
|
function acceleration(dimension: Dimension): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* 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=input/light-level weight=53 shim=micro_bit::lightLevel
|
//% help=input/light-level weight=53
|
||||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185" shim=input::lightLevel
|
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185" shim=input::lightLevel
|
||||||
function lightLevel(): number;
|
function lightLevel(): number;
|
||||||
|
|
||||||
@ -225,7 +222,7 @@ declare namespace input {
|
|||||||
* The pitch of the device, rotation along the ``x-axis``, in degrees.
|
* The pitch of the device, rotation along the ``x-axis``, in degrees.
|
||||||
* @param kind TODO
|
* @param kind TODO
|
||||||
*/
|
*/
|
||||||
//% help=/input/rotation weight=52 shim=micro_bit::getRotation
|
//% help=/input/rotation weight=52
|
||||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197" shim=input::rotation
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197" shim=input::rotation
|
||||||
function rotation(kind: Rotation): number;
|
function rotation(kind: Rotation): number;
|
||||||
|
|
||||||
@ -233,28 +230,28 @@ declare namespace input {
|
|||||||
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
|
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
|
||||||
* @param dimension TODO
|
* @param dimension TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/magnetic-force weight=51 shim=micro_bit::getMagneticForce
|
//% help=input/magnetic-force weight=51
|
||||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076" shim=input::magneticForce
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076" shim=input::magneticForce
|
||||||
function magneticForce(dimension: Dimension): number;
|
function magneticForce(dimension: Dimension): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of milliseconds elapsed since power on.
|
* Gets the number of milliseconds elapsed since power on.
|
||||||
*/
|
*/
|
||||||
//% help=input/running-time shim=micro_bit::getCurrentTime weight=50
|
//% help=input/running-time weight=50
|
||||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017" shim=input::runningTime
|
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017" shim=input::runningTime
|
||||||
function runningTime(): number;
|
function runningTime(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obsolete, compass calibration is automatic.
|
* Obsolete, compass calibration is automatic.
|
||||||
*/
|
*/
|
||||||
//% help=input/calibrate weight=0 shim=TD_NOOP shim=input::calibrate
|
//% help=input/calibrate weight=0 shim=input::calibrate
|
||||||
function calibrate(): void;
|
function calibrate(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||||
* @param name pin used to detect the touch
|
* @param name pin used to detect the touch
|
||||||
*/
|
*/
|
||||||
//% help=input/pin-is-pressed weight=58 shim=micro_bit::isPinTouched block="pin|%NAME|is pressed" icon="\uf094" shim=input::pinIsPressed
|
//% help=input/pin-is-pressed weight=58 block="pin|%NAME|is pressed" icon="\uf094" shim=input::pinIsPressed
|
||||||
function pinIsPressed(name: TouchPin): boolean;
|
function pinIsPressed(name: TouchPin): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,8 +260,7 @@ declare namespace input {
|
|||||||
*/
|
*/
|
||||||
//% help=input/set-accelerator-range
|
//% help=input/set-accelerator-range
|
||||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||||
//% weight=5
|
//% weight=5 shim=input::setAccelerometerRange
|
||||||
//% shim=micro_bit::setAccelerometerRange shim=input::setAccelerometerRange
|
|
||||||
function setAccelerometerRange(range: AcceleratorRange): void;
|
function setAccelerometerRange(range: AcceleratorRange): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,6 +303,74 @@ declare namespace control {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//% color=3 weight=35
|
||||||
|
declare namespace led {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
|
* @param x TODO
|
||||||
|
* @param y TODO
|
||||||
|
*/
|
||||||
|
//% help=led/plot weight=78 shim=micro_bit::plot
|
||||||
|
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8 shim=led::plot
|
||||||
|
function plot(x: number, y: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
|
* @param x TODO
|
||||||
|
* @param y TODO
|
||||||
|
*/
|
||||||
|
//% help=led/unplot weight=77 shim=micro_bit::unPlot
|
||||||
|
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8 shim=led::unplot
|
||||||
|
function unplot(x: number, y: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.
|
||||||
|
* @param x TODO
|
||||||
|
* @param y TODO
|
||||||
|
*/
|
||||||
|
//% help=led/point weight=76 shim=micro_bit::point
|
||||||
|
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c" shim=led::point
|
||||||
|
function point(x: number, y: number): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||||
|
*/
|
||||||
|
//% help=led/brightness weight=60 shim=micro_bit::getBrightness
|
||||||
|
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8 shim=led::brightness
|
||||||
|
function brightness(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the screen brightness from 0 (off) to 255 (full bright).
|
||||||
|
* @param value the brightness value, eg:255, 127, 0
|
||||||
|
*/
|
||||||
|
//% help=led/set-brightness weight=59 shim=micro_bit::setBrightness
|
||||||
|
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042" shim=led::setBrightness
|
||||||
|
function setBrightness(value: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels the current animation and clears other pending animations.
|
||||||
|
*/
|
||||||
|
//% weight=50 shim=uBit.display.stopAnimation help=led/stop-animation
|
||||||
|
//% blockId=device_stop_animation block="stop animation" icon="\uf04d" shim=led::stopAnimation
|
||||||
|
function stopAnimation(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
||||||
|
* @param mode TODO
|
||||||
|
*/
|
||||||
|
//% shim=micro_bit::setDisplayMode weight=1 help=/led/set-display-mode shim=led::setDisplayMode
|
||||||
|
function setDisplayMode(mode: DisplayMode): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a screenshot of the LED screen and returns an image.
|
||||||
|
*/
|
||||||
|
//% shim=uBit.display.screenShot help=led/screenshot shim=led::screenshot
|
||||||
|
function screenshot(): Image;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//% color=351 weight=30
|
//% color=351 weight=30
|
||||||
declare namespace pins {
|
declare namespace pins {
|
||||||
|
|
||||||
@ -314,7 +378,7 @@ declare namespace pins {
|
|||||||
* Read the specified pin or connector as either 0 or 1
|
* Read the specified pin or connector as either 0 or 1
|
||||||
* @param name pin to read from
|
* @param name pin to read from
|
||||||
*/
|
*/
|
||||||
//% help=pins/digital-read-pin weight=30 shim=micro_bit::digitalReadPin
|
//% help=pins/digital-read-pin weight=30
|
||||||
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin
|
||||||
function digitalReadPin(name: DigitalPin): number;
|
function digitalReadPin(name: DigitalPin): number;
|
||||||
|
|
||||||
@ -323,7 +387,7 @@ declare namespace pins {
|
|||||||
* @param name pin to write to
|
* @param name pin to write to
|
||||||
* @param value value to set on the pin, 1 eg,0
|
* @param value value to set on the pin, 1 eg,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/digital-write-pin weight=29 shim=micro_bit::digitalWritePin
|
//% help=pins/digital-write-pin weight=29
|
||||||
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value" shim=pins::digitalWritePin
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value" shim=pins::digitalWritePin
|
||||||
function digitalWritePin(name: DigitalPin, value: number): void;
|
function digitalWritePin(name: DigitalPin, value: number): void;
|
||||||
|
|
||||||
@ -331,7 +395,7 @@ declare namespace pins {
|
|||||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||||
* @param name pin to write to
|
* @param name pin to write to
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-read-pin weight=25 shim=micro_bit::analogReadPin
|
//% help=pins/analog-read-pin weight=25
|
||||||
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin
|
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin
|
||||||
function analogReadPin(name: AnalogPin): number;
|
function analogReadPin(name: AnalogPin): number;
|
||||||
|
|
||||||
@ -340,7 +404,7 @@ declare namespace pins {
|
|||||||
* @param name pin name to write to
|
* @param name pin name to write to
|
||||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-write-pin weight=24 shim=micro_bit::analogWritePin
|
//% help=pins/analog-write-pin weight=24
|
||||||
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 shim=pins::analogWritePin
|
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 shim=pins::analogWritePin
|
||||||
function analogWritePin(name: AnalogPin, value: number): void;
|
function analogWritePin(name: AnalogPin, value: number): void;
|
||||||
|
|
||||||
@ -350,7 +414,7 @@ declare namespace pins {
|
|||||||
* @param name analog pin to set period to
|
* @param name analog pin to set period to
|
||||||
* @param micros period in micro seconds. eg:20000
|
* @param micros period in micro seconds. eg:20000
|
||||||
*/
|
*/
|
||||||
//% shim=micro_bit::setAnalogPeriodUs help=pins/analog-set-period weight=23
|
//% help=pins/analog-set-period weight=23
|
||||||
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
|
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
|
||||||
function analogSetPeriod(name: AnalogPin, micros: number): void;
|
function analogSetPeriod(name: AnalogPin, micros: number): void;
|
||||||
|
|
||||||
@ -359,7 +423,7 @@ declare namespace pins {
|
|||||||
* @param name pin to write to
|
* @param name pin to write to
|
||||||
* @param value angle or rotation speed, eg:180,90,0
|
* @param value angle or rotation speed, eg:180,90,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/servo-write-pin weight=20 shim=micro_bit::servoWritePin
|
//% help=pins/servo-write-pin weight=20
|
||||||
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 shim=pins::servoWritePin
|
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 shim=pins::servoWritePin
|
||||||
function servoWritePin(name: AnalogPin, value: number): void;
|
function servoWritePin(name: AnalogPin, value: number): void;
|
||||||
|
|
||||||
@ -368,7 +432,7 @@ declare namespace pins {
|
|||||||
* @param name pin name
|
* @param name pin name
|
||||||
* @param micros pulse duration in micro seconds, eg:1500
|
* @param micros pulse duration in micro seconds, eg:1500
|
||||||
*/
|
*/
|
||||||
//% shim=micro_bit::setServoPulseUs help=pins/serial-set-pulse weight=19
|
//% help=pins/serial-set-pulse weight=19
|
||||||
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros" shim=pins::servoSetPulse
|
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros" shim=pins::servoSetPulse
|
||||||
function servoSetPulse(name: AnalogPin, micros: number): void;
|
function servoSetPulse(name: AnalogPin, micros: number): void;
|
||||||
|
|
||||||
@ -376,7 +440,7 @@ declare namespace pins {
|
|||||||
* Sets the pin used when using `pins->analog pitch`.
|
* Sets the pin used when using `pins->analog pitch`.
|
||||||
* @param name TODO
|
* @param name TODO
|
||||||
*/
|
*/
|
||||||
//% shim=micro_bit::enablePitch help=pins/analog-set-pitch weight=12 shim=pins::analogSetPitchPin
|
//% help=pins/analog-set-pitch weight=12 shim=pins::analogSetPitchPin
|
||||||
function analogSetPitchPin(name: AnalogPin): void;
|
function analogSetPitchPin(name: AnalogPin): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -384,7 +448,7 @@ declare namespace pins {
|
|||||||
* @param frequency TODO
|
* @param frequency TODO
|
||||||
* @param ms TODO
|
* @param ms TODO
|
||||||
*/
|
*/
|
||||||
//% shim=micro_bit::pitch help=pins/analog-pitch weight=14 async shim=pins::analogPitch
|
//% help=pins/analog-pitch weight=14 async shim=pins::analogPitch
|
||||||
function analogPitch(frequency: number, ms: number): void;
|
function analogPitch(frequency: number, ms: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user