This commit is contained in:
Tom Ball 2016-06-14 17:21:02 -04:00
commit 0c67cd8e8b
8 changed files with 134 additions and 16 deletions

View File

@ -29,7 +29,7 @@ the magnetic force is stronger, and dimmer when it is weaker.
```blocks ```blocks
led.plot(2, 2) led.plot(2, 2)
basic.forever(() => { basic.forever(() => {
let f = input.magneticForce("x") let f = input.magneticForce(Dimension.X)
led.setBrightness(f / 2000) led.setBrightness(f / 2000)
}) })
``` ```

View File

@ -1,6 +1,6 @@
# Brightness # Brightness
Find how bright the [LED screen](/device/screen) is. Find how bright the [LED screen](/device/screen) is _when it is turned on_.
```sig ```sig
led.brightness(); led.brightness();
@ -8,11 +8,11 @@ led.brightness();
### Returns ### Returns
* a [Number](/reference/types/number) that means how bright the screen is, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright. * a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on.
### Example: highest brightness ### Example: highest brightness
This program makes the screen completely bright if it is not that way already: This program makes the screen completely bright when it is turned on (if it is not that way already):
```blocks ```blocks
if (led.brightness() < 255) { if (led.brightness() < 255) {
@ -20,6 +20,20 @@ if (led.brightness() < 255) {
} }
``` ```
### Example: change brightness
This program makes the screen brightness 100% (255). Then it turns on
the center LED (`2, 2`), waits for one second and then sets the screen
brightness to 50% (128):
```blocks
led.setBrightness(255)
led.plot(2, 2)
basic.pause(1000)
led.setBrightness(led.brightness() / 2)
```
### See also ### See also
[set brightness](/reference/led/set-brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out) [set brightness](/reference/led/set-brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out)

View File

@ -1,6 +1,7 @@
# Set Brightness # Set Brightness
Sets the brightness of the [LED screen](/device/screen). Make the [LED screen](/device/screen) as bright as you say when it is
turned on.
```sig ```sig
led.setBrightness(121) led.setBrightness(121)
@ -8,17 +9,19 @@ led.setBrightness(121)
### Parameters ### Parameters
* value : [Number](/reference/types/number) - the brightness of the LED screen expressed as a number between 0 and 255 * a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on.
### Example: change brightness ### Example: change brightness
The following example sets the screen brightness to 100% (255), turns on LED `2, 2`, waits for a second and then sets the screen brightness to 50% (127): This program makes the screen brightness 100% (255). Then it turns on
the center LED (`2, 2`), waits for one second, and then sets the screen
brightness to 50% (128):
```blocks ```blocks
led.setBrightness(255) led.setBrightness(255)
led.plot(2, 2) led.plot(2, 2)
basic.pause(1000) basic.pause(1000)
led.setBrightness(127) led.setBrightness(led.brightness() / 2)
``` ```
### See also ### See also

View File

@ -2,14 +2,59 @@
#include "MESEvents.h" #include "MESEvents.h"
using namespace pxt; using namespace pxt;
//% color=#0082FB weight=2 //% color=#0082FB weight=20
namespace bluetooth { namespace bluetooth {
/** /**
* Starts the Bluetooth IO pin service * Starts the Bluetooth IO pin service
*/ */
//% help=bluetooth/io-pin-service //% help=bluetooth/start-io-pin-service
//% blockId=bluetooth-io-pin-service block="bluetooth io pin service" //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
void startIOPinService() { void startIOPinService() {
new MicroBitIOPinService(*uBit.ble, uBit.io); new MicroBitIOPinService(*uBit.ble, uBit.io);
} }
/**
* Starts the Bluetooth LED service
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
void startLEDService() {
new MicroBitLEDService(*uBit.ble, uBit.display);
}
/**
* Starts the temperature service
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
void startTemperatureService() {
new MicroBitTemperatureService(*uBit.ble, uBit.thermometer);
}
/**
* Starts the magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
void startMagnetometerService() {
new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
}
/**
* Starts the accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
void startAccelerometerService() {
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
}
/**
* Starts the button service
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
void startButtonService() {
new MicroBitButtonService(*uBit.ble);
}
} }

View File

@ -20,5 +20,5 @@
} }
} }
}, },
"installedVersion": "bpcjjs" "installedVersion": "vzlhfd"
} }

View File

@ -2,15 +2,50 @@
//% color=#0082FB weight=2 //% color=#0082FB weight=20
declare namespace bluetooth { declare namespace bluetooth {
/** /**
* Starts the Bluetooth IO pin service * Starts the Bluetooth IO pin service
*/ */
//% help=bluetooth/io-pin-service //% help=bluetooth/start-io-pin-service
//% blockId=bluetooth-io-pin-service block="bluetooth io pin service" shim=bluetooth::startIOPinService //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8 shim=bluetooth::startIOPinService
function startIOPinService(): void; function startIOPinService(): void;
/**
* Starts the Bluetooth LED service
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8 shim=bluetooth::startLEDService
function startLEDService(): void;
/**
* Starts the temperature service
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8 shim=bluetooth::startTemperatureService
function startTemperatureService(): void;
/**
* Starts the magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8 shim=bluetooth::startMagnetometerService
function startMagnetometerService(): void;
/**
* Starts the accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8 shim=bluetooth::startAccelerometerService
function startAccelerometerService(): void;
/**
* Starts the button service
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8 shim=bluetooth::startButtonService
function startButtonService(): void;
} }
// Auto-generated. Do not edit. Really. // Auto-generated. Do not edit. Really.

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.2.160", "version": "0.2.161",
"description": "BBC micro:bit target for PXT", "description": "BBC micro:bit target for PXT",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",

View File

@ -614,6 +614,27 @@ namespace pxsim.pins {
} }
namespace pxsim.bluetooth {
export function startIOPinService(): void {
// TODO
}
export function startLEDService(): void {
// TODO
}
export function startTemperatureService(): void {
// TODO
}
export function startMagnetometerService(): void {
// TODO
}
export function startAccelerometerService(): void {
// TODO
}
export function startButtonService(): void {
// TODO
}
}
namespace pxsim.images { namespace pxsim.images {
export function createImage(img: Image) { return img } export function createImage(img: Image) { return img }
export function createBigImage(img: Image) { return img } export function createBigImage(img: Image) { return img }