hub
Everything built into the hub.
Start your program with import hub. Then use hub.ports for
motors and sensors, hub.led for the light, hub.buttons,
hub.imu (motion sensor), hub.lcd (screen), hub.audio
(sound), hub.battery and more.
Submodules
Attributes
measures pushes and gravity along x, y and z. |
|
Which firmware version the hub is running, e.g. |
|
measures how fast the hub spins around x, y and z. |
|
The I2C connection on the hub's Grove connector, for extra sensors and gadgets. |
|
The hub's built-in colored light. Try |
Functions
|
Stop your program right here. |
|
Turn the hub off. |
|
The SD card, or |
|
Re-connect the SD card at |
|
Show ( |
|
Stop every button callback ( |
|
|
Package Contents
- hub.exit() NoReturn[source]
Stop your program right here.
The hub shows “Done”, just like when a program reaches its end.
- hub.powerOff() NoReturn[source]
Turn the hub off.
If a USB cable keeps it powered, the hub stops motors, the screen and Bluetooth and goes to sleep instead; press the center button to wake it.
- hub.sd_card() machine.SDCard | None[source]
The SD card, or
Noneif there is no card.Files on the card are found under
/sd, e.g./sd/song.mid.
- hub.sd_remount() None[source]
Re-connect the SD card at
/sd.Use it after turning off USB drive mode (see
set_usb_msc()) so your program can use the card again.
- hub.set_usb_msc(enabled: bool) None[source]
Show (
True) or hide (False) the SD card as a USB drive on your computer.While it’s shown as a drive, your program can’t use the card. After hiding it, call
sd_remount()to use it again.
- hub.stop_callbacks() int[source]
Stop every button callback (
hub.buttons.on()) that is still running.Each one stops at its next line of Python or inside its current
time.sleep_ms. Returns how many were told to stop. Calling it from inside a callback stops all the others, not the caller. Registered callbacks stay registered and run again on the next press.
- hub.accelerometer: lpf2.devices.accelerometer[source]
measures pushes and gravity along x, y and z.
- Type:
The built-in accelerometer
- hub.gyro: lpf2.devices.gyroscope[source]
measures how fast the hub spins around x, y and z.
- Type:
The built-in gyroscope
- hub.i2c: machine.I2C[source]
The I2C connection on the hub’s Grove connector, for extra sensors and gadgets.
It is a ready-to-use
machine.I2C— tryhub.i2c.scan()to list what’s connected. Some built-in parts of the hub share this connection.
- hub.led: lpf2.devices.hub_led[source]
The hub’s built-in colored light. Try
hub.led.setColor(255, 0, 0)for red.