Skip to content

Commit e309e62

Browse files
committed
Update README.md
1 parent c4329c1 commit e309e62

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,62 @@
11
# Makecode Extension to enable power management on micro:bit (V2)
22

3-
Use this extension to add all the blocks you will need to power the micro:bit on and off in your program when you are using the [latest micro:bit](https://microbit.org/new-microbit/).
3+
Use this extension to add all the blocks you will need to use less power in your program when you are using the [latest micro:bit](https://microbit.org/new-microbit/).
44

55
This extension might be useful when you want to conserve battery power, such as during a data logging activity.
66

7+
78
## Usage
89

9-
### Put the micro:bit to sleep 💤
10+
### Put the micro:bit to sleep in a low power mode 💤
1011

11-
To make the micro:bit sleep, you need to send a request to power it down. The ``||power.powerDownRequest||`` block will ask the micro:bit to power down at the next opportunity, such as when the current code operation has been allowed to complete.
12+
The ``||power.lowPowerRequest||`` block will ask the micro:bit to switch to low power mode at the next opportunity, such as when the current code operation has been allowed to complete, or inside ``||basic.pause(ms)||``.
1213

1314
```blocks
1415
input.onButtonPressed(Button.B, function () {
15-
power.powerDownRequest()
16+
power.lowPowerRequest()
1617
})
1718
```
1819

19-
You can also ask the micro:bit to enter a ``||power.deepSleep||`` where it will pause until a wake up event occurs and power down at the next opportunity.
20+
You can send ``||power.lowPowerRequest(LowPowerMode.Wait)||``. Then micro:bit will also pause until a full power event occurs.
21+
22+
The ``||power.lowPowerPause(ms)||`` block will ask the micro:bit to sleep for a set interval in milliseconds.
2023

21-
The ``||power.deepSleepPause(ms)||`` block will also ask the micro:bit to sleep for a set interval in milliseconds.
24+
In low power mode, micro:bit is asleep, and your program is paused. When micro:bit wakes up to full power mode, your program continues from the point it stopped.
2225

23-
You can also use the ``||PowerDown.prevent||`` and ``||PowerDown.allow||`` blocks to block a power down request until the code inside the two blocks has finished running. It is expected that you would use these blocks in pairs.
26+
You can use the ``||power.lowPowerEnable(PowerDown.prevent)||`` and ``||power.lowPowerEnable(PowerDown.allow)||`` blocks to block low power requests until the code between the two blocks has finished running. It is expected that you would use these blocks in pairs.
2427

2528
```blocks
2629
basic.forever(function () {
27-
power.powerDownEnable(PowerDown.prevent)
30+
power.lowPowerEnable(PowerDown.prevent)
2831
led.plot(2, 2)
2932
basic.pause(1000)
3033
led.unplot(2, 2)
3134
led.plot(2, 1)
3235
basic.pause(1000)
3336
led.unplot(2, 1)
34-
power.powerDownEnable(PowerDown.allow)
35-
power.powerDownRequest()
37+
power.lowPowerEnable(PowerDown.allow)
38+
power.lowPowerRequest()
3639
})
3740
```
3841

39-
### Wake the micro:bit from sleep
42+
### Wake up micro:bit to full power mode
4043

41-
In order to wake the micro:bit, you need to define an event to trigger the wake up call.
44+
In order to wake up micro:bit to full power mode, you need to define an event to trigger the wake up call.
4245

4346
You can wake the micro:bit when a button or pin is pressed. In this example, the micro:bit will wake up when Button A or Pin 0 has been pressed.
4447

4548
```blocks
46-
power.wakeOnEnable(PowerWakeup.A)
47-
power.wakeOnEnable(PowerWakeup.P0)
49+
power.fullPowerOn(FullPowerSource.A)
50+
power.fullPowerOn(FullPowerSource.P0)
4851
```
4952

5053
You can also wake the micro:bit at a set time interval in milliseconds. In this example, the micro:bit will wake up every minute and show a smiley face on the screen
5154

5255
```blocks
53-
power.wakeEvery(60000, function () {
56+
power.fullPowerEvery(60000, function () {
5457
basic.showIcon(IconNames.Happy)
5558
basic.clearScreen()
59+
power.lowPowerRequest()
5660
})
5761
```
5862

0 commit comments

Comments
 (0)