Skip to main content

Function Documentation

version 2.92

MPU

calibrate_gyro()

Description

Reads from the previous MPU offsets file unless the file does not exist. If an offsets file does not exist, then it will create an offsets file by taking the average of multiple readings from the sensor. While running this function, make sure Zumi is not moving and is resting on a flat surface. This function calls zumi.mpu.calibrate_MPU().

Syntax

calibrate_gyro()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.forward(40,2.0)
time.sleep(2)
zumi.calibrate_gyro()
time.sleep(2)
zumi.forward(40,2.0)

print("Done")

calibrate_MPU()

Description

Reads from the previous MPU offsets file unless the file does not exist. If an offsets file does not exist, then it will create an offsets file by taking the average of multiple readings from the sensor. While running this function, make sure Zumi is not moving and is resting on a flat surface.

Syntax

calibrate_MPU()
calibrate_MPU(count=100)

Parameters

integer count: the number of samples you want Zumi to take. Increase to improve accuracy.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
zumi = Zumi()

#Zumi will take 500 samples/readings
zumi.mpu.calibrate_MPU(count=500)

#this is the order the offsets will be printed
print("angular speed rad/sec Gx,Gy,Gz")
print("linear acceleration Ax,Ay,Az")

#print the offsets of each Axis
zumi.mpu.print_offsets()


get_orientation()

Description

Uses the acceleration values to find Zumi's orientation with respect to the strongest force being applied to Zumi (gravity).

Syntax

get_orientation()

Parameters

None

Returns

integer Orientation state:
-1 = unknown
0 = probably falling or moving between states
1 = camera straight up
2 = camera facing down
3 = on right side
4 = on left side
5 = wheels on floor
6 = wheels facing up (upside down)
7 = accelerating faster than 1g

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

#grab zumi and place it on any side
#example: upside down, on its nose etc.
for i in range(20):
orientation = zumi.get_orientation()
print(orientation)
time.sleep(0.5)
print(" done ")


read_x_angle()

Description

Calls update_angles() and returns only the x-angle.

Syntax

read_x_angle()

Parameters

None

Returns

float x-angle: The current x-angle of the Zumi

Example Code

#Python code
from zumi.zumi import Zumi
import IPython.display

zumi = Zumi()

for i in range(100):
print(zumi.read_x_angle())
IPython.display.clear_output(wait=True)
print("done")


read_y_angle()

Description

Calls update_angles() and returns only the y-angle.

Syntax

read_y_angle()

Parameters

None

Returns

float y-angle: The current y-angle of the Zumi

Example Code

#Python code
from zumi.zumi import Zumi
import IPython.display

zumi = Zumi()

for i in range(100):
print(zumi.read_y_angle())
IPython.display.clear_output(wait=True)
print("done")


read_z_angle()

Description

Calls update_angles() and returns only the z-angle.

Syntax

read_z_angle()

Parameters

None

Returns

float z-angle: The current z-angle of the Zumi

Example Code

#Python code
from zumi.zumi import Zumi
import IPython.display

zumi = Zumi()

for i in range(100):
print(zumi.read_z_angle())
IPython.display.clear_output(wait=True)
print("done")


reset_drive()

Description

Calls both reset_PID() and reset_gyro().

Syntax

reset_drive()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,50):
zumi.forward_step(0,50)

print(zumi.angle_list[2],", ", zumi.error_past)

zumi.stop()
zumi.reset_drive()

print(" Now ")
print(zumi.angle_list[2],", ", zumi.error_past)



reset_gyro()

Description

Resets all values in the angle list to 0. Use for driving straight or turning accurately.

Syntax

reset_gyro()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
zumi = Zumi()

print("z angle " , zumi.angle_list[2])

zumi.turn_left(90,1.2)

print("z angle " , zumi.angle_list[2])

zumi.reset_gyro()

print("z angle " , zumi.angle_list[2])

reset_PID()

Description

Resets the sum of the gyro error to zero as well as the PID error sum. Use for driving straight or turning accurately. This does not reset the P, I, and D values of the Zumi PID control.

Syntax

reset_PID()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
zumi = Zumi()

for i in range(0,50):
zumi.go_straight(50,0)
# print the error of the z angle along with some of the PID accumulators
print(zumi.PID_time_past,", ", zumi.error_past,", ", zumi.error_sum," , ", zumi.angle_list[2])

zumi.stop()
# this will reset those values
zumi.reset_PID()

print(" Now ")
print(zumi.PID_time_past,", ", zumi.error_past,", ", zumi.error_sum, " , ", zumi.angle_list[2])


update_angles()

Description

Reads angular speeds and updates the list of angles: The first 3 are angles produced from the gyroscope readings.
X angle, Y angle and Z angle in degrees.
The next 2 angles are produced by finding the tilt with respect to gravity.
X and Y acceleration angles in degrees. Work well if Zumi's wheels point to the floor
The next 2 angles are the complementary filtered angles are produced by combining both gyroscope and accelerometer angles for the x and y axis.
The next 3 are the rotation angles which are produced using the accelerometer.
rotation along X, Y and Z with respect to gravity.
The last one is the tilt state.

Syntax

update_angles()

Parameters

None

Returns

list angles: The updated list of angles in the following format, [Gyro x,Gyro y,Gyro z,Acc x,Acc y,Comp x,Comp y,Rot_x,Rot_y,Rot_z,tilt_state]

Example Code

#Python code
from zumi.zumi import Zumi
import time
zumi = Zumi()


for i in range(0,100):
angles = zumi.update_angles()
z_angle = angles[2]
print(z_angle)
print(" done ")


Sensors

back_left_detect()

Description

Returns True if the back left IR sensor detects a value below a threshold. The value decreases as the light reflected back to the receiver increases.

Syntax

back_left_detect()
back_left_detect(threshold=100)

Parameters

integer threshold: Threshold value (0 - 255) of the back left IR sensor

Returns

boolean detected: Returns True if sensor is triggered.

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,100):
if zumi.back_left_detect():
print("Detected!")
time.sleep(0.1) # Delay for I2C


back_right_detect()

Description

Returns True if the back right IR sensor detects a value below a threshold. The value decreases as the light reflected back to the receiver increases.

Syntax

back_right_detect()
back_right_detect(threshold=100)

Parameters

integer threshold: Threshold value (0 - 255) of the back right IR sensor

Returns

boolean detected: Returns True if sensor is triggered.

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,100):
if zumi.back_right_detect():
print("Detected!")
time.sleep(0.1) # Delay for I2C


bottom_left_detect()

Description

Returns True if the bottom left IR sensor detects a value below a threshold. The value decreases as the light reflected back to the receiver increases.

Syntax

bottom_left_detect()
bottom_left_detect(threshold=100)

Parameters

integer threshold: Threshold value (0 - 255) of the bottom left IR sensor

Returns

boolean detected: Returns True if sensor is triggered.

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,100):
if zumi.bottom_left_detect():
print("Detected!")
time.sleep(0.1) # Delay for I2C


bottom_right_detect()

Description

Returns True if the bottom right IR sensor detects a value below a threshold. The value decreases as the light reflected back to the receiver increases.

Syntax

bottom_right_detect()
bottom_right_detect(threshold=100)

Parameters

integer threshold: Threshold value (0 - 255) of the bottom right IR sensor

Returns

boolean detected: Returns True if sensor is triggered.

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,100):
if zumi.bottom_right_detect():
print("Detected!")
time.sleep(0.1) # Delay for I2C


calibrate_gyro()

Description

Reads from the previous MPU offsets file unless the file does not exist. If an offsets file does not exist, then it will create an offsets file by taking the average of multiple readings from the sensor. While running this function, make sure Zumi is not moving and is resting on a flat surface. This function calls zumi.mpu.calibrate_MPU().

Syntax

calibrate_gyro()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.forward(40,2.0)
time.sleep(2)
zumi.calibrate_gyro()
time.sleep(2)
zumi.forward(40,2.0)

print("Done")

calibrate_MPU()

Description

Reads from the previous MPU offsets file unless the file does not exist. If an offsets file does not exist, then it will create an offsets file by taking the average of multiple readings from the sensor. While running this function, make sure Zumi is not moving and is resting on a flat surface.

Syntax

calibrate_MPU()
calibrate_MPU(count=100)

Parameters

integer count: the number of samples you want Zumi to take. Increase to improve accuracy.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
zumi = Zumi()

#Zumi will take 500 samples/readings
zumi.mpu.calibrate_MPU(count=500)

#this is the order the offsets will be printed
print("angular speed rad/sec Gx,Gy,Gz")
print("linear acceleration Ax,Ay,Az")

#print the offsets of each Axis
zumi.mpu.print_offsets()


front_left_detect()

Description

Returns True if the front left IR sensor detects a value below a threshold. The value decreases as the light reflected back to the receiver increases.

Syntax

front_left_detect()
front_left_detect(threshold=100)

Parameters

integer threshold: Threshold value (0 - 255) of the front left IR sensor

Returns

boolean detected: Returns True if sensor is triggered.

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,100):
if zumi.front_left_detect():
print("Detected!")
time.sleep(0.1) # Delay for I2C


front_right_detect()

Description

Returns True if the front right IR sensor detects a value below a threshold. The value decreases as the light reflected back to the receiver increases.

Syntax

front_left_detect()
front_left_detect(threshold=100)

Parameters

integer threshold: Threshold value (0 - 255) of the front right IR sensor

Returns

boolean detected: Returns True if sensor is triggered.

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,100):
if zumi.front_right_detect():
print("Detected!")
time.sleep(0.1) # Delay for I2C


get_all_IR_data()

Description

Returns the readings from all 6 IR sensors.

Syntax

get_all_IR_data()

Parameters

None

Returns

list IR sensor readings: list of all 6 IR sensor values (0 - 255)

IR sensor indices:
index 0 - Front right sensor
index 1 - Bottom right sensor
index 2 - Back right sensor
index 3 - Bottom left sensor
index 4 - Back left sensor
index 5 - Front left sensor

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,100):
ir_readings = zumi.get_all_IR_data()
print(ir_readings)
time.sleep(0.1) # Delay for I2C


get_battery_voltage()

Description

Get the reading from battery level.

If you are charging Zumi RED LED ON you will see roughly 1.1-1.20 volts.

The battery should reach a max of 4.20 volts and the lowest it should ever reach is 3.0 volts. These values will only show up if the switch is in the on position and the RED led is not visible.

Syntax

get_battery_voltage()

Parameters

None

Returns

float voltage: The battery's voltage in units of Volts.

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,10):
# battery level is updated every 500ms or half a second
time.sleep(0.5)
battery = zumi.get_battery_voltage()
print(battery)

get_IR_data()

Description

Get the reading from the IR sensors and the index specified.

Syntax

get_IR_data(ir_sensor_index)

Parameters

integer ir_sensor_index: The specified index (0 - 5) from the IR sensors reading list.

IR sensor indices:

  • 0 IR.FRONT_RIGHT = Front right sensor
  • 1 IR.BOTTOM_RIGHT = Bottom right sensor
  • 2 IR.BACK_RIGHT = Back right sensor
  • 3 IR.BOTTOM_LEFT = Bottom left sensor
  • 4 IR.BACK_LEFT = Back left sensor
  • 5 IR.FRONT_LEFT = Front left sensor

Returns

integer IR sensor reading: IR sensor value for the given sensor (0 - 255).

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()
FRONT_RIGHT = 0

for i in range(5):
zumi.forward(40,1)
ir_reading = zumi.get_IR_data(FRONT_RIGHT)
print(ir_reading)
# Divide by 4 because note is between 0 and 60

time.sleep(0.05)

get_orientation_message()

Description

Uses the acceleration values to find Zumi's orientation with respect to the strongest force being applied to Zumi (gravity). This function returns the orientation as a string.

Syntax

get_orientation_message()

Parameters

None

Returns

string orientation state: a description of the orientation state

Descriptions of rientation state:
"unknown"
"face up"
"face down"
"right side down"
"left side down"
"upright"
"upside down"
"accelerating"

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

#grab zumi and place it on any side
#example: upside down, on its nose etc.
for i in range(20):
orientation = zumi.get_orientation_message()
print(orientation)
time.sleep(0.5)
print(" done ")


get_orientation()

Description

Uses the acceleration values to find Zumi's orientation with respect to the strongest force being applied to Zumi (gravity).

Syntax

get_orientation()

Parameters

None

Returns

integer Orientation state:
-1 = unknown
0 = probably falling or moving between states
1 = camera straight up
2 = camera facing down
3 = on right side
4 = on left side
5 = wheels on floor
6 = wheels facing up (upside down)
7 = accelerating faster than 1g

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

#grab zumi and place it on any side
#example: upside down, on its nose etc.
for i in range(20):
orientation = zumi.get_orientation()
print(orientation)
time.sleep(0.5)
print(" done ")


read_x_angle()

Description

Calls update_angles() and returns only the x-angle.

Syntax

read_x_angle()

Parameters

None

Returns

float x-angle: The current x-angle of Zumi

Example Code

#Python code
from zumi.zumi import Zumi
import IPython.display

zumi = Zumi()

for i in range(100):
print(zumi.read_x_angle())
IPython.display.clear_output(wait=True)
print("done")

read_y_angle()

Description

Calls update_angles() and returns only the y-angle.

Syntax

read_y_angle()

Parameters

None

Returns

float x-angle: The current y-angle of Zumi

Example Code

#Python code
from zumi.zumi import Zumi
import IPython.display

zumi = Zumi()

for i in range(100):
print(zumi.read_y_angle())
IPython.display.clear_output(wait=True)
print("done")


read_z_angle()

Description

Calls update_angles() and returns only the z-angle.

Syntax

read_z_angle()

Parameters

None

Returns

float x-angle: The current z-angle of Zumi

Example Code

#Python code
from zumi.zumi import Zumi
import IPython.display

zumi = Zumi()

for i in range(100):
print(zumi.read_z_angle())
IPython.display.clear_output(wait=True)
print("done")


reset_drive()

Description

Calls both reset_PID() and reset_gyro(). Use for driving straight or turning accurately.

Syntax

reset_drive()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

for i in range(0,50):
zumi.forward_step(0,50)

print(zumi.angle_list[2],", ", zumi.error_past)

zumi.stop()
zumi.reset_drive()

print(" Now ")
print(zumi.angle_list[2],", ", zumi.error_past)



reset_gyro()

Description

Resets all values in the angle list to 0. Use for driving straight or turning accurately.

Syntax

reset_gyro()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

print("z angle " , zumi.angle_list[2])

zumi.turn_left(90,1.2)

print("z angle " , zumi.angle_list[2])

zumi.reset_gyro()

print("z angle " , zumi.angle_list[2])

reset_PID()

Description

Resets the sum of the gyro error to zero as well as the PID error sum. Use for driving straight or turning accurately. This does not reset the P, I, and D values of the Zumi PID control.

Syntax

reset_PID()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

for i in range(0,50):
zumi.go_straight(50,0)
#print the error of the z angle along with some of the PID accumulators
print(zumi.PID_time_past,", ", zumi.error_past,", ", zumi.error_sum," , ", zumi.angle_list[2])

zumi.stop()

#this will reset those values
zumi.reset_PID()
print(" Now ")
print(zumi.PID_time_past,", ", zumi.error_past,", ", zumi.error_sum, " , ", zumi.angle_list[2])


update_angles()

Description

Reads angular speeds and updates the list of angles: The first 3 are angles produced from the gyroscope readings.
X angle, Y angle and Z angle in degrees.
The next 2 angles are produced by finding the tilt with respect to gravity.
X and Y acceleration angles in degrees. Work well if Zumi's wheels point to the floor
The next 2 angles are the complementary filtered angles are produced by combining both gyroscope and accelerometer angles for the x and y axis.
The next 3 are the rotation angles which are produced using the accelerometer.
rotation along X, Y and Z with respect to gravity.
The last one is the tilt state.

Syntax

update_angles()

Parameters

None

Returns

list angles: The updated list of angles in the following format, [Gyro x,Gyro y,Gyro z,Acc x,Acc y,Comp x,Comp y,Rot_x,Rot_y,Rot_z,tilt_state]

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()


for i in range(0,100):
angles = zumi.update_angles()
z_angle = angles[2]
print(z_angle)
print(" done ")


Driving

circle_left()

Description

Drives Zumi in a counterclockwise circle.

Syntax

circle_left()
circle_left(speed=30, step=2)

Parameters

integer speed: The driving speed (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.circle_left(step=3)


circle_right()

Description

Drives Zumi in a clockwise circle.

Syntax

circle_right()
circle_right(speed=30, step=2)

Parameters

integer speed: The driving speed (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.circle_right(step=3)


circle()

Description

Drives Zumi in a circle (counterclockwise by default).

Syntax

circle()
circle(speed=30, step=2, direction=1, delay=0.02)

Parameters

integer speed: The driving speed (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns) integer direction: -1 for clockwise and +1 for counterclockwise
float delay: The time delay between each angle step

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.circle(speed=60, step=4, direction=-1)


control_motors()

Description

Sets the speed of each individual motor. The changes take place immediately. This function does not include a stop command or any sensor feedback.

Syntax

control_motors(right,left)

Parameters

integer right: The speed value of the right motor (-126-127). Positive values for forward, negative values for reverse.
integer left: The speed value of the left motor (-126-127). Positive values for forward, negative values for reverse.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.control_motors(30,30)
time.sleep(2)
zumi.stop()

drive_over_markers()

Description

Zumi will drive over the specified number of alternating black and white horizontal lines at least 2 centimeters wide. Zumi will stop when the number of markers have been crossed or if the timeout ends, whichever is first. (Avoid making the speed very high, zumi will most likely overshoot since it has a lot of speed)

Syntax

zumi.drive_over_markers(5)
zumi.drive_over_markers(road_markers=3,speed=10,ir_threshold=120,time_out=3)

Parameters

integer road_markers: The number of road markers to drive over
integer speed: The speed value (0 - 80)
integer ir_threshold: The IR threshold value for the bottom left IR sensors to detect black or white.
integer time_out: Number of seconds before the timeout ends and Zumi stops driving.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

#must start off in a black area.
zumi.drive_over_markers(5)

#Drive over 10 road marker with a timeout of 6 seconds
zumi.drive_over_markers(5,40,100,3)


figure_8()

Description

Drives Zumi in a figure 8.

Syntax

figure_8()
figure_8(speed=30, step=3, delay=0.02)

Parameters

integer speed: The driving speed (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns)
float delay: The time delay between each angle step

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.figure_8(step=5)


forward_avoid_collision()

Description

Drives Zumi forward at a default speed of 40 for 1 second in the direction Zumi is currently facing. If either of the front IR sensor values go below the threshold, Zumi will stop even if the duration or timeout is not complete.

Syntax

forward_avoid_collision(speed=40, duration=1.0)
forward_avoid_collision(speed=40, duration=1.0, desired_angle=None, left_th=150, right_th=150)

Parameters

integer speed: The driving speed value (0 - 80)
float duration: Number of seconds Zumi will drive and check for collision
integer desired_angle: Heading or desired angle, in degrees (Default to None which is Zumi's current heading)
integer left_th: threshold of the front left IR sensor (0 - 255)
integer right_th: threshold of the front right IR sensor (0 - 255)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.forward_avoid_collision(40,2)


forward_step()

Description

Takes one drive "step" to correct for the set heading. This function only works when called inside of a loop.

Syntax

forward_step(speed, desired_angle)
forward_step(speed, desired_angle, max_speed=127)

Parameters

integer speed: The drive speed value (0 - 127); must be below the max_speed
integer desired_angle: heading (0 degrees is defined when the Zumi object is created.)
integer max_speed: Caps the max speed. Default to 127.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

for i in range(0, 200):
zumi.forward_step(40,20)

zumi.stop()

forward()

Description

Drives Zumi forward at a default speed of 40 for 1 second in the direction Zumi is currently facing.

Syntax

forward()
forward(speed=40, duration=1.0, desired_angle=None)

Parameters

integer speed: The driving speed value (0 - 80)
float duration: Number of seconds Zumi will drive forward
integer desired_angle: Heading or desired angle, in degrees, to drive in (When None is selected Zumi drives wherever she is facing)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward()
time.sleep(1)
zumi.forward(speed=50)
time.sleep(1)
zumi.forward(duration=2.1)
time.sleep(1)


funnel_align()

Description

Zumi will try to align to the funnel piece on the competition field (Click here for a PDF version).

Syntax

funnel_align(speed=20, duration=1.0)
funnel_align(speed=20, duration=1, angle=None, angle_adj=2, l_th=100, r_th=100)

Parameters

integer speed: The driving speed value (0 - 80)
float duration: Number of seconds Zumi will try to align to the funnel piece
integer angle: Heading or desired angle, in degrees, (Default to None which is Zumi's current heading)
integer angle_adj: The angle, in degrees, Zumi will turn if one IR sensor detects white
integer l_th: threshold of the bottom left IR sensor (0 - 255)
integer r_th: threshold of the bottom right IR sensor (0 - 255)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.funnel_align(speed=10,duration=3,angle_adj=1.1)


go_reverse()

Description

Takes one drive "step" in reverse to correct for the set heading. This function only works when called inside of a loop.

Syntax

go_reverse(speed, desired_angle)
go_reverse(speed, desired_angle, max_speed=127)

Parameters

integer speed: Drive speed (0 - 127); must be below the max_speed
integer desired_angle: heading (0 degrees is defined when the Zumi object is created.)
integer max_speed: Caps the max speed. Default to 127.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

for i in range(0, 200):
zumi.go_reverse(40,0)

zumi.stop()

go_straight()

Description

Takes one drive "step" to correct for the set heading. This function only works when called inside of a loop.

Syntax

go_straight(speed, desired_angle)
go_straight(speed, desired_angle, max_speed=127)

Parameters

integer speed: Drive speed (0 - 127); must be below the max_speed
integer desired_angle: heading (0 degrees is defined when the Zumi object is created.)
integer max_speed: Caps the max speed. Default to 127.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

for i in range(0, 200):
zumi.go_straight(40,0)

zumi.stop()

j_turn()

Description

Drives Zumi in a j-turn.

Syntax

j_turn()
j_turn(speed=80, step=4, delay=0.005)

Parameters

integer speed: The forward speed (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns)
float delay: The time delay between each angle step

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.j_turn(speed=60, delay=0.003)


left_u_turn()

Description

Drives Zumi in a left u-turn.

Syntax

left_u_turn()
left_u_turn(speed=30, step=4, delay=0.02)

Parameters

integer speed: The forward speed (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns)
float delay: The time delay between each angle step

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.left_u_turn()
time.sleep(1)
zumi.left_u_turn(step=3)


line_follower()

Description

On the road, Zumi uses the camera to detect lanes and stay inside of them.

Syntax

zumi.line_follower(duration=3, left_thresh=100,right_thresh=100)

Parameters

integer duration: Number of seconds Zumi will drive on the line
integer left_thresh: threshold of the bottom left IR sensor. By default, threshold is 100
integer right_thresh: threshold of the bottom right IR sensor. By default, threshold is 100

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.line_follower(3)
zumi.line_follower(3, left_thresh=100,right_thresh=100)

line_follow_gyro_assist()

Description

Drives Zumi forward at a default speed of 20 for 1 second in the direction Zumi is currently facing. Zumi will stop when the duration or timeout is over. If the bottom IR sensors detect a black line, Zumi will continue to drive. If one or the other sensor detects white, Zumi will auto-adjust to stay on the line. If both sensors detect white, Zumi will stop even if the duration has not been met.

Syntax

line_follow_gyro_assist(speed=20, duration=1.0)
line_follow_gyro_assist(speed=20, duration=1, angle=None, angle_adj=2, l_th=100, r_th=100)

Parameters

integer speed: The drive speed value (0 - 80)
integer duration: Number of seconds Zumi will drive on the line
integer angle: Heading or desired angle, in degrees (default is None which is Zumi's current heading)
integer angle_adj: The number of degrees Zumi will turn if one IR sensor detects white.
integer l_th: threshold of the bottom left IR sensor.
integer r_th: threshold of the bottom right IR sensor.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.line_follow_gyro_assist(speed=10,duration=3,angle_adj=1.1)


move_centimeters()

Description

This method uses a best fit linear approximation of the distance traveled over time. It uses the equation y = mx + b, where:

  • y is the distance traveled
  • m is the predicted speed in centimeters per second
  • x is the time elapsed
  • b is the slope intercept

If the PID values are not set the internal default values will be set.

If the angle is not input Zumi will drive to whatever angle it is currently facing.

Syntax

move_centimeters(distance, angle)
move_centimeters(distance, angle=None, k_p=None, k_i=None, k_d=None)

Parameters

float distance: the distance in centimeters you want to travel
integer angle: heading, in degrees (0 degrees is defined when the Zumi object is created.) Default to None
float k_p: P-gain. Default to None.
float k_i: I-gain. Default to None.
float k_d: D-gain. Default to None.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.move_centimeters(10)
zumi.move_centimeters(10,90)
zumi.move_centimeters(15,0)

move_inches()

Description

This method uses a best fit linear approximation of the distance traveled over time. It uses the equation y = mx + b, where:

  • y is the distance traveled
  • m is the predicted speed in inches per second
  • x is the time elapsed
  • b is the slope intercept

If the PID values are not set the internal default values will be set.

If the angle is not input Zumi will drive to whatever angle it is currently facing.

Syntax

move_inches(distance, angle)
move_inches(distance, angle=None, k_p=None, k_i=None, k_d=None)

Parameters

float distance: the distance in inches you want to travel
integer angle: heading, in degrees (0 degrees is defined when the Zumi object is created.) Default to None
float k_p: P-gain. Default to None.
float k_i: I-gain. Default to None.
float k_d: D-gain. Default to None.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.move_inches(5)
zumi.move_inches(6,90)
zumi.move_inches(5,0)

move_to_coordinate()

Description

This method drives Zumi from an origin to an x,y position in inches. Using this function will keep track of Zumi's coordinates. To reset the origin, use the reset_coordinate() function. This method uses a best fit linear approximation of the distance traveled over time. It uses the equation y = mx + b, where:

  • y is the distance traveled
  • m is the predicted speed in inches per second
  • x is the time elapsed
  • b is the slope intercept

Syntax

move_to_coordinate(desired_x, desired_y)
move_to_coordinate(desired_x, desired_y, k_p=None, k_i=None, k_d=None, units="in"):

Parameters

float desired_x: The x-coordinate of the destination
float desired_y: The y-coordinate of the destination
float k_p: P-gain. Default to None.
float k_i: I-gain. Default to None.
float k_d: D-gain. Default to None.
string units: Defaults to "in" or inches. Set it to "cm" for centimeters.

Returns

None

Example Code Sample 1

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

# a square
zumi.move_to_coordinate(6,0)
zumi.move_to_coordinate(6,6)
zumi.move_to_coordinate(0,6)
zumi.move_to_coordinate(0,0)

Sample 2

#Python code
from zumi.zumi import Zumi
import time
zumi = Zumi()

# Avoid this
zumi.move_to_coordinate(10,0)
time.sleep(1)
# zumi wont drive the second time since its already at (10, 0)
zumi.move_to_coordinate(10,0)

Sample 3

#Python code
from zumi.zumi import Zumi
import time
zumi = Zumi()

# Avoid this
zumi.move_to_coordinate(10,0)
time.sleep(1)

zumi.reset_coordinate()
# zumi will drive the second time since its position will be reset, and will move a total of 20 inches from the start
zumi.move_to_coordinate(10,0)

parallel_park()

Description

Drives Zumi in a parallel park maneuver.

Syntax

parallel_park()
parallel_park(speed=15, step=1, delay=0.01)

Parameters

integer speed: Drive speed (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns)
float delay: The time delay between each angle step

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,2)
zumi.parallel_park(speed=20, step=2)


rectangle_left()

Description

Drives Zumi in a counterclockwise rectangle.

Syntax

rectangle_left()
rectangle_left(speed=40, seconds=1.0, ratio=2)

Parameters

integer speed: Drive speed between (0 - 80)
float seconds: Duration in seconds for shorter side
float ratio: Ratio of longer side to shorter side (Multiply ratio by seconds to get the duration of the longer side)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.rectangle_left(ratio=3)

rectangle_right()

Description

Drives Zumi in a clockwise rectangle.

Syntax

rectangle_right()
rectangle_right(speed=40, seconds=1.0, ratio=2)

Parameters

integer speed: Drive speed between (0 - 80)
float seconds: Duration in seconds for shorter side
float ratio: Ratio of longer side to shorter side (Multiply ratio by seconds to get the duration of the longer side)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.rectangle_right(ratio=3)

rectangle()

Description

Drives Zumi in a rectangle.

Syntax

rectangle()
rectangle(speed=40, seconds=1.0, direction=1, ratio=2)

Parameters

integer speed: Drive speed between (0 - 80)
float seconds: Duration in seconds for shorter side
integer direction: direction of turn (1 for counterclockwise and -1 for clockwise)
float ratio: Ratio of longer side to shorter side (Multiply ratio by seconds to get the duration of the longer side)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.forward(40,1)
zumi.rectangle(ratio=3)

reset_coordinate()

Description

Will reset the coordinate to (0,0).

Syntax

reset_coordinate()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.move_to_coordinate(10,0)
zumi.reset_coordinate()
#zumi will drive another 10 inches
zumi.move_to_coordinate(10,0)


reverse_avoid_collision()

Description

Drives Zumi in reverse at a default speed of 40 for 1 second in the direction Zumi is currently facing. If either of the back IR sensor values go below the threshold, Zumi will stop even if the duration or timeout is not complete.

Syntax

reverse_avoid_collision(speed=40, duration=1.0)
reverse_avoid_collision(speed=40, duration=1.0, desired_angle=None, left_th=150, right_th=150)

Parameters

integer speed: Driving speed (0 - 80)
float duration: Number of seconds Zumi will drive and check for collision
integer desired_angle: Heading or desired angle, in degrees (Default to None which is Zumi's current heading)
integer left_th: threshold of the back left IR sensor
integer right_th: threshold of the back right IR sensor

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.reverse_avoid_collision(40,2)


reverse_step()

Description

Takes one drive "step" in reverse to correct for the set heading. This function only works when called inside of a loop.

Syntax

reverse_step(speed, desired_angle)
reverse_step(speed, desired_angle, max_speed=127)

Parameters

integer speed: Drive speed between (0 - 127); must be below the max_speed
integer desired_angle: heading, in degrees (0 degrees is defined when the Zumi object is created.)
integer max_speed: Caps the max speed. Default to 127.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

for i in range(50):
zumi.reverse_step(40,0)

zumi.stop()

reverse()

Description

Drives Zumi in reverse at a default speed of 40 for 1 second in the direction Zumi is currently facing.

Syntax

reverse()
reverse(speed=40, duration=1.0, desired_angle=None)

Parameters

integer speed: Driving speed between (0 - 80)
float duration: Number of seconds Zumi will drive reverse
integer desired_angle: Heading or desired angle to drive in, in degrees (When None is selected Zumi drives wherever she is facing)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.reverse()
time.sleep(1)
zumi.reverse(speed=50)
time.sleep(1)
zumi.reverse(duration=2.1)
time.sleep(1)
zumi.reverse(50,2.1,45)


right_u_turn()

Description

Drives Zumi in a right u-turn.

Syntax

right_u_turn()
right_u_turn(speed=30, step=4, delay=0.02)

Parameters

integer speed: Driving speed value (0 - 80)
integer step: The angle step size (decrease for wider turns, increase for tighter turns)
float delay: The time delay between each angle step.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.right_u_turn(speed=20)
time.sleep(1)
zumi.right_u_turn(delay=0.04)


smooth_forward()

Description

Causes Zumi to gradually accelerate forward to max speed during a given duration before decelerating back to zero.

Syntax

smooth_forward(duration)
smooth_forward(duration, rate=1)

Parameters

float duration: Total duration of drive command including acceleration and deceleration
float rate: rate at which speed changes. Default to 1

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.smooth_forward(3)
time.sleep(1)
zumi.smooth_forward(duration=3,rate=2)


smooth_reverse()

Description

Causes Zumi to gradually accelerate in reverse to max speed during a given duration before decelerating back to zero.

Syntax

smooth_reverse(duration)
smooth_reverse(duration, rate=1)

Parameters

float duration: Total duration of drive command including acceleration and deceleration
float rate: Rate at which speed changes. Default to 1

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.smooth_reverse(3)
time.sleep(1)
zumi.smooth_reverse(duration=3,rate=2)


smooth_turn_left()

Description

Turns left gradually to reach the desired angle while also going forward. Default to 90 degrees.

Syntax

smooth_turn_left()
smooth_turn_left(desired_angle=90,speed=20,step=2)

Parameters

integer desired_angle: Degrees you want to turn from your starting position
integer speed: Driving speed (0 - 80). Default to 20.
integer step: The angle step size (decrease for wider turns, increase for tighter turns)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.smooth_turn_left()
time.sleep(1)
zumi.smooth_turn_left(speed=30)


smooth_turn_right()

Description

Turns right gradually to reach the desired angle while also going forward. Default to 90 degrees.

Syntax

smooth_turn_right()
smooth_turn_right(desired_angle=90,speed=20,step=2)

Parameters

integer desired_angle: Degrees you want to turn from your starting position
integer speed: Driving speed between 0 and 80. Default to 20.
integer step: The angle step size (decrease for wider turns, increase for tighter turns)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.smooth_turn_right()
time.sleep(1)
zumi.smooth_turn_right(speed=30)


speed_calibration()

Description

In order to use this method you will need a speed calibration sheet (Click here for a PDF version). Zumi will drive over 5 horizontal white lines that are 2 centimeters wide. The slope and y_intercept will be generated for the best fit line of the speed prediction. These values will be saved to the Zumi as a text file.

This function is necessary for move_to_coordinate(), move_inches(), and move_centimeters().

Syntax

speed_calibration()
speed_calibration(speed=40, ir_threshold=100, time_out=3, cm_per_brick=2, show_graphs=False)

Parameters

integer speed: Driving speed value (0 - 80). The lower the more accurate the speed prediction.
integer ir_threshold: Integer value for the bottom left IR threshold (0-255).
float time_out: The number of seconds before the timeout.
float cm_per_brick: The width of each road marker in centimeters.
boolean show_graphs: Defaults to False. If set to True, a graph will be displayed with the best fit line prediction. *Note: You may need to run this function twice to see the graph.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

# Place Zumi on the black portion of the speed calibration sheet
zumi.speed_calibration()

# To show the graphs, replace the original "zumi.speed_calibration" with the following line
# zumi.speed_calibration(show_graphs = True)


square_left()

Description

Drives Zumi in a counterclockwise square.

Syntax

square_left()
square_left(speed=40, seconds=1.0)

Parameters

integer speed: Drive speed value (0 - 80)
float seconds: Duration in seconds Zumi drives for each side

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.square_left(seconds=1.5)

square_right()

Description

Drives Zumi in a clockwise square.

Syntax

square_right()
square_right(speed=40, seconds=1.0)

Parameters

integer speed: Drive speed value (0 - 80)
float seconds: Duration in seconds Zumi drives for each side

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.square_right(seconds=1.5)

square()

Description

Drives Zumi in a square. Default to counterclockwise.

Syntax

square()
square(speed=40, seconds=1, direction=1)

Parameters

integer speed: Drive speed between 0-80
float seconds: Duration in seconds Zumi drives for each side
integer direction: Direction of turn (-1 for clockwise and +1 for counterclockwise)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time
zumi = Zumi()
zumi.square(seconds=1.0)
time.sleep(1)
zumi.square(speed=60,seconds=1.2)

stop()

Description

Stops Zumi's motors immediately.

Syntax

stop()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

for i in range(0, 30):
zumi.go_straight(30,0)

zumi.stop()

triangle_left()

Description

Drives Zumi in a counterclockwise triangle.

Syntax

triangle_left()
triangle_left(speed=40, seconds=1.5)

Parameters

integer speed: Drive speed value (0 - 80)
float seconds: Duration in seconds Zumi drives for each side

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.triangle_left(speed=30)

triangle_right()

Description

Drives Zumi in a clockwise triangle.

Syntax

triangle_right()
triangle_right(speed=40, seconds=1.5)

Parameters

integer speed: Drive speed value (0 - 80)
float seconds: Duration in seconds Zumi drives for each side

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.triangle_right(speed=30)

triangle()

Description

Drives Zumi in a triangle. Default is counterclockwise.

Syntax

triangle()
triangle(speed=40, seconds=1.5, direction=1)

Parameters

integer speed: Drive speed value (0 - 80)
float seconds: Duration in seconds Zumi drives for each side
integer direction: Direction of turn (-1 for clockwise and +1 for counterclockwise)

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.triangle(speed=30, direction=-1)

turn_left()

Description

Causes Zumi to turn left the specified number of degrees. Default to 90 degrees.

Syntax

turn_left()
turn_left(desired_angle=90, duration=1.0)

Parameters

integer desired_angle: Degrees you want to turn to the left from your starting position. Default to 90. Only positive values.
float duration: The amount of time in seconds Zumi will try and complete the turn. Increase for turns greater than 90 degrees.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.turn_left()
time.sleep(1)
zumi.turn_left(130,1.5)

turn_right()

Description

Causes Zumi to turn right the specified number of degrees. Default to 90 degrees.

Syntax

turn_right()
turn_right(desired_angle=90,duration=1.0)

Parameters

integer desired_angle: Degrees you want to turn to the right from your starting position. Default to 90. Only positive values.
float duration: The amount of time in seconds Zumi will try and complete the turn. Increase for turns greater than 90 degrees.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.turn_right(45)
time.sleep(1)
zumi.turn_right(200,duration=1.3)


turn()

Description

Zumi will turn to a desired angle.

Syntax

turn(desired_angle)
turn(desired_angle, duration=1.5, max_speed=25, accuracy=1):

Parameters

integer desired_angle: Angle to turn. Positive degrees to the left. Negative degrees to the right.
float duration: Number of seconds Zumi will perform the command.
integer speed: The max motor speed for turning (0 - 80).
integer accuracy: The tolerance of +- degrees (e.g. accuracy = 1 means +1 or -1 degree off from desired_angle).

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

# zumi will turn to the left
zumi.turn(90)

#zumi will turn to the right 90 degrees from the starting angle
zumi.turn(-90)


LEDs-and-Buzzer

all_lights_off()

Description

Turns all LEDs off

Syntax

all_lights_off()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.all_lights_on()
time.sleep(2)
zumi.all_lights_off()

all_lights_on()

Description

Turns all LEDs on the 2 front white leds and the rear 2 leds.

Syntax

all_lights_on()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.all_lights_on()

brake_lights_off()

Description

Turns off front LEDs only

Syntax

brake_lights_off()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time
zumi = Zumi()

zumi.brake_lights_on()
time.sleep(2)
zumi.brake_lights_off()

brake_lights_on()

Description

Turns on back LEDs only

Syntax

brake_lights_on()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.brake_lights_on()

hazard_lights_off()

Description

Turns off flashing front and back LEDs

Syntax

hazard_lights_off()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.hazard_lights_on()
time.sleep(2)
zumi.hazard_lights_off()

hazard_lights_on()

Description

Flashes both front and back LEDs

Syntax

hazard_lights_on()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.hazard_lights_on()

headlights_off()

Description

Turns off front LEDs only

Syntax

headlights_off()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.headlights_on()
time.sleep(2)
zumi.headlights_off()

headlights_on()

Description

Turns on front LEDs only

Syntax

headlights_on()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.headlights_on()

play_note()

Description

Play a note, from C2 - B6.

Syntax

play_note(note_type)
play_note(note_type, note_duration=500)

Parameters

integer/enum note_type: Integer from 0 to 60 or enum from Note class. Setting the note to 0 will result in no sound.
integer note_duration: Default to 500 milliseconds but can be an integer from 0 to 2500 milliseconds. Must be in 100 millisecond increments ex. 100, 200, 500, 2000. If 0 note will play forever.

class Note:
C2 = 1
CS2 = 2
D2 = 3
DS2 = 4
E2 = 5
F2 = 6
FS2 = 7
G2 = 8
GS2 = 9
A2 = 10
AS2 = 11
B2 = 12
C3 = 13
CS3 = 14
D3 = 15
DS3 = 16
E3 = 17
F3 = 18
FS3 = 19
G3 = 20
GS3 = 21
A3 = 22
AS3 = 23
B3 = 24
C4 = 25
CS4 = 26
D4 = 27
DS4 = 28
E4 = 29
F4 = 30
FS4 = 31
G4 = 32
GS4 = 33
A4 = 34
AS4 = 35
B4 = 36
C5 = 37
CS5 = 38
D5 = 39
DS5 = 40
E5 = 41
F5 = 42
FS5 = 43
G5 = 44
GS5 = 45
A5 = 46
AS5 = 47
B5 = 48
C6 = 49
CS6 = 50
D6 = 51
DS6 = 52
E6 = 53
F6 = 54
FS6 = 55
G6 = 56
GS6 = 57
A6 = 58
AS6 = 59
B6 = 60

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.protocol import Note
import time

zumi = Zumi()

zumi.play_note(30, 500)
time.sleep(1)
zumi.play_note(Note.C4)
time.sleep(1)
# will stop the buzzer
zumi.play_note(0, 0)

signal_left_off()

Description

Turns off flashing both left front and left back LEDs

Syntax

signal_left_off()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.signal_left_on()
time.sleep(2)
zumi.signal_left_off()

signal_left_on()

Description

Flashes both left front and left back LEDs

Syntax

signal_left_on()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.signal_left_on()

signal_right_off()

Description

Turns off flashing both right front and right back LEDs

Syntax

signal_right_off()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
import time

zumi = Zumi()

zumi.signal_right_on()
time.sleep(2)
zumi.signal_right_off()

signal_right_on()

Description

Flashes both right front and right back LEDs

Syntax

signal_right_on()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi

zumi = Zumi()

zumi.signal_right_on()

Camera

capture()

Description

Takes a picture using the PiCamera and saves it in an array.

Syntax

capture()

Parameters

None

Returns

ndarray image array: a NumPy array representing the captured image

Example Code

Python

#Python code

from zumi.util.camera import Camera
import time

camera=Camera()

camera.start_camera()
frame = camera.capture()
camera.show_image(frame)
time.sleep(5)
camera.close()

clear_output()

Description

Clear the output for the next image to show.

Syntax

clear_output()

Parameters

None

Returns

None

Example Code

from zumi.util.camera import Camera

camera = Camera()

camera.start_camera()
try:
for x in range(30):
frame = camera.capture()
camera.show_image(frame)
camera.clear_output() # Clear the output for the next image to show
finally:
camera.close()

close()

Description

Releases camera's resources

Syntax

close()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.camera import Camera

camera=Camera()

camera.start_camera()
camera.save_photo()
camera.close() # closes camera stream

is_closed()

Description

Checks if the camera stream is open

Syntax

is_closed()

Parameters

None

Returns

Boolean: Returns True if camera stream is open. Otherwise returns False

Example Code

#Python code
from zumi.util.camera import Camera

camera=Camera()

camera.start_camera()
camera.close()
print("Camera is closed?")
print(camera.is_closed())
if not camera.is_closed():
camera.close()

save_photo()

Description

Captures an image and saves it in the working directory.

Syntax

save_photo()
save_photo(file_name)

Parameters

string file_name: The name of the image file that will be saved. Default name (no input) is the current time.

Returns

None

Example Code

#Python code
from zumi.util.camera import Camera

camera=Camera()

camera.start_camera()
camera.save_photo()
#"<current_time>.jpg" file will be saved in the current working directory
camera.save_photo("Cheese")
#"Cheese.jpg" file will be saved in the current working directory
camera.close()

show_image()

Description

Displays an image taken from Zumi's camera.

Syntax

show_image(frame)

Parameters

ndarray frame: An image array that will be displayed

Returns

None

Example Code

#Python code

from zumi.util.camera import Camera
import time

camera=Camera()

camera.start_camera()
frame = camera.capture()
camera.show_image(frame)
camera.close()

start_camera()

Description

Turns on the camera

Syntax

start_camera()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.camera import Camera
import cv2
import IPython.display
import PIL.Image
from io import BytesIO
import time

# you can change the resolution of the camera
# using the image_w = image width
# and the image_h = image heigth
#camera = Camera(image_w=1280,image_h=960)
#camera = Camera(image_w=1024,image_h=768)
#camera = Camera(image_w=128,image_h=64)
camera = Camera(image_w=60,image_h=32)

camera.start_camera() # opens camera stream

time_start = time.time()
try:
for i in range(30):
frame = camera.capture()

img = PIL.Image.fromarray(frame, "RGB")
buffer = BytesIO()
img.save(buffer,format="JPEG")

IPython.display.display(IPython.display.Image(data=buffer.getvalue()))

IPython.display.clear_output(wait=True)

finally:
print(30/(time.time()-time_start))

Colors

fit()

Description

Fits values for prediction. By default, HSV is fitted.

Syntax

fit(values)

Parameters

string values: values to be fitted for prediction. By default hsv is fitted.

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.camera import Camera
from zumi.util.screen import Screen
from zumi.util.color_classifier import ColorClassifier
import time
camera = Camera()
screen = Screen()
zumi = Zumi()

user_name = 'username' # Type your actual username here
project_name = 'project_name' # Type your actual project name here

knn = ColorClassifier(user_name=user_name) # Must include "user_name="
train = knn.load_model(project_name)
knn.fit("hsv") # Fitting to HSV

camera.start_camera()
while True:
user_input = input("Press 'enter' to predict or 'q to quit: ")
if user_input == "q":
break
image = camera.capture()
predict = knn.predict(image)
screen.draw_text_center(predict)
camera.close()

predict()

Description

Predicts a color captured from the Zumi camera.

Syntax

predict(pred_features)

Parameters

ndarray p*red_features: The image to draw the prediction from

Returns

string prediction: The prediction made by the knn color classifier

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.camera import Camera
from zumi.util.screen import Screen
from zumi.util.color_classifier import ColorClassifier
import time
camera = Camera()
screen = Screen()
zumi = Zumi()

user_name = 'username' # Type your actual username here
project_name = 'project_name' # Type your actual project name here

knn = ColorClassifier(user_name=user_name) # Must include "user_name="
train = knn.load_model(project_name)
knn.fit("hsv") # Fitting to HSV

camera.start_camera()
while True:
user_input = input("Press 'enter' to predict or 'q to quit: ")
if user_input == "q":
break
image = camera.capture()
predict = knn.predict(image) # Based on the image taken, the knn color classifier will predict a color
screen.draw_text_center(predict) # This prediction gets written to the Zumi screen
camera.close()

load_model()

Description

Loads the model based on your project name.

Syntax

load_model(name)

Parameters

string name: The project name. This will depend on what you chose to name your project

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.camera import Camera
from zumi.util.screen import Screen
from zumi.util.color_classifier import ColorClassifier
import time
camera = Camera()
screen = Screen()
zumi = Zumi()
user_name = 'username' # Type your actual username here
project_name = 'project_name' # Type your actual project name here

knn = ColorClassifier(user_name=user_name) # Must include "user_name="
train = knn.load_model(project_name) # Loads the model based on your project name.
knn.fit("hsv")

camera.start_camera()
while True:
user_input = input("Press 'enter' to predict or 'q to quit: ")
if user_input == "q":
break
image = camera.capture()
predict = knn.predict(image)
screen.draw_text_center(predict)
camera.close()

Vision

convert_to_gray()

Description

Converts captured image into a grayscaled image.

Syntax

convert_to_gray(img)

Parameters

ndarray img: an image array to be converted

Returns

ndarray image array: a modified image array of img for grayscaling

Example Code

from zumi.util.vision import Vision
from zumi.util.camera import Camera

camera = Camera()
vision = Vision()

camera.start_camera()
img = camera.capture()
camera.close()
gray = vision.convert_to_gray(img) # Convert it to grayscaled version of img
camera.show_image(gray)


convert_to_hsv()

Description

Converts captured image to an HSV image.

Syntax

convert_to_hsv(img)

Parameters

ndarray img: An image array to be converted

Returns

ndarray image array: A modified image array of img in the HSV colorspace

Example Code

from zumi.util.vision import Vision
from zumi.util.camera import Camera

camera = Camera()
vision = Vision()

camera.start_camera()
img = camera.capture()
camera.close()
hsv = vision.convert_to_hsv(img) # Convert it to HSV, hue saturation and value
camera.show_image(hsv)


get_QR_message()

Description

Returns the message from decoded QR code.

Syntax

get_QR_message(Qr_object)

Parameters

Decoded Qr_object: decoded QR data (an object of class Decoded) that find_QR_code()

Returns

string message: decoded message from QR code

Example Code

from zumi.util.vision import Vision
from zumi.util.camera import Camera

camera = Camera()

camera.start_camera()
frame = camera.capture()
camera.close()
qr_code = vision.find_QR_code(frame)
message = vision.get_QR_message(qr_code) # returns None if QR code was not detected
print(message)

find_face()

Description

Searches captured image for facial features to find face's pixel location in the image.

Syntax

find_face(frame, scale_factor=1.05, min_neighbors=8, min_size=(40,40))

Parameters

ndarray frame: an image array
float scale_factor: a number to reduce image size for easier training. By default, scale_factor is 1.05 (reducing the image by 5%)
integer min_neighbors: minimum number of neighbors (features that have similarities)
integer min_size: minimum size of face to be detected

Returns

list area: [x,y,w,h] of the face's x and y coordinates along with the area's width and height. Returns None if not detected

Example Code

from zumi.util.camera import Camera
from zumi.util.vision import Vision

camera = Camera()
vision = Vision()

camera.start_camera()
image = camera.capture()
camera.close()

face_location = vision.find_face(image, scale_factor = 1.05, min_neighbors=8, min_size= (40,40))
# returns location of face frame within image. None if not found

print("[x,y,w,h] =",face_location)
camera.show_image(image) # displays image with outlined face (if it exists) in Jupyter Notebook

find_stop_sign()

Description

Searches an image for a stop sign and returns a list containing x-y coordinates, width, and height of the stop sign's frame.

Syntax

find_stop_sign(frame, scale_factor=1.05, min_neighbors=8, min_size=(40,40))

Parameters

ndarray frame: an image array
float scale_factor: a number to reduce image size for easier training. By default, scale_factor is 1.05 (reducing the image by 5%)
integer min_neighbors: minimum number of neighbors (features that have similarities)
integer min_size: minimum size for the stop sign to be detected

Returns

list area: [x,y,w,h] of the stop sign's x and y coordinates along with the area's width and height. Returns None if not detected

Example

from zumi.util.camera import Camera
from zumi.util.vision import Vision

camera = Camera()
vision = Vision()

camera.start_camera()
image = camera.capture()
camera.close()

stop_sign_location = vision.find_stop_sign(image, scale_factor = 1.05, min_neighbors=8, min_size= (40,40))
# returns location of stop sign frame within image. None if not found

print("[x,y,w,h] =",stop_sign_location)
camera.show_image(image) # displays image with outlined stop sign (if it exists) in Jupyter Notebook

find_QR_code()

Description

Processes the image that is given as a parameter and draws a rectangle around the QR code with the decoded message on it.

Syntax

find_QR_code(frame)

Parameters

*ndarray frame: a NumPy array representing a captured image (image array)

Returns

Decoded decoded_Qr: decoded QR data (an object of Decoded class). Returns None if QR code is not detected

Example Code

from zumi.zumi import Zumi
from zumi.util.camera import Camera
from zumi.util.vision import Vision

camera = Camera()
vision = Vision()

camera.start_camera()
try:
for i in range(50):
frame = camera.capture()
vision.find_QR_code(frame)
camera.show_image(frame)
camera.clear_output()
finally:
print("Done!")
camera.close()

find_smile()

Description

Searches captured image for smiling facial features to find smile's pixel location in the image.

Syntax

find_smile(frame, scale_factor=1.05, min_neighbors=8, min_size=(40,40))

Parameters

ndarray frame: a NumPy array representing a captured image (image array)
float scale_factor: a number to reduce image size for easier training. By default, scale_factor is 1.05 (reducing the image by 5%)
integer min_neighbors: minimum number of neighbors (features that have similarities)
integer min_size: minimum size of face to be detected
integer max_size: maximum size of face to be detected

Returns

list area: [x,y,w,h] of the smiles's x and y coordinates along with the area's width and height. Returns None if not detected

Example Code

from zumi.util.camera import Camera
from zumi.util.vision import Vision

camera = Camera()
vision = Vision()

camera.start_camera()
image = camera.capture()
camera.close()


smile_location = vision.find_smile(image, scale_factor = 1.05, min_neighbors=8, min_size= (40,40))
# returns location of smile frame within image. None if not found

print("[x,y,w,h] =",smile_location)
camera.show_image(image) # displays image with outlined smile (if it exists) in Jupyter Notebook

Screen

angry()

Description

Draws Zumi's angry eyes on the screen.

Syntax

angry()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.angry()

Description

Draws Zumi's blinking animation on the screen.

Syntax

blink()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.blink()

clear_display()

Description

Clears everything on the OLED by drawing a black rectangle.

Syntax

clear_display()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.print("Hello")
screen.clear_display()


clear_drawing()

Description

Clears the drawing canvas object without clearing the OLED screen. Use this before using any new draw functions.

Syntax

clear_drawing()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.draw_circle(30,30,10)
time.sleep(1)
screen.clear_drawing()
screen.print("Hello")


clock()

Description

Clears the screen and draws a clock with the given hour and minute set by the user.

Syntax

clock(hour, minute)
clock(hour, minute, string='', font_size=18)

Parameters

integer hour: hour set by user
integer minute: minute set by user
string message: an 8 character message to be displayed under the clock (optional). Defaults to an empty string.
integer font_size: the font-size of the time

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.clock(3,15,"Monday")

close_eyes()

Description

Draws Zumi's closed eyes on the screen.

Syntax

close_eyes()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen

screen = Screen()

screen.close_eyes()

draw_arc()

Description

Draws an arc within the boundaries of points x1,y1, and x2,y2 at the specified starting and ending angles.

Syntax

draw_arc(x1, y1, x2, y2, start_ang, end_ang)
draw_arc(x1, y1, x2, y2, start_ang, end_ang,fill_in=True)

Parameters

integer x1: x coordinate of top-left corner for the rectangle enclosing the arc
integer y1: y coordinate of top-left corner for the rectangle enclosing the arc
integer x2: x coordinate of bottom-right corner for the rectangle enclosing the arc
integer y2: y coordinate of bottom-right corner for the rectangle enclosing the arc
integer start_ang: starting arc angle, in degrees
integer end_ang: ending arc angle, in degrees
boolean fill_in: Boolean that selects if the triangle will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen

screen=Screen()

screen.draw_arc(0,0,50,50,-180,0)

draw_chord()

Description

Draws a chord within the boundaries of points x1,y1, and x2,y2 at the specified starting and ending angles.

Syntax

draw_chord(x1, y1, x2, y2, start_ang, end_ang)
draw_chord(x1, y1, x2, y2, start_ang, end_ang,fill_in=True)

Parameters

integer x1: x coordinate of top-left corner for the rectangle enclosing the chord
integer y1: y coordinate of top-left corner for the rectangle enclosing the chord
integer x2: x coordinate of bottom-right corner for the rectangle enclosing the chord
integer y2: y coordinate of bottom-right corner for the rectangle enclosing the chord
integer start_ang: starting angle
integer end_ang: ending angle
boolean fill_in: Boolean that selects if the triangle will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen

screen=Screen()

screen.draw_chord(0,0,20,20,-180,0)
screen.draw_chord(30,30,50,50,-180,0)

#do a 360 from -180 degrees to 180 degrees
screen.draw_chord(60,30,100,50,-180,180)

draw_circle()

Description

Draws a circle that fits inside a square with its top-left corner at x,y and a width/height of the circle's diameter.

Syntax

draw_circle(x, y, diameter)
draw_circle(x, y, diameter, fill_in=True)

Parameters

integer x: x-coordinate of the top-left corner of the enclosing square
integer y: y-coordinate of the top-left corner of the enclosing square
integer diameter: diameter of the circle (also the width and height of enclosing square)
boolean fill_in: Boolean that selects if the triangle will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.draw_circle(10,0,20,fill_in=False)

draw_ellipse()

Description

Draws an ellipse that fits in a rectangle with its top-left corner at x,y and a set width and height.

Syntax

draw_ellipse(self, x, y, width, height)
draw_ellipse(self, x, y, width, height, fill_in=True)

Parameters

integer x: x coordinate of the top-left corner of the enclosing rectangle
integer y: y coordinate of the top-left corner of the enclosing rectangle
integer width: width of enclosing rectangle
integer height: height of enclosing rectangle
boolean fill_in: Boolean that selects if the triangle will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.draw_ellipse(0,0,100,30,fill_in=True)

draw_image()

Description

Draws the image on the screen.

Syntax

draw_image(img)

Parameters

Image img: An image object that's produced using screen.path_to_image(path), "path" being the file location of your image.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()
path = "/usr/local/lib/python3.5/dist-packages/zumi/util/images/happy1.ppm"
screen.draw_image(screen.path_to_image(path))


draw_line()

Description

Draws a line between points (x1,y1) and (x2,y2).

Syntax

draw_line(x1, y1, x2, y2)
draw_line(x1, y1, x2, y2, thickness=1,fill_in=True)

Parameters

integer x1: x coordinate of the starting point
integer y1: y coordinate of the starting point
integer x2: x coordinate of the ending point
integer y2: y coordinate of the ending point
integer thickness: pixel width of the line
boolean fill_in: Boolean that selects if the line will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.draw_line(0,0,40,40,fill_in=True)
screen.draw_line(40,0,0,40,thickness=10,fill_in=True)

draw_point()

Description

Draws a single pixel at the set x and y coordinate.

Syntax

draw_point(x, y)
draw_point(x, y,fill_in=True)

Parameters

integer x: the x coordinate
integer y: the y coordinate
boolean fill_in: Boolean that selects if the point will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.draw_point(100,30)

draw_polygon()

Description

Draws lines between points in a given list [(x1,y1),...,(xn,yn)] to form a shape.

Syntax

draw_polygon(points_list)
draw_polygon(points_list,fill_in = True):

Parameters

list points_list: A list [x1,y1,x2,y2,....xn,yn] with at least 3 points
boolean fill_in: Boolean that selects if the polygon will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()
points = [(30,50),(90,10),(20,10),(5,20)]

screen.draw_polygon(points)

draw_rect()

Description

Draws a rectangle on the screen.

Syntax

draw_rect(x, y, width, height)
draw_rect(x, y, width, height, thickness=1, fill_in=False)

Parameters

integer x: the top left corner x coordinate
integer y: the top left corner y coordinate
integer width: width of rectangle
integer height: height of rectangle
integer thickness: thickness of rectangle border, default to 1
boolean fill_in: Boolean that selects if the shape will be filled in. Default to False.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.draw_rect(0,0,128,64,thickness=1,fill_in=True)

draw_square()

Description

Draws a square on the screen.

Syntax

draw_square(x, y, width)
draw_square(x, y, width, thickness=1, fill_in=False)

Parameters

integer x: the top left corner x coordinate
integer y: the top left corner y coordinate
integer width: width of each side
integer thickness: thickness of rectangle border, default to 1
integer fill_in: Boolean that selects if the shape will be filled in. Default to False.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.draw_square(0,0,30,thickness=1,fill_in=True)

draw_text_center()

Description

Draws text to the center of the screen

Syntax

draw_text_center(string, font_size=16)
draw_text_center(string)
draw_text_center(string, font_size)

Parameters

string string: The text that Zumi will show on the screen integer font_size: The font size of the text, defaults to 16 pixels.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time


screen=Screen()

screen.draw_text_center('hello',font_size=10)
time.sleep(0.5)
screen.draw_text_center('hello',font_size=20)
time.sleep(0.5)
screen.draw_text_center('hello',font_size=30)
time.sleep(0.5)
screen.draw_text_center('hello',font_size=40)
time.sleep(0.5)
screen.draw_text_center('hello',font_size=50)
time.sleep(0.5)

draw_text()

Description

Draws text to the upper lefthand corner of the screen

Syntax

draw_text(string)
draw_text(string, x, y, font_size) (display, clear)..

Parameters

string string: The text that Zumi will show on the screen
integer x: The x coordinate start value of the string, defaults to 1
integer y: The y coordinate start value of the string, defaults to 1
integer font_size: The font size of the string, defaults to 16 pixels

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

for i in range(10):
screen.draw_text(str(i)+'!')
time.sleep(0.1)
screen.clear_display()

draw_triangle()

Description

Draws a triangle with 3 points (x1,y1), (x2,y2), (x3,y3): x1, y1, x2, y2, x3, y3.

Syntax

draw_triangle(x1,y1,x2,y2,x3,y3)
draw_triangle(x1,y1,x2,y2,x3,y3,fill_in=True):

Parameters

integer x1: the x coordinate of point 1
integer y1: the y coordinate of point 1
integer x2: the x coordinate of point 2
integer y2: the y coordinate of point 2
integer x3: the x coordinate of point 3
integer y3: the y coordinate of point 3
boolean fill_in: Boolean that selects if the triangle will be filled in (white). Default to True.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen

screen=Screen()

screen.draw_triangle(0,10,20,50,50,0)

glimmer()

Description

Draws an animation of Zumi's eyes glimmering on the screen.

Syntax

glimmer()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.glimmer()

happy()

Description

Draws an animation of Zumi's happy eyes.

Syntax

happy()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.happy()

hello()

Description

Draws Zumi's default eyes on the screen.

Syntax

hello()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.hello()

look_around_open()

Description

Draws Zumi's eyes looking around left and right on the screen.

Syntax

look_around_open()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.look_around_open()

look_around()

Description

Makes zumi look around

Syntax

look_around()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.look_around()

print()

Description

Prints any number of strings on the screen.

Syntax

print(*messages)
print(*messages,x=0, y=0, fill_in=True,font_size=12)

Parameters

string messages: Any number of strings that will print to the screen
integer x: x coordinate of the string. Default to 0.
integer y: y coordinate of the string. Default to 0.
boolean fill_in: Boolean that selects if text will be white(True) or black (False). Default to True.
integer font_size: Pixel size of the font. Default to 12.

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
import time

screen=Screen()

screen.print("12345678")
screen.print("hello", y=15)
screen.print("\n\n","Zumi")

time.sleep(1)
screen.clear_drawing()
screen.print("ZUMI",font_size=20)


sad()

Description

Draws Zumi's sad eyes on the screen.

Syntax

sad()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen

screen = Screen()

screen.sad()

show_screen()

Description

Displays an image on Zumi's screen taken from Zumi's camera.

Syntax

show_image(frame)

Parameters

ndarray frame: A NumPy array representing a captured image

Returns

None

Example Code

from zumi.util.screen import Screen
from zumi.util.camera import Camera

screen = Screen()
camera = Camera()

camera.start_camera() # Turn on the camera
image = camera.capture() # Take a picture
camera.close() # Make sure to close the camera stream
screen.show_image(image) # Display image on OLED

sleeping()

Description

Draws an animation of Zumi sleeping on the screen.

Syntax

sleeping()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.sleeping()

sleepy_eyes()

Description

Draws Zumi's sleepy eyes on the screen.

Syntax

sleepy_eyes()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.sleepy_eyes()

sleepy_left()

Description

Draws a sleepy left eye on the screen.

Syntax

sleepy_left()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.sleepy_left()

sleepy_right()

Description

Draws a sleepy right eye on the screen.

Syntax

sleepy_right()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.util.screen import Screen
screen = Screen()

screen.sleepy_right()

Personality

angry()

Description

Draws Zumi's angry eyes on the screen.

Syntax

angry()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.angry()

awake()

Description

Draws Zumi opening her eyes with the wake up sound effect.

Syntax

awake()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.awake()

celebrate()

Description

Makes Zumi celebrate.

Syntax

celebrate()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.celebrate()

disoriented_left()

Description

Draws Zumi's eyes looking to the left with the disoriented sound effect.

Syntax

disoriented_left()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.disoriented_left()

disoriented_right()

Description

Draws Zumi's eyes looking to the right with the disoriented sound effect.

Syntax

disoriented_right()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.disoriented_right()

happy()

Description

Makes Zumi wiggle and make a happy sound.

Syntax

happy()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.happy()

look_around_open()

Description

Makes Zumi look around with wide open eyes.

Syntax

look_around_open()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.look_around_open()

look_around()

Description

Makes Zumi look around.

Syntax

look_around()

Parameters

None

Returns

None

Example Code

#Python code
from zumi.zumi import Zumi
from zumi.util.screen import Screen
from zumi.personality import Personality

zumi = Zumi()
screen = Screen()
personality = Personality(zumi, screen)

personality.look_around()