sciro.pump

sciro.pump – PUMP devices on the PeakHub, the PUMP counterpart of pybricks.pupdevices: the generic PUMPDevice plus one class per device (currently the LP-FloorPro line sensor).

Stub for the frozen module of the same name. Every reading method returns the value directly, or an awaitable under multitasking.

FloorPro

class sciro.pump.FloorPro(port: Port)

LP-FloorPro connected to a PeakHub port, speaking PUMP.

dev: PUMPDevice

The underlying generic device.

serial: str

The device’s 8-character short ID.

line: Line
ir_raw: IRRaw
ir_calib: IRCalib
pixels: Pixels

The strip picture stream; None with firmware that lacks it.

color_sensor(ext_port=1) → ColorSensor

The TCS3400 on extension port 1 or 2; raises OSError if none.

gyro(ext_port=2) → Gyro  -- the gyro on extension port 1 or 2; raises ``OSError`` if none.
imu(ext_port=2) → Gyro  -- alias of :meth:`gyro`.
all_sensor_data() → Tuple  -- the same as ``line.read()``.
dark_centroid() → float  -- see :meth:`Line.dark_centroid`.
bright_centroid() → float  -- see :meth:`Line.bright_centroid`.
brightness() → float  -- overall brightness 0 .. 1.
darkness() → float  -- overall darkness 0 .. 1.
line_sensors_binary() → Tuple[bool, ...]  -- 15 flags, True = bright.
line_sensors_analog() → Tuple[int, ...]  -- 15 raw ADC counts

(0 .. 4095), sensor 0 first; one ir_raw frame on demand.

streams() → Tuple  -- the enumerated streams ``(id, url, ext_port, state_len)``.

Streams

class sciro.pump.Line

IR array derived data (default: every sample, 400 Hz).

read() → Tuple

Returns (cog_dark, cog_bright, brightness, darkness, mask, calibrating): center of gravity of the dark / bright pixels in sensor pitches from the middle sensor (-7 .. +7), overall brightness / darkness (0 .. 1), a 15-bit bright-pixel mask (bit i = sensor i), and whether calibration is active.

dark_centroid() → float  -- center of gravity of the dark pixels, in

sensor pitches from the middle sensor (-7 .. +7).

bright_centroid() → float  -- center of gravity of the bright pixels (-7 .. +7).
brightness() → float  -- overall brightness 0 .. 1.
darkness() → float  -- overall darkness 0 .. 1.
line_sensors_binary() → Tuple[bool, ...]  -- 15 flags, sensor 0 first,

True where the sensor sees bright.

calibrating() → bool  -- True while the min-max calibration runs.
calibrate(enable: bool = True) → MaybeAwaitable

calibrate(enable=True) – start/stop min-max calibration of the array.

state() → bytes | None  -- the stream's current state prefix.
subscribe(mode: int, rate: int = 0) → MaybeAwaitable

subscribe(mode, rate=0) – rate in Hz, 0 = every sample; see PUMPDevice.subscribe().

dev: PUMPDevice
id: int
class sciro.pump.IRRaw

15 raw 12-bit ADC readings. Off by default: use oneshot() or subscribe.

read() → Tuple[int, ...]  -- 15 values, 0 .. 4095, sensor 0 first.
oneshot() → Tuple[int, ...]  -- request one frame and return it.
state() → bytes | None  -- the stream's current state prefix.
subscribe(mode: int, rate: int = 0) → MaybeAwaitable

subscribe(mode, rate=0) – rate in Hz, 0 = every sample; see PUMPDevice.subscribe().

dev: PUMPDevice
id: int
class sciro.pump.IRCalib

Calibration table of the IR array. Off by default.

read() → Tuple

Returns (min, max, min_visited_mask, max_visited_mask) with min and max tuples of 15 raw counts.

oneshot() → Tuple  -- request the table once and return it.
state() → bytes | None  -- the stream's current state prefix.
subscribe(mode: int, rate: int = 0) → MaybeAwaitable

subscribe(mode, rate=0) – rate in Hz, 0 = every sample; see PUMPDevice.subscribe().

dev: PUMPDevice
id: int
class sciro.pump.Pixels

The sensor’s own LED strip picture, rendered on the device at full scale: 18 (r, g, b) triplets = IR channels 0..14, EXT1, EXT2, battery. Off by default. A PeakHub mirrors it on its 5x5 matrix with sciro.hubs.LightMatrix.device().

read() → Tuple[Tuple[int, int, int], ...]  -- 18 RGB triplets, 0 .. 255.
oneshot() → Tuple  -- request one frame and return it.
state() → bytes | None  -- the stream's current state prefix.
subscribe(mode: int, rate: int = 0) → MaybeAwaitable

subscribe(mode, rate=0) – rate in Hz, 0 = every sample; see PUMPDevice.subscribe().

dev: PUMPDevice
id: int

Extension-port devices

class sciro.pump.ColorSensor(port: Port | PUMPDevice, ext_port: int = 1)

TCS3400 color sensor on an extension port of a PUMP device.

ColorSensor(port, ext_port) opens it directly; FloorPro.color_sensor() returns the same class. hsv() and color() follow pybricks.pupdevices.ColorSensor.

Every sample is tagged with the settings it was measured under, so a read after a settings change waits for the first sample taken with the new settings.

ext_port: int
read() → Tuple[int, int, int, int, int]  -- raw (red, green, blue, clear, status) at device resolution.
calibrated() → Tuple[int, int, int]

Red, green, blue 0 .. 255 as the device itself shows them: stretched over the calibrated range when a valid calibration applies, scaled to full scale otherwise.

hsv() → Color

Hue (0 .. 359), saturation (0 .. 100) and value (0 .. 100) of the surface, as a Color: standard HSV of the calibrated color when a valid calibration applies, of the raw reading otherwise.

calibration_status() → str

"none" (nothing stored), "weak" (stored but not applicable: incomplete, or LED / gain / integration differ from the calibration profile), "ok" (applied), or "calibrating".

calibrate(enable=True)

Start or stop the range calibration on the device. While it runs, move the sensor over the darkest and brightest surfaces (or elements) it will see; stopping stores the table on the sensor, bound to the LED, gain and integration time in force. Changing those meanwhile aborts it.

clear_calibration() → MaybeAwaitable

clear_calibration() – drop the stored calibration (back to full-scale color).

calibration() → Tuple

The stored table: (min, max, (led, gain, atime), valid, applicable, visited_mask) with min/max tuples of four counts (red, green, blue, clear). Fetched from the device on demand.

color() → Color

The nearest of the detectable colors (default: red, yellow, green, blue, white, none), matched like pybricks.pupdevices.ColorSensor.

detectable_colors(colors: Iterable[Color] | None = None) → Tuple[Color, ...] | None

detectable_colors(colors) – set the colors color() chooses from; with no argument, get them.

settings() → Tuple[int, int, int]  -- (led_percent, gain_x, atime) in effect.
set_light(percent: int) → MaybeAwaitable

set_light(percent) – illumination LED duty, 0 .. 100.

set_gain(gain_x: int) → MaybeAwaitable

set_gain(gain_x) – analog gain: 1, 4, 16 or 64.

set_integration(atime: int) → MaybeAwaitable

set_integration(atime) – TCS3400 ATIME register 0 .. 255: (256 - atime) * 2.78 ms.

state() → bytes | None  -- the stream's current state prefix.
subscribe(mode: int, rate: int = 0) → MaybeAwaitable

subscribe(mode, rate=0) – rate in Hz, 0 = every sample; see PUMPDevice.subscribe().

dev: PUMPDevice
id: int
SR Gyro EXT v1.1

The Gyro (BNO086) on its extension board.

class sciro.pump.Gyro(port: Port | PUMPDevice, ext_port: int = 2)

Gyro (BNO086) on an extension port of a PUMP device: roll, pitch, yaw in degrees.

Gyro(port, ext_port) opens it directly; FloorPro.gyro() returns the same class (IMU is an alias). The heading offset lives on the hub: reset_heading() makes the current yaw read as the given angle.

ext_port: int
read() → Tuple  -- (roll, pitch, yaw, status), degrees; yaw includes the offset.
heading() → float  -- yaw in degrees (-180 .. 180], with the offset applied.
reset_heading(angle: float = 0) → MaybeAwaitable

reset_heading(angle=0) – make the current heading read as angle.

state() → bytes | None  -- the stream's current state prefix.
subscribe(mode: int, rate: int = 0) → MaybeAwaitable

subscribe(mode, rate=0) – rate in Hz, 0 = every sample; see PUMPDevice.subscribe().

dev: PUMPDevice
id: int
sciro.pump.IMU = <class 'sciro.pump.Gyro'>

Alias of Gyro.