hub – hub brick functionality

Classes and functions related to simple parts and abilities of the Hub brick itself, like buttons, ports, and internal sensors.

These are lower-level functions than the API ones (the API seems to import this module a lot) and as such they provide greater control, although with a corresponding amount of risk of things going wrong if you use them improperly.

Constants

hub.__version__ = v1.0.06.0034-b0c335b

Functions

hub.info(???)

???

hub.power_off(???)

???

hub.repl_restart(???)

???

hub.status(???)

???

hub.led(???)

???

hub.temperature(???)

???

hub.file_transfer(???)

???

Imports

Objects and Classes

It’s not quite clear from MicroPython help text whether these are classes or instances of classes. For the moment I’m assuming both, since some have different names from the object they point to. But if that’s the case it’s not clear where the class lives!

hub.port
class hub.Port(???)

???

Constants

DETACHED = 0

???

ATTACHED = 1

???

A = Port(A)
B = Port(B)
C = Port(C)
D = Port(D)
E = Port(E)
F = Port(F)

???

MODE_DEFAULT = 0

???

MODE_FULL_DUPLEX = 1

???

MODE_HALF_DUPLEX = 2

???

MODE_GPIO = 3

???

Port(X)

These are objects in their own right, with the following contents:

Methods .. method:: callback(???)

???

info(???)

???

mode(???)

???

pwm(???)

???

Variables .. data:: device

??? Observed value: None

motor

??? Observed value: None

hub.display
class hub.Display(???)

???

pixel(???)

???

show(???)

???

callback(???)

???

clear(???)

???

rotation(???)

???

hub.button
class hub.Button(???)

???

Members

center = center
left = left
right = right
connect = connect

Represent each of the four buttons on the Hub (the main button in the center, left, right, and the bluetooth connect button). The values are objects with the following contents:

is_pressed(???)

???

was_pressed(???)

???

presses(???)

???

callback(???)

???

on_change(???)

???

hub.sound
class hub.Sound(???)

???

Methods

volume(???)

???

beep(???)

???

play(???)

???

callback(???)

???

Constants

SOUND_SIN = 0

???

SOUND_SQUARE = 1

???

SOUND_TRIANGLE = 2

???

SOUND_SAWTOOTH = 3

???

hub.motion
class hub.Motion(???)

???

Methods

gyroscope(???)

???

gyroscope_filter(???)

???

accelerometer(???)

???

accelerometer_filter(???)

???

position(???)

???

reset_yaw(???)

???

preset_yaw(???)

???

orientation(???)

???

gesture(???)

???

was_gesture(???)

???

callback(???)

???

Constants

NONE = NULL

???

LEFTSIDE = leftside

???

RIGHTSIDE = rightside

???

DOWN = down

???

UP = up

???

FRONT = front

???

BACK = back

???

TAPPED = tapped

???

DOUBLETAPPED = doubletapped

???

SHAKE = shake

???

FREEFALL = freefall

???

hub.battery
class hub.Battery(???)

???

Methods

voltage(???)

???

current(???)

???

temperature(???)

???

charger_detect(???)

???

info(???)

???

capacity_left(???)

???

Constants

BATTERY_NO_ERROR = 0

???

BATTERY_HUB_TEMPERATURE_CRITICAL_OUT_OF_RANGE = -2

???

BATTERY_TEMPERATURE_OUT_OF_RANGE = -2

???

BATTERY_TEMPERATURE_SENSOR_FAIL = -3

???

BATTERY_BAD_BATTERY = -4

???

BATTERY_VOLTAGE_TOO_LOW = -5

???

USB_CH_PORT_NONE = 0

???

USB_CH_PORT_SDP = 1

???

USB_CH_PORT_CDP = 2

???

USB_CH_PORT_DCP = 3

???

CHARGER_STATE_FAIL = -1

???

CHARGER_STATE_DISCHARGING = 0

???

CHARGER_STATE_CHARGING_ONGOING = 1

???

CHARGER_STATE_CHARGING_COMPLETED = 2

???

hub.bluetooth
class hub.bt(???)

???

info(???)

???

discoverable(???)

???

hub.ble
class hub.bluetooth(???)

???

rssi(???)

???

mac(???)

???

scan(???)

???

scan_result(???)

???

connect(???)

???

callback(???)

???

hub.supervision
class hub.supervision(???)

???

info(???)

???

hub.BT_VCP
class hub.BT_VCP(???)

???

setinterrupt(???)

???

isconnected(???)

???

any(???)

???

send(???)

???

recv(???)

???

read(???)

???

readinto(???)

???

readline(???)

???

readlines(???)

???

write(???)

???

close(???)

???

__del__(???)

???

__enter__(???)

???

__exit__(???)

???

callback(???)

???

hub.USB_VCP
class hub.USB_VCP(???)

??? Has all the same contents as BT_VCP, with these extras:

Methods

init(???)

???

Constants

RTS = 1

???

CTS = 2

???