This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions.

If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

thingz.thingz_accel

Thingz accelerometer

class thingz.thingz_accel.Accel

Control Galaxia’s accelerometer

get_x() float
Returns:

the acceleration value of x axis in mG

Return type:

float

get_y() float
Returns:

the acceleration value of y axis in mG

Return type:

float

get_z() float
Returns:

the acceleration value of z axis in mG

Return type:

float

get_values() list
Returns:

the acceleration values of the 3 axis in a list. Index 0 is X, 1 is Y, 2 is Z

Return type:

list

current_gesture() str

Get the current gesture. Can be on of the following value:

  • up

  • down

  • left

  • right

  • face up

  • face down

  • freefall

  • 3g

  • 6g

  • 8g

  • shake

  • none

Returns:

the current gesture

Return type:

str

is_gesture(gesture: str) bool
Parameters:

gesture (str) – the gesture to test

Returns:

True if the current gesture is the gesture receive as parameter

Return type:

bool

was_gesture(gesture: str) bool
Parameters:

gesture (str) – the gesture to test

Returns:

True if the gesture has been active since the last call to this function

Return type:

bool

get_gestures() list
Returns:

The history of gesture. The most recent is listed last

Return type:

list

on_gesture(gesture: str, callback: Callable[str | None]) None

Register a callaback bind to press event

Parameters:
  • gesture (str) – The gesture to bind the callback to

  • callback (Callable[Optional[str]]) – The function to call when the event occurs. When called the gesture will be passed as paramater

class thingz.thingz_accel.Compass

Control Galaxia’s magnetometer

get_x() float
Returns:

the magnetic field value of x axis in uT

Return type:

float

get_y() float
Returns:

the magnetic field value of y axis in uT

Return type:

float

get_values() list
Returns:

the magnetic field values of the 3 axis in a list. Index 0 is X, 1 is Y, 2 is Z

Return type:

list

heading() float
Returns:

the current heading

Return type:

float

calibrate(calibration_time: int, nb_of_samples: int) None

Calibrate the magnetometer. During the calibration the board has to be rotated along the Z axis

Parameters:
  • calibration_time (int) – Time to spend on the calibration, value is in seconds

  • nb_of_samples (int) – Number of sample to take