Skip to content

Search the documentation

Kit
Firmware

Names from 2.x to 3.0

Firmware 3.0 gave the Python names a clean-up. Some names changed, a few were removed and a few are new. A robot on 3.0 does not know the 2.x names, and a robot on 2.x does not know the 3.0 names. This page lists every change, kit by kit.

Find the old name in the list for your kit. What comes after the arrow is what to write now. The pages of the reference describe the new names.

Jump to a kit: Smart Car, Mini, Smart Home.

These rules come with the map. They are for anyone changing old code, by hand or with a program.

  1. Apply the root entry first: every mobotROBOTICS. / mobotMINI. becomes robot., every mobotIOT. becomes home..
  2. Then the longer old paths before the shorter ones (an entry for robot.ble.x before the attribute entry robot.ble -> robot.bluetooth).
  3. old and new are written from the root object; [name], (n), (pattern) mark where an argument goes.
  4. new with ' | ' lists the two names a call can become; its rule says which one.
  5. Entries with a rule change their arguments; examples are [old, new] pairs.
  6. Nothing in removed has an alias on 3.0.0; instead is what a program writes now.
  7. internal is for the simulator and the firmware’s own tests: a program does not use those names.

On firmware 2.x, a program for the Smart Car used mobotROBOTICS. On 3.0 it is robot.

  • mobotROBOTICS → robot: an instance of class SmartCar (smart_car.py), bound in __main__ by _boot.py. Every mobotROBOTICS. prefix becomes robot.; the entries below are the members whose own name changes too
  • mobotROBOTICS.ble → robot.bluetooth: the BLEController; every other ble.* member not listed here keeps its name under bluetooth
  • mobotROBOTICS.init() → robot._init(): internal since 3.0.0: the mode runner and the simulator call it, a program does not
  • mobotROBOTICS.cleanup() → robot._cleanup(): internal since 3.0.0: the mode runner and the simulator call it
  • mobotROBOTICS.left_motor.setSpeed → robot.left_motor.set_speed: 0-100, keeps the direction
  • mobotROBOTICS.right_motor.setSpeed → robot.right_motor.set_speed: 0-100, keeps the direction
  • mobotROBOTICS.led1.setState → robot.led1.set: True/False or 1/0, as before
  • mobotROBOTICS.led1.setLedBrightness → robot.led1.set_brightness: the argument was already a percent, 0-100
  • mobotROBOTICS.led2.setState → robot.led2.set: True/False or 1/0, as before
  • mobotROBOTICS.led2.setLedBrightness → robot.led2.set_brightness: the argument was already a percent, 0-100
  • mobotROBOTICS.buzzer.get_current_song() → robot.buzzer.current_song
  • mobotROBOTICS.ble.x → robot.gamepad.x: -128 (left) to 127 (right)
  • mobotROBOTICS.ble.y → robot.gamepad.y: -128 (down) to 127 (up)
  • mobotROBOTICS.ble.changeName → robot.set_name
  • mobotROBOTICS.ble.mobot_name → robot.name
  • mobotROBOTICS.ble.control_mode → robot.mode: 255 = Programmable
  • from BLE import map_range → from mobot import map_range
  • mobotROBOTICS.irs → robot.line_sensor
  • mobotROBOTICS.irs.readAllIRs() → robot.line_sensor.read(): one value per eye, left to right, as before
  • mobotROBOTICS.irs.readSingleIR(n) → robot.line_sensor.read(n)
  • mobotROBOTICS.irs.compIRs(pattern) → robot.line_sensor.matches(pattern)
  • mobotROBOTICS.ultrasonic → robot.distance_sensor
  • mobotROBOTICS.ultrasonic.get_distance_cm() → robot.distance_sensor.distance_cm()
  • mobotROBOTICS.ultrasonic.get_distance_mm() → robot.distance_sensor.distance_mm()
  • mobotROBOTICS.color_sensor.readColor() → robot.color_sensor.read(): (r, g, b, clear) raw counts, as before
  • mobotROBOTICS.color_sensor.printColors() → robot.color_sensor.print_reading()
  • mobotROBOTICS.compass.read() → robot.compass.heading(): degrees, 0 up to 360
  • mobotROBOTICS.compass.angle_error → robot.compass.heading_error
  • mobotROBOTICS.battery_sensor → robot.battery
  • mobotROBOTICS.battery_sensor.read_battery_voltage() → robot.battery.voltage(): volts
  • mobotROBOTICS.joystick1.readX() → robot.joystick1.x(): raw ADC, 0-1023
  • mobotROBOTICS.joystick1.readY() → robot.joystick1.y(): raw ADC, 0-1023
  • mobotROBOTICS.joystick2.readX() → robot.joystick2.x(): raw ADC, 0-1023
  • mobotROBOTICS.joystick2.readY() → robot.joystick2.y(): raw ADC, 0-1023
  • mobotROBOTICS.servo1.move → robot.servo1.set_angle: degrees, 0-180
  • mobotROBOTICS.servo2.move → robot.servo2.set_angle: degrees, 0-180
  • mobotROBOTICS.servo3.move → robot.servo3.set_angle: degrees, 0-180
  • mobotROBOTICS.servo4.move → robot.servo4.set_angle: degrees, 0-180
  • mobotROBOTICS.servos[i].move → robot.servos[i].set_angle
  • mobotROBOTICS.init_servo() → robot.enable_servos()
  • mobotROBOTICS.init_joysticks() → robot.enable_joysticks()

Smart Car: names that change how you call them

Section titled “Smart Car: names that change how you call them”

For these, the arguments change too. Each one comes with its rule, and an example when the map has one.

mobotROBOTICS.left_motor.setDirectionAndSpeed

Section titled “mobotROBOTICS.left_motor.setDirectionAndSpeed”

Write robot.left_motor.forward or robot.left_motor.backward.

setDirectionAndSpeed(d, s) -> robot.left_motor.forward(s) when d == 1 (forward on the Smart Car), else robot.left_motor.backward(s). A d that is not a literal: robot.left_motor.drive(s if d == 1 else -s)

mobotROBOTICS.left_motor.setDirectionAndSpeed(1, 60) # 2.x
robot.left_motor.forward(60) # 3.0
mobotROBOTICS.left_motor.setDirectionAndSpeed(0, 60) # 2.x
robot.left_motor.backward(60) # 3.0

mobotROBOTICS.left_motor.set_direction_and_speed

Section titled “mobotROBOTICS.left_motor.set_direction_and_speed”

Write robot.left_motor.forward or robot.left_motor.backward.

the snake_case twin of setDirectionAndSpeed on the 2.x Smart Car shim: the same rule, forward when d == 1

Write robot.left_motor.forward or robot.left_motor.backward.

setDirection(d) followed by a speed write -> forward(s) / backward(s) with d == 1 meaning forward; setDirection(d) alone (keep the speed, change the way) -> robot.left_motor.forward(abs(robot.left_motor.speed)) when d == 1, else robot.left_motor.backward(abs(robot.left_motor.speed))

Write robot.left_motor.forward or robot.left_motor.backward.

the snake_case twin of setDirection: the same rule, forward when d == 1

Write robot.left_motor.speed.

get_speed() was 0-100 whatever the direction; .speed is signed, -100 to 100 (negative = backward): abs(robot.left_motor.speed) is the old value

Write robot.left_motor.speed.

get_direction() == 1 (forward on the Smart Car) -> robot.left_motor.speed > 0; == 0 -> robot.left_motor.speed < 0. At speed 0 the direction is no longer readable

mobotROBOTICS.right_motor.setDirectionAndSpeed

Section titled “mobotROBOTICS.right_motor.setDirectionAndSpeed”

Write robot.right_motor.forward or robot.right_motor.backward.

setDirectionAndSpeed(d, s) -> robot.right_motor.forward(s) when d == 1 (forward on the Smart Car), else robot.right_motor.backward(s). A d that is not a literal: robot.right_motor.drive(s if d == 1 else -s)

mobotROBOTICS.right_motor.setDirectionAndSpeed(1, 60) # 2.x
robot.right_motor.forward(60) # 3.0
mobotROBOTICS.right_motor.setDirectionAndSpeed(0, 60) # 2.x
robot.right_motor.backward(60) # 3.0

mobotROBOTICS.right_motor.set_direction_and_speed

Section titled “mobotROBOTICS.right_motor.set_direction_and_speed”

Write robot.right_motor.forward or robot.right_motor.backward.

the snake_case twin of setDirectionAndSpeed on the 2.x Smart Car shim: the same rule, forward when d == 1

Write robot.right_motor.forward or robot.right_motor.backward.

setDirection(d) followed by a speed write -> forward(s) / backward(s) with d == 1 meaning forward; setDirection(d) alone (keep the speed, change the way) -> robot.right_motor.forward(abs(robot.right_motor.speed)) when d == 1, else robot.right_motor.backward(abs(robot.right_motor.speed))

Write robot.right_motor.forward or robot.right_motor.backward.

the snake_case twin of setDirection: the same rule, forward when d == 1

Write robot.right_motor.speed.

get_speed() was 0-100 whatever the direction; .speed is signed, -100 to 100 (negative = backward): abs(robot.right_motor.speed) is the old value

Write robot.right_motor.speed.

get_direction() == 1 (forward on the Smart Car) -> robot.right_motor.speed > 0; == 0 -> robot.right_motor.speed < 0. At speed 0 the direction is no longer readable

Write robot.buzzer.play_song.

the default changes from repeating to once: play(x) -> play_song(x, loop=True); play(x, looping=False) -> play_song(x); play(x, looping=v) -> play_song(x, loop=v)

mobotROBOTICS.buzzer.play(SONGS['demo']) # 2.x
robot.buzzer.play_song(SONGS['demo'], loop=True) # 3.0
mobotROBOTICS.buzzer.play(SONGS['demo'], looping=False) # 2.x
robot.buzzer.play_song(SONGS['demo']) # 3.0

Write robot.gamepad.is_pressed(name).

a subscript becomes a call with the same string: ble.isPressed['a'] -> gamepad.is_pressed("a"); names a, b, x, y, up, down, left, right

mobotROBOTICS.ble.isPressed['a'] # 2.x
robot.gamepad.is_pressed("a") # 3.0

Write robot.gamepad.buttons().

the whole dict (not subscripted) -> the call gamepad.buttons(), the same dict

Write robot.bluetooth.is_connected().

always a call now: ble.is_connected (a property in 2.x; ble.is_connected() raised TypeError there) -> bluetooth.is_connected()

Write map_range.

add from mobot import map_range at the top of the program; the arguments and the float result are unchanged

mobotROBOTICS.ble.map_range(x, -128, 127, 0, 100) # 2.x
map_range(x, -128, 127, 0, 100) # 3.0

mobotROBOTICS.ultrasonic.is_object_detected

Section titled “mobotROBOTICS.ultrasonic.is_object_detected”

Write robot.distance_sensor.sees_object.

the keyword threshold_cm= becomes within_cm=; positional calls are unchanged

Write robot.color_sensor.is_color.

the argument order changes: compColor(reading, color, th=t) -> is_color(color, reading, tolerance=t); is_color(color) with no reading measures the sensor itself

mobotROBOTICS.color_sensor.compColor(rgb, (255, 0, 0), th=30) # 2.x
robot.color_sensor.is_color((255, 0, 0), rgb, tolerance=30) # 3.0

Write robot.compass.turn_to.

turn_to_heading(target_deg, base_speed=28, kp=0.8, tol_deg=5, timeout_s=8, L=None, R=None) -> turn_to(heading, speed=28, tolerance=5, timeout_s=8, left=None, right=None): drop L and R when they were the robot’s own motors (the default now), else pass them as left= / right=; kp is fixed at 0.8; base_speed= -> speed=, tol_deg= -> tolerance=

mobotROBOTICS.compass.turn_to_heading(90, L=mobotROBOTICS.left_motor, R=mobotROBOTICS.right_motor) # 2.x
robot.compass.turn_to(90) # 3.0

Write robot.buzzer.set_volume.

the unit changes from the PWM duty (0-65535, loudest 32768, default 2512) to percent (0-100, 100 = duty 32768): set_volume(d) -> set_volume(round(d * 100 / 32768)), capped at 100

mobotROBOTICS.buzzer.set_volume(32768) # 2.x
robot.buzzer.set_volume(100) # 3.0
mobotROBOTICS.buzzer.set_volume(2512) # 2.x
robot.buzzer.set_volume(8) # 3.0

These names have no alias on 3.0. A program that still uses one stops with an error.

  • mobotROBOTICS.ble.enable_activation_gate: inert since 2.1 (Bluetooth is always on); the call did nothing. What to write now: nothing: delete the call
  • mobotROBOTICS.ble.is_activation_gate_enabled: inert since 2.1 (Bluetooth is always on); the call did nothing. What to write now: nothing: delete the call
  • mobotROBOTICS.ble.is_activated: inert since 2.1 (Bluetooth is always on); the call did nothing. What to write now: nothing: delete the call
  • mobotROBOTICS.servo: a second name for servo1. What to write now: robot.servo1
  • mobotROBOTICS.compass.pivot: now private (_pivot). What to write now: robot.compass.turn_to(heading)
  • mobotROBOTICS.compass.halt: now private (_halt). What to write now: robot.left_motor.stop(); robot.right_motor.stop()
  • mobotROBOTICS.compass.save_calibration: now private (calibrate() saves). What to write now: robot.compass.calibrate()
  • mobotROBOTICS.compass.load_calibration: now private (the compass loads it at start-up).
  • mobotROBOTICS.battery_sensor.read_raw: now private (_read_raw). What to write now: robot.battery.voltage()
  • mobotROBOTICS.battery_sensor.read_pin_voltage: now private (_read_pin_voltage). What to write now: robot.battery.voltage()
  • robot.left_motor.drive(speed) / robot.right_motor.drive(speed): -100 to 100, negative = backward
  • robot.gamepad: a read-only view of the app’s Game Pad: x, y, is_pressed(name), buttons()
  • robot.name / robot.set_name(name) / robot.mode: on the root (were ble.mobot_name, ble.changeName, ble.control_mode)
  • from mobot import map_range, sleep_ms: the shared helpers (src/helpers.py, src/mobot/__init__.py)
  • robot.led1.toggle() / robot.led2.toggle(): the Mini had it; now the Smart Car too
  • robot.buzzer.volume: read only, percent (0-100); the default duty 2512 reads 8
Smart Car: names in the firmware source (programs do not use these)

Modules and classes that were renamed.

  • startup → smart_car
  • BLE → ble_service
  • mobot_runner → mode_runner
  • capped_drive → speed_limits: internal: only the built-in modes use it
  • from startup import mobotROBOTICS → from smart_car import robot: only firmware code and tests import it; a program uses the global robot
  • startup.mobotROBOTICS → smart_car.SmartCar
  • motors.Motors → motors.Motor
  • motors.DRV8833_Motor → motors.DRV8833Motor
  • motors.Servos → motors.Servo
  • servo.Servo → servo.ServoDriver
  • indicators.LED → indicators.Led
  • indicators.BuzzerPlayer → indicators.Buzzer
  • indicators.Music → indicators.SongPlayer
  • sensors.IRs → sensors.LineSensor
  • sensors.UltrasonicSensor → sensors.DistanceSensor
  • sensors.Joysticks → sensors.Joystick
  • sensors.BatterySensor → sensors.Battery
  • BLE.GamepadState → ble_service.Gamepad: Gamepad is a new read-only view (robot.gamepad); GamepadState stays as the internal state holder
  • mobot_runner.sleep_ms → mode_runner.sleep_ms: a program writes from mobot import sleep_ms; mode_manager.sleep_ms keeps its name

Removed from the firmware source.

  • BLE.ActivationGate: inert since 2.1.
  • BLEController(activation_pin=...): the inert gate’s button pin; the Smart Car no longer configures GPIO 13 with a pull-up at boot.
  • motors.DRV8833_Motor: the 2.x alias of DRV8833Motor (no aliases). What to write now: motors.DRV8833Motor

Internal names. The simulator and the firmware tests use these. A program does not.

  • BLE.NVS → ble_service.SettingsFile: the settings file (/mobot.json, /mobot_mini.json); keys unchanged
  • BLEController._nvs → BLEController._settings
  • BLEController.isPressed → BLEController.buttons
  • BLEController.changeName() → BLEController.set_name()
  • BLEController.is_connected → BLEController.is_connected(): a method now (was a property)
  • BLEController.map_range → helpers.map_range
  • ModeHooks.R / ModeLink.R → ModeHooks.runner / ModeLink.runner: the mode runner engine
  • capped_drive.CappedDrive(ble, left, right, forward, tag, config_sides_swapped) → speed_limits.SpeedLimitedDrive(ble, left, right, tag, config_sides_swapped): the forward argument is gone: each motor’s forward() knows its kit
  • mode_manager.capped_drive(tag) → mode_manager.speed_limited_drive(tag)
  • mode_manager.FORWARD → (removed): the motors carry it
  • indicators.Music.playingNotes / playingDurations → indicators.SongPlayer.playing_notes / playing_durations
  • indicators.BuzzerPlayer.current_song (attribute) → indicators.Buzzer._current_song (+ property current_song)
  • mobotROBOTICS.init / cleanup / _stop_outputs / _restore_shared / _reset_after_program (staticmethods on the class) → robot._init / _cleanup / _stop_outputs / _restore_shared / _reset_after_program (methods of the instance): the simulator’s shims call these
  • mobotROBOTICS._built → robot._built: an instance attribute now
  • indicators.buzzer_init_freq() / buzzer_pin_number() → indicators._buzzer_init_freq() / _buzzer_pin_number()
  • BLE.IRLineSensorData → ble_service.LineSensorData
  • BLE.UltrasonicData → ble_service.DistanceData
  • sensors.ColorSensor._setTh() → sensors.ColorSensor._set_threshold()
  • mobotROBOTICS._battery_telemetry_loop / start_battery_telemetry (staticmethods) → robot._battery_telemetry_loop / start_battery_telemetry (methods)

On firmware 2.x, a program for the Mini used mobotMINI. On 3.0 it is robot.

  • mobotMINI → robot: an instance of class SmartCarMini (smart_car_mini.py), bound in __main__ by _boot.py. Every mobotMINI. prefix becomes robot.; the entries below are the members whose own name changes too
  • mobotMINI.ble → robot.bluetooth: the BLEController; every other ble.* member not listed here keeps its name under bluetooth
  • mobotMINI.init() → robot._init(): internal since 3.0.0: the mode runner and the simulator call it, a program does not
  • mobotMINI.cleanup() → robot._cleanup(): internal since 3.0.0: the mode runner and the simulator call it
  • mobotMINI.led1.setState → robot.led1.set: True/False or 1/0, as before
  • mobotMINI.led1.setLedBrightness → robot.led1.set_brightness: the argument was already a percent, 0-100
  • mobotMINI.led2.setState → robot.led2.set: True/False or 1/0, as before
  • mobotMINI.led2.setLedBrightness → robot.led2.set_brightness: the argument was already a percent, 0-100
  • mobotMINI.buzzer.get_current_song() → robot.buzzer.current_song
  • mobotMINI.ble.x → robot.gamepad.x: -128 (left) to 127 (right)
  • mobotMINI.ble.y → robot.gamepad.y: -128 (down) to 127 (up)
  • mobotMINI.ble.changeName → robot.set_name
  • mobotMINI.ble.mobot_name → robot.name
  • mobotMINI.ble.control_mode → robot.mode: 255 = Programmable
  • mobotMINI.rgb → robot.rgb_led: the same name as the Smart Home’s; colours 0-255 as before
  • mobotMINI.rgb.get_brightness() → robot.rgb_led.brightness
  • mobotMINI.rgb.start_flash → robot.rgb_led.blink: (r, g, b), call tick() in the loop, as before
  • mobotMINI.rgb.start_rainbow() → robot.rgb_led.rainbow()
  • mobotMINI.rgb.flash(r, g, b, duration_ms=50) → robot.rgb_led.flash(r, g, b, duration_ms=50): the blocking one-shot flash, as before: every LED shows the colour (0-255 each, at the current brightness) for duration_ms, then gets back the colour it had; a running blink() or rainbow() goes on
  • mobotMINI.ultrasonic → robot.distance_sensor: a DistanceSensor now (it was the raw HCSR04): a failed reading is -1 instead of an exception
  • mobotMINI.initUltrasonic() → robot.enable_distance_sensor()
  • mobotMINI.initIRs() → robot.enable_line_sensor()

For these, the arguments change too. Each one comes with its rule, and an example when the map has one.

mobotMINI.left_motor.set_direction_and_speed

Section titled “mobotMINI.left_motor.set_direction_and_speed”

Write robot.left_motor.forward or robot.left_motor.backward.

set_direction_and_speed(d, s) -> robot.left_motor.forward(s) when d == 0 (forward on the Mini), else robot.left_motor.backward(s). A d that is not a literal: robot.left_motor.drive(s if d == 0 else -s)

mobotMINI.left_motor.set_direction_and_speed(0, 60) # 2.x
robot.left_motor.forward(60) # 3.0
mobotMINI.left_motor.set_direction_and_speed(1, 60) # 2.x
robot.left_motor.backward(60) # 3.0

Write robot.left_motor.forward or robot.left_motor.backward.

set_direction(d) followed by a speed write -> forward(s) / backward(s) with d == 0 meaning forward; set_direction(d) alone (keep the speed, change the way) -> robot.left_motor.forward(abs(robot.left_motor.speed)) when d == 0, else robot.left_motor.backward(abs(robot.left_motor.speed))

Write robot.left_motor.speed.

get_speed() was 0-100 whatever the direction; .speed is signed, -100 to 100 (negative = backward): abs(robot.left_motor.speed) is the old value

Write robot.left_motor.speed.

get_direction() == 0 (forward on the Mini) -> robot.left_motor.speed > 0; == 1 -> robot.left_motor.speed < 0. At speed 0 the direction is no longer readable

mobotMINI.right_motor.set_direction_and_speed

Section titled “mobotMINI.right_motor.set_direction_and_speed”

Write robot.right_motor.forward or robot.right_motor.backward.

set_direction_and_speed(d, s) -> robot.right_motor.forward(s) when d == 0 (forward on the Mini), else robot.right_motor.backward(s). A d that is not a literal: robot.right_motor.drive(s if d == 0 else -s)

mobotMINI.right_motor.set_direction_and_speed(0, 60) # 2.x
robot.right_motor.forward(60) # 3.0
mobotMINI.right_motor.set_direction_and_speed(1, 60) # 2.x
robot.right_motor.backward(60) # 3.0

Write robot.right_motor.forward or robot.right_motor.backward.

set_direction(d) followed by a speed write -> forward(s) / backward(s) with d == 0 meaning forward; set_direction(d) alone (keep the speed, change the way) -> robot.right_motor.forward(abs(robot.right_motor.speed)) when d == 0, else robot.right_motor.backward(abs(robot.right_motor.speed))

Write robot.right_motor.speed.

get_speed() was 0-100 whatever the direction; .speed is signed, -100 to 100 (negative = backward): abs(robot.right_motor.speed) is the old value

Write robot.right_motor.speed.

get_direction() == 0 (forward on the Mini) -> robot.right_motor.speed > 0; == 1 -> robot.right_motor.speed < 0. At speed 0 the direction is no longer readable

Write robot.buzzer.play_song.

the default changes from repeating to once: play(x) -> play_song(x, loop=True); play(x, looping=False) -> play_song(x); play(x, looping=v) -> play_song(x, loop=v)

mobotMINI.buzzer.play(SONGS['demo']) # 2.x
robot.buzzer.play_song(SONGS['demo'], loop=True) # 3.0
mobotMINI.buzzer.play(SONGS['demo'], looping=False) # 2.x
robot.buzzer.play_song(SONGS['demo']) # 3.0

Write robot.gamepad.is_pressed(name).

a subscript becomes a call with the same string: ble.isPressed['a'] -> gamepad.is_pressed("a"); names a, b, x, y, up, down, left, right

mobotMINI.ble.isPressed['a'] # 2.x
robot.gamepad.is_pressed("a") # 3.0

Write robot.gamepad.buttons().

the whole dict (not subscripted) -> the call gamepad.buttons(), the same dict

Write robot.bluetooth.is_connected().

always a call now: ble.is_connected (a property in 2.x; ble.is_connected() raised TypeError there) -> bluetooth.is_connected()

Write map_range.

add from mobot import map_range at the top of the program; the arguments and the float result are unchanged

mobotMINI.ble.map_range(x, -128, 127, 0, 100) # 2.x
map_range(x, -128, 127, 0, 100) # 3.0

Write robot.rgb_led.color.

get_color(index) for a chained LED other than 0 has no 3.0 form (the kit has one LED)

Write robot.line_sensor.read(0).

eye 0 is the left one

Write robot.line_sensor.read(1).

eye 1 is the right one

Write robot.line_sensor.

[left_ir.value(), right_ir.value()] -> line_sensor.read()

Write robot.line_sensor.

see left_ir

Write robot.buzzer.set_volume.

the unit changes from the PWM duty (0-65535, loudest 32768, default 2512) to percent (0-100, 100 = duty 32768): set_volume(d) -> set_volume(round(d * 100 / 32768)), capped at 100

mobotMINI.buzzer.set_volume(32768) # 2.x
robot.buzzer.set_volume(100) # 3.0
mobotMINI.buzzer.set_volume(2512) # 2.x
robot.buzzer.set_volume(8) # 3.0

These names have no alias on 3.0. A program that still uses one stops with an error.

  • mobotMINI.ble.enable_activation_gate: inert since 2.1 (Bluetooth is always on); the call did nothing. What to write now: nothing: delete the call
  • mobotMINI.ble.is_activation_gate_enabled: inert since 2.1 (Bluetooth is always on); the call did nothing. What to write now: nothing: delete the call
  • mobotMINI.ble.is_activated: inert since 2.1 (Bluetooth is always on); the call did nothing. What to write now: nothing: delete the call
  • mobotMINI.left_motor.FORWARD / REVERSE: raw direction numbers (D4: no direction numbers). What to write now: forward() / backward()
  • robot.left_motor.drive(speed) / robot.right_motor.drive(speed): -100 to 100, negative = backward
  • robot.gamepad: a read-only view of the app’s Game Pad: x, y, is_pressed(name), buttons()
  • robot.name / robot.set_name(name) / robot.mode: on the root (were ble.mobot_name, ble.changeName, ble.control_mode)
  • from mobot import map_range, sleep_ms: the shared helpers (src/helpers.py, src/mobot/__init__.py)
  • robot.line_sensor: a LineSensor over the Mini’s two IR eyes (GPIO 26 left, 27 right): read(), read(i), matches()
  • robot.distance_sensor.sees_object(within_cm=10): as on the Smart Car
  • robot.buzzer.volume: read only, percent (0-100); the default duty 2512 reads 8
Mini: names in the firmware source (programs do not use these)

Modules and classes that were renamed.

  • startup → smart_car_mini
  • BLE → ble_service
  • mobot_runner → mode_runner
  • capped_drive → speed_limits: internal: only the built-in modes use it
  • from startup import mobotMINI → from smart_car_mini import robot: only firmware code and tests import it; a program uses the global robot
  • startup.mobotMINI → smart_car_mini.SmartCarMini
  • motors.DRV8833_Motor → motors.DRV8833Motor
  • indicators.LED → indicators.Led
  • indicators.BuzzerPlayer → indicators.Buzzer
  • indicators.Music → indicators.SongPlayer
  • rgb_led.RGB_LED → rgb_led.RGBLed
  • BLE.GamepadState → ble_service.Gamepad: Gamepad is a new read-only view (robot.gamepad); GamepadState stays as the internal state holder
  • mobot_runner.sleep_ms → mode_runner.sleep_ms: a program writes from mobot import sleep_ms; mode_manager.sleep_ms keeps its name

Removed from the firmware source.

  • BLE.ActivationGate: inert since 2.1.
  • BLEController(activation_pin=...): the inert gate’s button pin; the Smart Car no longer configures GPIO 13 with a pull-up at boot.

Internal names. The simulator and the firmware tests use these. A program does not.

  • BLE.NVS → ble_service.SettingsFile: the settings file (/mobot.json, /mobot_mini.json); keys unchanged
  • BLEController._nvs → BLEController._settings
  • BLEController.isPressed → BLEController.buttons
  • BLEController.changeName() → BLEController.set_name()
  • BLEController.is_connected → BLEController.is_connected(): a method now (was a property)
  • BLEController.map_range → helpers.map_range
  • ModeHooks.R / ModeLink.R → ModeHooks.runner / ModeLink.runner: the mode runner engine
  • capped_drive.CappedDrive(ble, left, right, forward, tag, config_sides_swapped) → speed_limits.SpeedLimitedDrive(ble, left, right, tag, config_sides_swapped): the forward argument is gone: each motor’s forward() knows its kit
  • mode_manager.capped_drive(tag) → mode_manager.speed_limited_drive(tag)
  • mode_manager.FORWARD → (removed): the motors carry it
  • indicators.Music.playingNotes / playingDurations → indicators.SongPlayer.playing_notes / playing_durations
  • indicators.BuzzerPlayer.current_song (attribute) → indicators.Buzzer._current_song (+ property current_song)
  • mobotMINI.init / cleanup / _stop_outputs / _restore_shared / _reset_after_program (staticmethods on the class) → robot._init / _cleanup / _stop_outputs / _restore_shared / _reset_after_program (methods of the instance): the simulator’s shims call these
  • mobotMINI._built → robot._built: an instance attribute now

On firmware 2.x, a program for the Smart Home used mobotIOT. On 3.0 it is home.

  • mobotIOT → home: an instance of class SmartHome (smart_home.py), bound in __main__ by _boot.py. Every mobotIOT. prefix becomes home.; the entries below are the members whose own name changes too
  • mobotIOT.dht11 → home.temperature_sensor
  • mobotIOT.pir → home.motion_sensor
  • mobotIOT.mq135 → home.gas_sensor
  • mobotIOT.ldr → home.light_sensor
  • mobotIOT.pot → home.knob
  • mobotIOT.oled → home.display
  • mobotIOT.seg → home.number_display
  • mobotIOT.server → home.dashboard
  • mobotIOT.mq135.read() → home.gas_sensor.level(): raw 0-4095, as before
  • mobotIOT.ldr.read() → home.light_sensor.level(): raw 0-4095, as before
  • mobotIOT.pot.read() → home.knob.position(): raw 0-4095, as before
  • mobotIOT.battery.read() → home.battery.voltage(): volts, two decimals
  • mobotIOT.rfid.read() → home.rfid.read_card()
  • mobotIOT.led1.write_percent → home.led1.set_brightness: percent, 0-100
  • mobotIOT.led2.write_percent → home.led2.set_brightness: percent, 0-100
  • mobotIOT.seg.number → home.number_display.show_number
  • mobotIOT.seg.show_number → home.number_display.show_number: (n, dots=None): dots is a list of three True/False
  • mobotIOT.seg.set_segments_for_digit → home.number_display.set_digit
  • mobotIOT.init_seg() → home.enable_number_display()
  • mobotIOT.buzzer.play_sound → home.buzzer.play_tone: (frequency Hz, duration ms)
  • mobotIOT.buzzer.play_sequence → home.buzzer.play_notes
  • mobotIOT.buzzer.is_busy() → home.buzzer.is_playing()
  • mobotIOT.servo.get_angle() → home.servo.angle
  • mobotIOT.servo.min() → home.servo.move_to_min()
  • mobotIOT.servo.max() → home.servo.move_to_max()
  • mobotIOT.fan.get_speed() → home.fan.speed
  • mobotIOT.oled.display_text → home.display.show_text
  • mobotIOT.oled.clear_screen() → home.display.clear()
  • mobotIOT.oled.display_frame → home.display.show_frame
  • mobotIOT.wifi.connected() → home.wifi.is_connected()
  • mobotIOT.server.start_web_server → home.dashboard.start
  • mobotIOT.server.stop_web_server → home.dashboard.stop
  • mobotIOT.server.register_toggle → home.dashboard.add_switch: returns the control’s number, as before
  • mobotIOT.server.register_slider → home.dashboard.add_slider: returns the control’s number
  • mobotIOT.server.register_rgb → home.dashboard.add_color: returns the control’s number
  • mobotIOT.server.register_text → home.dashboard.add_text: returns the control’s number
  • mobotIOT.server.get_toggle → home.dashboard.switch: takes the number add_switch() returned, as before
  • mobotIOT.server.get_slider → home.dashboard.slider: takes the number add_slider() returned
  • mobotIOT.server.get_rgb → home.dashboard.color: takes the number add_color() returned
  • mobotIOT.server.get_text → home.dashboard.text: takes the number add_text() returned
  • mobotIOT.server.get_server_ip → home.dashboard.ip
  • mobotIOT.server.is_server_running → home.dashboard.is_running

Smart Home: names that change how you call them

Section titled “Smart Home: names that change how you call them”

For these, the arguments change too. Each one comes with its rule, and an example when the map has one.

Write home.temperature_sensor.temperature or home.temperature_sensor.humidity.

read(0) -> temperature(), read(1) -> humidity(); a mode that is not a literal: (temperature() if m == 0 else humidity())

mobotIOT.dht11.read(0) # 2.x
home.temperature_sensor.temperature() # 3.0
mobotIOT.dht11.read(1) # 2.x
home.temperature_sensor.humidity() # 3.0

Write home.rgb_led.set_color.

percent becomes 0-255: write(r, g, b) -> set_color(round(r * 255 / 100), round(g * 255 / 100), round(b * 255 / 100)); a literal 100 is 255, 50 is 128

mobotIOT.rgb_led.write(100, 50, 0) # 2.x
home.rgb_led.set_color(255, 128, 0) # 3.0

Write from mobot import map_range.

map(x, a, b, c, d) -> int(map_range(x, a, b, c, d)): utils.map floored an integer division, map_range returns a float; the int() keeps the old value whenever it is not negative

These names have no alias on 3.0. A program that still uses one stops with an error.

  • mobotIOT.rgb_led.write: hidden as _write(), still in percent, for the firmware’s own callers. What to write now: home.rgb_led.set_color(r, g, b), 0-255
  • mobotIOT.seg.show: a TM1637 driver method that was reachable through seg; home.number_display offers show_number() and set_digit(). What to write now: home.number_display.show_number(n)
  • mobotIOT.seg.float: a TM1637 driver method that was reachable through seg; home.number_display offers show_number() and set_digit(). What to write now: home.number_display.show_number(n)
  • mobotIOT.seg.raw: a TM1637 driver method that was reachable through seg; home.number_display offers show_number() and set_digit(). What to write now: home.number_display.set_digit(index, segments)
  • home.rgb_led.set_color(r, g, b): 0-255
  • home.number_display.show_number(n, dots=None): dots: a list of three True/False, now on the TM1637
  • home.number_display.show_text(text): up to 3 characters, right-aligned like show_number, "" blanks it: 0-9, '-', space and the letters A b C d E F H L P in either case ('B' draws b, 'a' draws A; b and d always look small); any other character, or more than 3, raises ValueError naming what works, and the display keeps what it showed
  • from mobot import map_range, sleep_ms: the shared helpers (sleep_ms is time.sleep_ms on the Smart Home)
Smart Home: names in the firmware source (programs do not use these)

Modules and classes that were renamed.

  • iot_startup → smart_home
  • server → dashboard
  • TM1637 → tm1637
  • utils → helpers: helpers.py is shared by all four boards (src/ root); a program imports from mobot instead: from mobot import map_range
  • iot_startup.mobotIOT → smart_home.SmartHome
  • sensors.DHT11 → sensors.TemperatureSensor
  • sensors.PIRSensor → sensors.MotionSensor
  • sensors.MQ135 → sensors.GasSensor
  • sensors.LDR → sensors.LightSensor
  • sensors.Potentiometer → sensors.Knob
  • sensors.RFID → sensors.RFIDReader
  • displays.OLEDWrapper → displays.Display
  • displays.SimpleLed → displays.Led
  • TM1637.TM1637_CA → tm1637.TM1637CommonAnode
  • actuators.ServoWrapper → actuators.Servo
  • servo.Servo → servo.ServoDriver
  • server.ConfigurableServer → dashboard.Dashboard
  • displays.SevenSegment3Digit → displays.NumberDisplay: NumberDisplay drives the house’s TM1637 (TM1637CommonAnode); the GPIO-multiplexing SevenSegment3Digit, which the kit never built, is gone

Removed from the firmware source.

  • utils.hello: a test leftover.
  • displays.SevenSegment3Digit(segment_pins, digit_pins): a GPIO-multiplexed 3-digit driver the house never built; NumberDisplay drives the TM1637. What to write now: home.number_display

Internal names. The simulator and the firmware tests use these. A program does not.

  • sensors._ArbitratedADC.read() → sensors._ArbitratedADC._read()
  • sounds.Buzzer.is_playing (attribute) → sounds.Buzzer._playing: freed the name for the method is_playing()
  • displays.RGBLed.write() → displays.RGBLed._write(): percent; Improv, the boot colours and /api/act/rgb use it
  • the TM1637 driver behind seg → home.number_display._driver: the monitors engine uses raw(), float(), number() through it
  • server.server (the instance) → dashboard.server
  • the Bluetooth GATT contract (UUIDs, frames, event types)
  • the Smart Home HTTP routes and their JSON, and the Improv protocol
  • the settings files and their keys (/mobot.json, /mobot_mini.json, compass_cal.json, mobot_mini_sequence.bin)
  • the mode ids, the serial markers (MOBOT-MODE…), boot.py / main.py / _boot.py
  • mode_manager (module and resume()), BLEController.set_control_mode(), ColorSensor, Compass, Fan, Button, the chip drivers
  • home.dashboard.update_* and set_ssid_password, home.wifi.ip/house_id/networks/forget/hostname