b2op-hub-micropython

Getting started

  • Quickstart
    • Minimal program
    • What the modules do
  • Examples
    • Distance sensor
    • Dumb-car (two motors + remote)
    • Port expander
    • IMU
    • LCD (LVGL)
    • BLE remote hub
    • Grove I2C (MPU-6050)
    • NeoPixel on a repurposed LPF2 port
      • Why hub.ports.D.disable() first
      • Re-enabling the port

Hub module

  • The hub module
    • Top-level members
    • Reference
  • Ports
    • Members
    • Lifecycle
    • Pausing a port
    • Reading sensor values
    • Wrapped built-in ports
  • Hub LED
  • IMU
    • Attitude
    • Raw samples
    • Calibration
    • Example loop
  • Buttons
    • Level readers
    • Callbacks
    • Exiting a program
    • Power-off
    • Callback registry snapshots
  • LCD
    • Init
    • Rendering loop
    • Backlight
    • Raw panel access
    • Soft reset
  • I2C (Grove connector)
    • Coexistence with the C++ side
    • Pins
    • Quickstart
    • Raw write / read
    • Register access
    • Full example — MPU-6050 accelerometer on Grove
    • API reference
  • Board constants
    • Logical pins and buses
    • Buses
    • Peripheral chips
    • Subsystems
    • SD card
    • Port pins
  • Program lifecycle
    • Running a program
    • Exiting a program
    • Powering off
    • Background poll hook
    • Log level
  • Host protocol framing — V2
    • Wire format
    • Kind table
    • Structured payloads
    • UPLOAD flow
    • Sequence / response matching
    • Fire-and-forget ordering (NO_ACK)
    • HELLO lifecycle
    • Why the C-level stdout hook
    • Transport fan-out
      • set_framed_output()
      • raw_write()
      • flush_output()
      • set_frame_sink()
    • Notes

LPF2 module

  • The lpf2 module
    • Layout
    • Design notes
      • Automatic polling
      • Subclassing
  • Ports
    • Lifecycle & polling
    • Forcing a device type (local ports only)
    • Detecting a device
    • Mode selection
    • Direct motor commands
    • Introspection
    • Raw I/O
  • Devices
    • Common methods
    • Registering factories
  • Motors
    • Conventions
    • Open-loop power
    • Continuous speed
    • Timed moves
    • Relative-degree moves
    • Absolute position
    • Ramp profiles
    • Motor tuning presets
  • Sensors
    • Colour sensor
    • Distance sensor
    • Colour + distance (legacy)
    • Built-in inertial sensors
  • Virtual devices
    • The pieces
    • Building a descriptor
    • Subclassing device
    • Attaching and running
    • GC pitfalls
  • Hub emulation
    • Typical setup
    • Runtime updates
    • Stop
    • Lifetime
  • Remote hub (BLE client)
    • Basic pattern
    • Ports on the remote hub
    • Manual port configuration
    • Hub properties
    • State flags
    • Shutdown
  • Battery
    • Voltage window
    • Manual voltage updates
    • Custom percent mapping
    • Built-in ADC reader
  • Enumerations
    • lpf2.color
    • lpf2.device_type
    • lpf2.hub_type
    • lpf2.alerts
    • lpf2.battery_type
    • lpf2.button_state
    • lpf2.hub_property
    • lpf2.port_num
  • Port expander
    • Sub-port numbering
    • Client side
    • Server side

Reference

  • hub
    • Attributes
    • Functions
    • Module Contents
      • exit()
      • flush_output()
      • on()
      • powerOff()
      • raw_write()
      • sd_card()
      • sd_remount()
      • set_frame_sink()
      • set_framed_output()
      • set_usb_msc()
      • usb_msc_mode()
      • accelerometer
      • audio
      • battery
      • board
      • buttons
      • gyro
      • i2c
      • imu
      • lcd
      • led
      • log
      • ports
      • pwm
      • video
  • lpf2
    • Submodules
      • lpf2.alerts
        • Attributes
        • Module Contents
      • lpf2.battery_type
        • Attributes
        • Module Contents
      • lpf2.button_state
        • Attributes
        • Module Contents
      • lpf2.color
        • Attributes
        • Module Contents
      • lpf2.device_type
        • Attributes
        • Module Contents
      • lpf2.devices
        • Classes
        • Functions
        • Package Contents
      • lpf2.hub_property
        • Attributes
        • Module Contents
      • lpf2.hub_type
        • Attributes
        • Module Contents
      • lpf2.local
        • Classes
        • Package Contents
      • lpf2.port_expander
        • Submodules
        • Classes
        • Package Contents
      • lpf2.port_num
        • Submodules
      • lpf2.virtual
        • Classes
        • Package Contents
    • Classes
    • Package Contents
      • battery
        • battery.getCurrentVoltage()
        • battery.getMaxVoltage()
        • battery.getMinVoltage()
        • battery.getPercent()
        • battery.readBatteryVoltage()
        • battery.setCurrentVoltage()
        • battery.setMaxVoltage()
        • battery.setMinVoltage()
        • battery.setPercentFunc()
        • battery.setupAdcDivider()
      • device_descriptor
        • device_descriptor.fwVersion
        • device_descriptor.hwVersion
        • device_descriptor.modes
      • hub
        • hub.connectHub()
        • hub.getAllInfoStr()
        • hub.getBatteryType()
        • hub.getHubAddress()
        • hub.getHubPropStr()
        • hub.getHubType()
        • hub.getName()
        • hub.getPort()
        • hub.infoReady()
        • hub.init()
        • hub.isConnected()
        • hub.isConnecting()
        • hub.isScanning()
        • hub.setName()
        • hub.setPortMode()
        • hub.setPortModeCombo()
        • hub.shutDownHub()
        • hub.update()
      • hub_emulation
        • hub_emulation.attachPort()
        • hub_emulation.getName()
        • hub_emulation.setAlert()
        • hub_emulation.setBatteryLevel()
        • hub_emulation.setBatteryType()
        • hub_emulation.setButtonState()
        • hub_emulation.setFirmwareVersion()
        • hub_emulation.setHardwareVersion()
        • hub_emulation.setName()
        • hub_emulation.setUseBuiltInDevices()
        • hub_emulation.start()
        • hub_emulation.stop()
      • mode
        • mode.PCTmax
        • mode.PCTmin
        • mode.SImax
        • mode.SImin
        • mode.dataSets
        • mode.decimals
        • mode.figures
        • mode.flags
        • mode.format
        • mode.inMapping
        • mode.max
        • mode.min
        • mode.motorBias
        • mode.name
        • mode.outMapping
        • mode.rawData
      • motor_setting
        • motor_setting.medium_linear
        • motor_setting.technic_large_angular
        • motor_setting.technic_large_angular_grey
        • motor_setting.technic_large_linear
        • motor_setting.technic_medium_angular
        • motor_setting.technic_medium_angular_grey
        • motor_setting.technic_xlarge_linear
      • port
        • port.device()
        • port.disable()
        • port.enable()
        • port.getCapabilities()
        • port.getDeviceType()
        • port.getInfoStr()
        • port.getInputModes()
        • port.getMode()
        • port.getModeCombo()
        • port.getModeComboCount()
        • port.getModeCount()
        • port.getOutputModes()
        • port.getValue()
        • port.getValueStr()
        • port.getViewCount()
        • port.gotoAbsPosition()
        • port.init()
        • port.isDeviceConnected()
        • port.isDisabled()
        • port.presetEncoder()
        • port.rawToSpeed()
        • port.setAccTime()
        • port.setDecTime()
        • port.setMode()
        • port.setModeCombo()
        • port.setRgbColor()
        • port.setRgbColorIdx()
        • port.speedToRaw()
        • port.startPower()
        • port.startSpeed()
        • port.startSpeedForDegrees()
        • port.startSpeedForTime()
        • port.update()
        • port.writeData()
      • version
        • version.Bugfix
        • version.Build
        • version.Major
        • version.Minor
  • machine
    • Attributes
    • Classes
    • Functions
    • Module Contents
      • ADC
        • ADC.read()
        • ADC.read_u16()
        • ADC.read_uv()
      • DAC
        • DAC.deinit()
        • DAC.write()
      • I2C
        • I2C.readfrom()
        • I2C.readfrom_into()
        • I2C.readfrom_mem()
        • I2C.readfrom_mem_into()
        • I2C.scan()
        • I2C.writeto()
        • I2C.writeto_mem()
        • I2C.writevto()
      • I2S
        • I2S.deinit()
        • I2S.readinto()
        • I2S.shift()
        • I2S.write()
        • I2S.MONO
        • I2S.RX
        • I2S.STEREO
        • I2S.TX
      • PWM
        • PWM.deinit()
        • PWM.duty()
        • PWM.duty_ns()
        • PWM.duty_u16()
        • PWM.freq()
      • Pin
        • Pin.irq()
        • Pin.off()
        • Pin.on()
        • Pin.value()
        • Pin.IN
        • Pin.IRQ_FALLING
        • Pin.IRQ_RISING
        • Pin.OPEN_DRAIN
        • Pin.OUT
        • Pin.PULL_DOWN
        • Pin.PULL_UP
      • SPI
        • SPI.read()
        • SPI.readinto()
        • SPI.write()
        • SPI.write_readinto()
        • SPI.LSB
        • SPI.MSB
      • UART
        • UART.any()
        • UART.flush()
        • UART.irq()
        • UART.read()
        • UART.readinto()
        • UART.readline()
        • UART.write()
        • UART.CTS
        • UART.INV_CTS
        • UART.INV_RTS
        • UART.INV_RX
        • UART.INV_TX
        • UART.IRQ_BREAK
        • UART.IRQ_RX
        • UART.IRQ_RXIDLE
        • UART.RTS
      • MAKE_BUS()
      • MAKE_PIN()
      • BUS_ADC
      • BUS_I2C
      • BUS_I2S
      • BUS_LEDC
      • BUS_MCPWM
      • BUS_NONE
      • BUS_SPI
      • BUS_UART
      • BUS_UART_CH9434
      • BUS_UART_SC16IS750
      • PERIPH_BNO085
      • PERIPH_CH9434
      • PERIPH_COMBINED
      • PERIPH_DRV8908Q1
      • PERIPH_ESP32
      • PERIPH_LSM6DSL
      • PERIPH_PCA9685
      • PERIPH_SC16IS750
      • PERIPH_ST7735
      • PERIPH_TLA2528
      • PIN_NONE
b2op-hub-micropython
  • Python Module Index

Python Module Index

h | l | m
 
h
hub
 
l
- lpf2
    lpf2.alerts
    lpf2.battery_type
    lpf2.button_state
    lpf2.color
    lpf2.device_type
    lpf2.devices
    lpf2.hub_property
    lpf2.hub_type
    lpf2.local
    lpf2.port_expander
    lpf2.port_expander.port_num
    lpf2.port_num
    lpf2.port_num.controlplus
    lpf2.port_num.duplotrain
    lpf2.port_num.mario
    lpf2.port_num.movehub
    lpf2.port_num.poweredup
    lpf2.port_num.poweredupremote
    lpf2.virtual
 
m
machine

© Copyright 2026, b2op-hub-micropython contributors.

Built with Sphinx using a theme provided by Read the Docs.