lpf2.devices
Typed wrappers for LPF2 devices attached to a lpf2.port.
Each class corresponds to a C++ Lpf2::Devices::*Control interface
and is returned by lpf2.port.device() once the port’s factory has
identified the attached device.
Classes
Built-in hub accelerometer (mode 0 = GRV, unit: mG). |
|
Simple DC motor with no encoder (train motor, PF-M motor). |
|
Boost Color & Distance Sensor (legacy, WeDo/Boost). |
|
Technic Color Sensor. |
|
Technic Distance Sensor (time-of-flight). |
|
Motor with rotary encoder + position/speed control loops. |
|
Built-in hub gyroscope (mode 0 = ROT, unit: dps). |
|
RGB LED attached to a hub's built-in LED port. |
|
LPF2 Port Expander (extension module giving four sub-ports on one port). |
Functions
|
Register the built-in device factories with the global registry. |
Package Contents
- class lpf2.devices.basic_motor[source]
Simple DC motor with no encoder (train motor, PF-M motor).
- getDeviceType() int[source]
Reported LPF2 device type (see
lpf2.device_type).
- class lpf2.devices.color_distance_sensor[source]
Boost Color & Distance Sensor (legacy, WeDo/Boost).
- getColorIdx() int[source]
Detected colour as
lpf2.colorindex.
- setLedColor(color: int) None[source]
Set the on-board LED colour (
lpf2.colorindex).
- class lpf2.devices.color_sensor[source]
Technic Color Sensor.
Modes 0/1/5/6 are polled through an internal combo so multiple values (colour, reflectivity, RGB, HSV) can be read without repeated mode switches.
- getColorIdx() int[source]
Detected colour as
lpf2.colorindex.
- setLight(l1: int, l2: int, l3: int) None[source]
Drive the on-board light channels (each 0..100 PCT).
- setMode(modeNum: int, delta: float = 1.0) None[source]
Switch active mode.
delta= change threshold for callbacks (0 = every update).
- MODE_COLOR: int = 0[source]
Detected colour index (
lpf2.color).
- class lpf2.devices.distance_sensor[source]
Technic Distance Sensor (time-of-flight).
- setLight(l1: int, l2: int, l3: int, l4: int) None[source]
Drive the four on-board light segments (each 0..100 PCT).
- class lpf2.devices.encoder_motor[source]
Motor with rotary encoder + position/speed control loops.
- gotoAbsPosition(absPos: int, speed: int = 100, maxPower: int = 100, endState: int = 0, useProfile: int = 0) None[source]
Move to absolute encoder position
absPosatspeedthen applyendState.
- setAccTime(time: int, profile: int) None[source]
Set acceleration ramp time (ms) and profile index.
- setDecTime(time: int, profile: int) None[source]
Set deceleration ramp time (ms) and profile index.
- startPower(pw: int) None[source]
Set motor power (-100..100). Same semantics as
basic_motor.startPower().
- startSpeed(speed: int = 100, maxPower: int = 100, useProfile: int = 0) None[source]
Run continuously at
speed(-100..100), power capped atmaxPower.
- class lpf2.devices.hub_led[source]
RGB LED attached to a hub’s built-in LED port.
- setColorIdx(color: int) None[source]
Set colour by
lpf2.colorindex.