Working with Tile orientation

The LIFX tile contains an accelerometer that is used to determine what direction is down. This information can then be used by Photons to rotate the 64 hsbk values we give to a tile such that it looks like the Tile is rotated upright.

So for example, if the Tile is rotated to the left, then when we send the hsbk values to the device, we first rotate them to the right.

Photons contains code to make this easy.

class photons_canvas.orientation.Orientation(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)

The different available orientations

FaceDown = 6
FaceUp = 5
RightSideUp = 1
RotatedLeft = 3
RotatedRight = 4
UpsideDown = 2
photons_canvas.orientation.nearest_orientation(x, y, z)

Determine which orientation maps to the provided x, y, z

photons_canvas.orientation.reorient(colors, orientation)

Return the colors in the different order given our orientation


Return the reverse orientation

Useful for mapping current colours into RightSideUp

photons_canvas.orientation.rotated_index(i, orientation)

Give new index for i given our orientation

It is recommended you use the “parts” plan to access this functionality.