Skip to content

Turning on the radio by default #97

Closed
@microbit-carlos

Description

@microbit-carlos

For the micro:bit radio to be used example programmes are usually like this:

import radio

radio.on()
radio.send('hello')
from microbit import *
import radio

radio.on()
while True:
    message = radio.receive()
    if message:
        display.scroll(message)

In all cases radio.on() is necessary to start using the radio, otherwise functions like radio.send() or radio.receive() will throw an exception ValueError: radio is not enabled.

The majority of the micro:bit features, specially those that can be turned off like the display, are "on" by default.
The reason this is not the case for radio is because it has a significant impact on power consumption, about 10 mA as measure by Damien from USB, however:

  • The majority of programmes turn on the radio immediately after import, so no difference there
  • Any power conscious applications would still have the option to turn on and off the radio as needed

If we are to enable the radio by default we have two options:
a) Do it on import
- Disadvantage: If an existing programme runs a lot of code before calling radio.on(), this is time with a larger power consumption
b) Do it on the first call of radio.send()/.receive()/etc
- Disadvantage: In this case the first call of radio.receive() would only turn on the radio, as it cannot receive anything while it's off

We also need to consider if this would be a breaking change, as ideally we'd like to avoid that.

And, of course, we would have to mirror this to the MicroPython for V1 port.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions