RPiSense package

Submodules

RPiSense.Colors module

class RPiSense.Colors.Colors(order=('H', 'L', 'S'), ascending=True)[source]

Bases: object

Keep a list of colors organized and sorted. You can select colors by name, by index number, and even at random.

Parameters:
  • order – (array_like) This defines the hierarchy of field names when sorting. See the colors.csv file for information about these names.
  • ascending – (boolean) Sorting can either be ascending or descending.
fetch(key, mode='rgb')[source]

Select a color at random.

Parameters:
  • key – (string) The name of the color to find.
  • mode – (‘string’) This is a 3-character description for the color category to return. Valid options are ‘rgb’ (red, green, blue), ‘hsv’ (hue, saturation, value), and ‘HLS’ (HUE, LUMINOSITY, SATURATION).
Returns:

  • abc (tuple) – Three 8-bit values for the color.

random(low=-1, high=-1, mode='rgb')[source]

Select a color at random.

Parameters:
  • low – (integer) The lowest index of the array to use. If low=-1, this defaults to the first index.
  • high – (integer) The highest index of the array to use. If high=-1, this defaults to the last index.
  • mode – (‘string’) This is a 3-character description for the color category to return. Valid options are ‘rgb’ (red, green, blue), ‘hsv’ (hue, saturation, value), and ‘HLS’ (HUE, LUMINOSITY, SATURATION).
Returns:

  • name (string) – The name of the color.
  • abc (tuple) – Three 8-bit values for the color.

randomColor(low=-1, high=-1, mode='rgb')[source]

Select a color at random.

Parameters:
  • low – (integer) The lowest index of the array to use. If low=-1, this defaults to the first index.
  • high – (integer) The highest index of the array to use. If high=-1, this defaults to the last index.
  • mode – (‘string’) This is a 3-character description for the color category to return. Valid options are ‘rgb’ (red, green, blue), ‘hsv’ (hue, saturation, value), and ‘HLS’ (HUE, LUMINOSITY, SATURATION).
Returns:

  • abc (tuple) – Three 8-bit values for the color.

randomName(low=-1, high=-1, mode='rgb')[source]

Select a color at random.

Parameters:
  • low – (integer) The lowest index of the array to use. If low=-1, this defaults to the first index.
  • high – (integer) The highest index of the array to use. If high=-1, this defaults to the last index.
  • mode – (‘string’) This is a 3-character description for the color category to return. Valid options are ‘rgb’ (red, green, blue), ‘hsv’ (hue, saturation, value), and ‘HLS’ (HUE, LUMINOSITY, SATURATION).
Returns:

  • name (string) – The name of the color.
  • abc (tuple) – Three 8-bit values for the color.

RPiSense.Compass module

class RPiSense.Compass.Compass(sense, fg=(255, 0, 0), bg=(0, 0, 255))[source]

Bases: object

Display the direction of North on the LED matrix.

Parameters:
  • sense – (SenseHat instance) A reference to the SenseHat API
  • fg – (tuple) The three 8-bit color values to use for a dot.
  • bg – (list) The three 8-bit color values to use for a circle.
Update()[source]

Refresh the LED matrix according to its current orientation.

RPiSense.Convert module

RPiSense.Convert.C2F(C)[source]

Convert Celsius to Fahrenheit

Parameters:C – (float) The temperature in Celsius.
Returns:
  • F (float) – The temperature in Fahrenheit.
RPiSense.Convert.mbar2inHg(mbar)[source]

Convert millibars to inches of mercury.

Parameters:mbar – (float) The pressure in millibars.
Returns:
  • inHg (float) – The pressure in inches of mercury.

RPiSense.Level module

class RPiSense.Level.Level(sense, fg=(255, 255, 255), scale=30)[source]

Bases: object

Display a white dot in the LED matrix to mimic the behavior of a bubble in a leveller.

Parameters:
  • sense – (SenseHat instance) A reference to the SenseHat API
  • fg – (tuple) The three 8-bit color values to use for the bubble.
  • scale – (integer) The sensitivity to tilting. Higher values are more sensitive.
Update()[source]

Refresh the LED matrix according to its current tilt.

RPiSense.MakeyJoy module

class RPiSense.MakeyJoy.MakeyJoy(sense, makey=False)[source]

Bases: object

Return a direction of input from either the joystick or the keyboard.

Parameters:
  • sense – (SenseHat instance) A reference to the SenseHat API
  • makey – (boolean) Use Makey Makey (or keyboard) arrows instead of the Sense HAT joystick.
GetEvent()[source]

Get the event and intepret it as a direction.

Returns:
  • direction (string) – The arrow event, i.e. ‘up’, ‘down’, ‘left’, or ‘right.

RPiSense.RepeatMe module

class RPiSense.RepeatMe.RepeatMe(sense, time=0.5, makey=False)[source]

Bases: object

Play a game of Repeat After Me. A square will appear on the Sense HAT LED matrix. Press the joystick in the direction of the square. The game will continue adding to the sequence as long as you pick the right direction. Get the sequence right and the display turns green. Get the sequence wrong and the display turns red and you have to start over.

Parameters:
  • sense – (SenseHat instance) A reference to the SenseHat API
  • time – (float) The amount of time to display each entry in the sequence.
  • makey – (boolean) Use Makey Makey (or keyboard) arrows instead of the Sense HAT joystick.
Next()[source]

Get the next entry in the sequence and test the input.

Module contents