Skip to content

Instantly share code, notes, and snippets.

@davidhoness
Last active November 18, 2017 10:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save davidhoness/6a53345441de4be31603746b2db8784e to your computer and use it in GitHub Desktop.
Save davidhoness/6a53345441de4be31603746b2db8784e to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
from sense_hat import *
EN_DIRECTION_UP = 'up'
EN_DIRECTION_DOWN = 'down'
EN_DIRECTION_LEFT = 'left'
EN_DIRECTION_RIGHT = 'right'
EN_DIRECTION_MIDDLE = 'middle'
EN_ACTION_PRESSED = 'pressed'
EN_ACTION_RELEASED = 'released'
EN_ACTION_HELD = 'held'
class SenseStick_en(SenseStick):
def __init__(self):
SenseStick.__init__(self)
def en_wait_for_event(self, en_emptybuffer=False):
return self.wait_for_event(en_emptybuffer)
SenseStick_en.en_get_events = SenseStick_en.get_events
SenseStick_en.en_direction_up = SenseStick_en.direction_up
SenseStick_en.en_direction_down = SenseStick_en.direction_down
SenseStick_en.en_direction_left = SenseStick_en.direction_left
SenseStick_en.en_direction_right = SenseStick_en.direction_right
SenseStick_en.en_direction_middle = SenseStick_en.direction_middle
SenseStick_en.en_direction_any = SenseStick_en.direction_any
class SenseHat_en(SenseHat):
def __init__(self):
SenseHat.__init__(self)
self._stick = SenseStick_en()
####
# LED Matrix
####
def en_set_rotation(self, en_r=0, en_redraw=True):
self.set_rotation(en_r, en_redraw)
def en_flip_h(self, en_redraw=True):
return self.flip_h(en_redraw)
def en_flip_v(self, en_redraw=True):
return self.flip_v(en_redraw)
def en_set_pixels(self, en_pixel_list):
self.set_pixels(en_pixel_list)
def en_set_pixel(self, en_x, en_y, *en_args):
self.set_pixel(en_x, en_y, *en_args)
def en_get_pixel(self, en_x, en_y):
return self.get_pixel(en_x, en_y)
def en_load_image(self, en_file_path, en_redraw=True):
return self.load_image(en_file_path, en_redraw)
def en_clear(self, *en_args):
self.clear(*en_args)
def en_show_message(self, en_text_string, en_scroll_speed=.1, en_text_colour=[255, 255, 255], en_back_colour=[0, 0, 0]):
self.show_message(en_text_string, en_scroll_speed, en_text_colour, en_back_colour)
def en_show_letter(self, en_s, en_text_colour=[255, 255, 255], en_back_colour=[0, 0, 0]):
self.show_letter(en_s, en_text_colour, en_back_colour)
####
# IMU Sensor
####
def en_set_imu_config(self, en_compass_enabled, en_gyro_enabled, en_accel_enabled):
self.set_imu_config(en_compass_enabled, en_gyro_enabled, en_accel_enabled)
# Joystick
SenseHat_en.en_stick = SenseHat_en.stick
# LED matrix
SenseHat_en.en_rotation = SenseHat_en.rotation
SenseHat_en.en_get_pixels = SenseHat_en.get_pixels
SenseHat_en.en_gamma = SenseHat_en.gamma
SenseHat_en.en_gamma_reset = SenseHat_en.gamma_reset
SenseHat_en.en_low_light = SenseHat_en.low_light
# Environmental sensors
SenseHat_en.en_get_humidity = SenseHat_en.get_humidity
SenseHat_en.en_humidity = SenseHat_en.humidity
SenseHat_en.en_get_temperature_from_humidity = SenseHat_en.get_temperature_from_humidity
SenseHat_en.en_get_temperature_from_pressure = SenseHat_en.get_temperature_from_pressure
SenseHat_en.en_get_temperature = SenseHat_en.get_temperature
SenseHat_en.en_temp = SenseHat_en.temp
SenseHat_en.en_temperature = SenseHat_en.temperature
SenseHat_en.en_get_pressure = SenseHat_en.get_pressure
SenseHat_en.en_pressure = SenseHat_en.pressure
# IMU sensor
SenseHat_en.en_get_orientation_radians = SenseHat_en.get_orientation_radians
SenseHat_en.en_orientation_radians = SenseHat_en.orientation_radians
SenseHat_en.en_get_orientation_degrees = SenseHat_en.get_orientation_degrees
SenseHat_en.en_get_orientation = SenseHat_en.get_orientation
SenseHat_en.en_orientation = SenseHat_en.orientation
SenseHat_en.en_get_compass = SenseHat_en.get_compass
SenseHat_en.en_compass = SenseHat_en.compass
SenseHat_en.en_get_compass_raw = SenseHat_en.get_compass_raw
SenseHat_en.en_compass_raw = SenseHat_en.compass_raw
SenseHat_en.en_get_gyroscope = SenseHat_en.get_gyroscope
SenseHat_en.en_gyro = SenseHat_en.gyro
SenseHat_en.en_gyroscope = SenseHat_en.gyroscope
SenseHat_en.en_get_gyroscope_raw = SenseHat_en.get_gyroscope_raw
SenseHat_en.en_gyro_raw = SenseHat_en.gyro_raw
SenseHat_en.en_gyroscope_raw = SenseHat_en.gyroscope_raw
SenseHat_en.en_get_accelerometer = SenseHat_en.get_accelerometer
SenseHat_en.en_accel = SenseHat_en.accel
SenseHat_en.en_accelerometer = SenseHat_en.accelerometer
SenseHat_en.en_get_accelerometer_raw = SenseHat_en.get_accelerometer_raw
SenseHat_en.en_accel_raw = SenseHat_en.accel_raw
SenseHat_en.en_accelerometer_raw = SenseHat_en.accelerometer_raw
@davidhoness
Copy link
Author

An example of a French translation can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment