HomeTurtlegraficsGPanelRobotics WebTigerPython
 Python - Online
Deutsch   English   

Dokumentation Callibot

Modul callibot

Modul import:
from callibot import *

Function Action
forward() sets robot in forward motion
delay(ms) stops program for ms milliseconds
backward() sets robot in reverse motiong
left() sets robot in a left turn (one motor in forward, the other in backward rotation)
right() sets robot in a right turn (one motor in forward, the other in backward rotation)
leftArc(radius) sets robot to a left curve with given radius (in m)
rightArc(radius) sets robot to a right curve with given radius (in m)
stop() stops the movement
setSpeed() sets the speed for all movements (10...100), default 50
setLED(n) n = 1: turns both LEDs on, n = 0: turns both LEDs off
setAlarm(n) n = 1: sets the alarm on, n = 0: sets the alarm off
getDistance() returns the distance (in cm, in range 2..200 approx.) measured with the ultrasonic sensor (255: illegal measurement))
motL.rotate(speed) rotatate motor left (speed > 0: forwad, speed < 0: backward, speed= 0: stop) (speed -255 - 255)
motR.rotate(speed) rotatate motor rightt (speed > 0: forwad, speed < 0: backward, speed= 0: stop) (speed -255 - 255)
setLEDLeft(n)
setLEDRight(n))
turns LED on (n = 1) or off (n = 0)
setServo(port, angle) rotates the servo motor at port S1 or S2 to the given angular position.(angle: 0 to 180)
playTone(freq., duration plays the sound at the given frequency for the given time

 

Modul callibormot (Controlling motors individually)

Modul import:
from callibotmot import *

motL, motR motor left , motor right
motL.rotate(speed)
motR.rotate(speed)
rotatate motor left or right (speed > 0: forwad, speed < 0: backward, speed= 0: stop) (speed 0 - 100)


 

Documentation Calliope Mini

Modul import: from calliope_mini import *

Global function calls

Function Action
reset() restarts the board (and executes main.py)
sleep(dt) stops program for ms milliseconds
temperature() returns the temperature in degrees celsius (as float))




Class Display

display object reference (instance)

Methods:
set_pixel(x, y, value) sets the intensity of pixel at position x, y. value in range 0..9
get_pixel(x, y) returns the intensity of the pixel at position x, y
clear() clears all pixels
on()/off() switches the display on/off. When switched off, the following pins are also available as I/O: pin4, pin6, pin7, pin9
show(str) shows given str on LED display. If str has more than 1 character, the text ist scrolled until the last character becomes visible
show(img) shows given str on LED display. If str has more than 1 character, the text ist scrolled until the last character becomes visible
show(list_of_img, delay = 400, loop = False, wait = True, clear = False) shows all images of the list in a timed sequence. If loop = True ist, the sequence is repeated infinitely. For wati = True the method is blocking, otherwise it returns while the sequence continues in the background. delay is the display time for each image in ms (default: 400). For clear = True, the display is clear after the last image is shown
scroll(str) shows str as scrolling text. The last character disappears
scroll(str, delay = 150, loop = False, wait = True, monospace = False) show str as scrolling text . If loop = True, the sequence is repeated infinitely. For wait = True the method is blocking, otherwise it returns while the sequence continues in the background. delay is the display time for a single column (default: 150)




Class Image
Image(str) creates object reference (instance). str has format "aaaaa:bbbbb:ccccc:ddddd:eeeee:" where a is a number in the range 0..9 and defines the intensity of the pixel, a are values of first line, b of second, etc.
Image() creates object reference (instance) with 5x5 pixels and all pixels are turned off

Methods:
set_pixel(x, y, value) sets the intensity of pixel at position x, y. value in range 0..9
fill(value) sets all pixel intensities to the given value (0..9)
get_pixel(x, y) returns the intensity of the pixel at position x, y
shift_left(n) returns an Image object by shifting the picture left by n columns (inserted columns at the right are turned off)
shift_right(n) returns an Image object by shifting the picture right by n columns (inserted columns at the left are turned off)
shift_up(n) returns an Image object by shifting the picture up by n rows (inserted rows at the bottom are turned off)
shift_down(n) returns an Image object by shifting the picture down by n rows (inserted rows at the top are turned off)
copy() returns a clone of the image
invert() returns an Image object by inverting the intensity of all pixels (new_value = 9 - value)

Operationen:
image_new = image * n returns an object with all pixel intensities multiplied by n
image_new = image1 + image2 returns an object by adding the pixel intensities of image1 and image2


Predefined images:

  • Image.HEART
  • Image.HEART_SMALL
  • Image.HAPPY
  • Image.SMILE
  • Image.SAD
  • Image.CONFUSED
  • Image.ANGRY
  • Image.ASLEEP
  • Image.SURPRISED
  • Image.SILLY
  • Image.FABULOUS
  • Image.MEH
  • Image.YES
  • Image.NO
  • Image.CLOCK12, Image.CLOCK11, Image.CLOCK10, Image.CLOCK9, Image.CLOCK8, Image.CLOCK7, Image.CLOCK6, Image.CLOCK5, Image.CLOCK4, Image.CLOCK3, Image.CLOCK2, Image.CLOCK1
  • Image.ARROW_N, Image.ARROW_NE, Image.ARROW_E, Image.ARROW_SE, Image.ARROW_S, Image.ARROW_SW, Image.ARROW_W, Image.ARROW_NW
  • Image.TRIANGLE
  • Image.TRIANGLE_LEFT
  • Image.CHESSBOARD
  • Image.DIAMOND
  • Image.DIAMOND_SMALL
  • Image.SQUARE
  • Image.SQUARE_SMALL
  • Image.RABBIT
  • Image.COW
  • Image.MUSIC_CROTCHET
  • Image.MUSIC_QUAVER
  • Image.MUSIC_QUAVERS
  • Image.PITCHFORK
  • Image.XMAS
  • Image.PACMAN
  • Image.TARGET
  • Image.TSHIRT
  • Image.ROLLERSKATE
  • Image.DUCK
  • Image.HOUSE
  • Image.TORTOISE
  • Image.BUTTERFLY
  • Image.STICKFIGURE
  • Image.GHOST
  • Image.SWORD
  • Image.GIRAFFE
  • Image.SKULL
  • Image.UMBRELLA
  • Image.SNAKE
  • Listen: Image.ALL_CLOCKS, Image.ALL_ARROWS


Class Buttons

button_a object reference (instance) of button A
button_b object reference (instance) of button B

Methods:
is_pressed() returns True, if the button is down (pressed); otherwise False
was_pressed() returns True, if the button was pressed since the last call (or start of the program). Another call returns False, until the button is pressed againd




Class ColorLED
led Instance of FarbLED

Methoden:
set_colors(r, g, b) sets the three color components r, g, b = 0..255
get_colors() returns the three color components as a tuple


ColorLEDs Callope mini 3
Modul import: from neopixel import *

LEDs = NeoPixel(pin_RGB, 3) Instances LEDs[0], LEDs[1], LEDs[2]

Methods:
LEDs[0] = (r, g, b) sets the three color components for the first LED, r, g, b = 0..255
LEDs[1] = (r, g, b) sets the three color components for the second LED, r, g, b = 0..255
LEDs[2] = (r, g, b) sets the three color components for the third LED, r, g, b = 0..255
LEDs.show() displays the selected colors on all LEDs




Class Accelerometer
accelerometer object reference (instance)

Methods:
get_x(), get_y(), get_z() returns the current value of acceleration in x, y or z direction (int, range approx.. -2047 to +2048, corresponding approx. -20 m/s^2 to +20 m/s^2, gravitational acceleration of approx. 10 m/s^2 included). x direction: ButtonA-ButtonB; y direction: Pin2-USB; z direction: perpenticular to the board
get_values() returns a tuple with the acceleration in x, y and z direction (ints, units as above)
current_gesture() returns the current gesture. The following gestures are detected: " up", " down", " left", " right", " face up", " face down", " freefall", " 3g", " 6g", " 8g", " shake"




Class Compass
compass object reference (instance)

Methoden:
get_x(), get_y(), get_z() returns the current value of the x, y or z component of the magnetic field at the sensor position (int, in microtesla, no calibration needed)




Class Gyrometer

gyrometer object reference (instance)

Methods:
get_x(), get_y(), get_z() gives the current value of the x, y or z component of the angular velocity
get_values() gives a tuple of the x-, y- and z-components of the angular velocity




Class NeoPixel

(Modul import: from neopixel import *)
np = NeoPixel(pin, n)

creates a Neopixel object (instance) with n neopixels controlled via given pin. Each pixel is addressed by its position (starting from 0) and its color is determined by assigning a RGB tuple, e.g. np[2] = (0, 100, 255) sets pixel # 2 to red = 0, green = 100, blue = 255. show() must be called to update the display


Methods:
clear()

clears all pixels

show() shows the pixels. Must be called to make any change of color values visible



Modul music

(Modul import: from music import *)

Functions:
pitch(frequency, len, pin = pin0, wait = True) plays a tone with given frequency in Hertz during the given length (duration) (in milliseconds). pin defines the output pin at the GPIIO header (default: P0). If wait = True, the function is blocking; otherwise it returns while the sound continues (until finished or stop() is called)
play(melody) plays a melody with current tempo. pin defines the output pin at the GPIIO header (default: P0). If wait = True, the function is blocking; otherwise it returns while the sound continues (until finished or stop() is called). If loop is True, the melody is played again infinitely

Predefined songs:

  • ADADADUM -Beethoven’s 5. Sinfonie
  • ENTERTAINER -Scott Joplin’s Ragtime Klassiker “The Entertainer”
  • PRELUDE Prelude C Dur von J.S.Bach’s 48
  • ODE - “Ode on Joy Thema aus Beethoven’s 9. Sinfonie
  • NYAN - the Nyan Cat Thema
  • RINGTONE -Phone tone
  • FUNK - A sound for secret agents
  • BLUES - Boogie-Woogie Blues
  • BIRTHDAY - Happy Birthday to You
  • WEDDING - Chorus of the groom Wagner’s Oper Lohengrin
  • FUNERAL -Frédéric Chopin Klaviersonate No. 2, B♭Moll
  • PUNCHLINE - a funnyTonclip,
  • PYTHON - Python Flying Circus
  • BADDY - The Baddy
  • CHASE - Hunting scene
  • BA_DING -a Signal tone
  • WAWAWAWAA - Posaunenklang
  • JUMP_UP -for games, go up
  • JUMP_DOWN - for games go down
  • POWER_UP -power up
  • POWER_DOWN - power down



Modul radio:

(Modul import: from radio import *)

Bluetooth Communication

Funktions:
on() turns Bluetooth communication on. Connecting to a micro:bit node that has radio turned on
off() turns Bluetooth communicaion off
send(msg) sends the message string to the receiving node's message queue (First-In-First-Out, FIFO buffer)
msg = receive()

returns the oldest message (string) in the message queue and removes it from the queue. None is returned, if the queue is empty. It is assumed that the messages is sent with send(smg), so it can be converted in a valuable string [otherwise a ValueError exception ("received packet is not a string") is raised]





Modul cpglow
(Modul import: from cpglow import *)

makeGlow()

creates a visible glowbug at position (0, 0) directed to the north with its trace enabled. Coordinate system: -2 <=x <=2 (+ to the right), -2 <= y <= 2 (+ upwards), (0, 0) at center pixel
forward() moves the glowbug one step in the forward direction
back() moves the glowbug one step in the backward direction
left(angle) turns the glowbug in 45 degrees increments to the left (angle = 45, 90, 135, 180, 215, 270, 315)
right(angle) turns the glowbug in 45 degrees increments to the right (angle = 45, 90, 135, 180, 215, 270, 315)
setSpeed() sets the speed for movements (0..100)
show() makes the glowbug visible at the current position and for the next movements
hide() makes the glowbug invisible for the next movements
clear() clears all visible pixels. The glowbug remains at the current position (but is invisible)
showTrace(False/True) enables/disables the trace for the following movements (pixels are turned on at the glowbug position)
setPos(x, y) sets the glowbug at position (x, y)
getPos() returns the current position of the glowbug (as tuple)
isLit() returns True, if the pixel at the current glowbug position is turned on