Skip to content

Instantly share code, notes, and snippets.

@tyrower
Created August 22, 2017 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyrower/cc7138ef37c30d508fa947a74a9cf955 to your computer and use it in GitHub Desktop.
Save tyrower/cc7138ef37c30d508fa947a74a9cf955 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Previous line sets coding - character set
from sense_hat import *
#French Translation of terms/paramaters for Sense HAT usage
#Traduction Francaise de la terminologie et parametres pour l'utilisation du Sense HAT
EN_HAUT = 'up'
EN_BAS = 'down'
A_GAUCHE = 'left'
A_DROITE = 'right'
AU_MILIEU = 'middle'
ACTION_APPUYE = 'pressed'
ACTION_RELACHE = 'released'
ACTION_MAINTENU = 'held'
class SenseJoystick(SenseStick):
def __init__(self):
SenseStick.__init__(self)
def en_attente_evenement(self, videtampon=False):
return self.wait_for_event(videtampon)
SenseJoystick.lire_evenement = SenseJoystick.get_events
SenseJoystick.en_haut = SenseJoystick.direction_up
SenseJoystick.en_bas = SenseJoystick.direction_down
SenseJoystick.a_gauche = SenseJoystick.direction_left
SenseJoystick.a_droite = SenseJoystick.direction_right
SenseJoystick.au_milieu = SenseJoystick.direction_middle
SenseJoystick.quelconque_direction = SenseJoystick.direction_any
class SenseHat_fr(SenseHat):
def __init__(self):
SenseHat.__init__(self)
self._stick = SenseJoystick()
####
# Matrice de DEL (LED Matrix)
####
def definir_rotation(self, r=0, regenerer=True):
self.set_rotation(r, regenerer)
def reflexion_horizontale(self, regenerer=True):
return self.flip_h(regenerer)
def reflexion_verticale(self, regenerer=True):
return self.flip_v(regenerer)
def definir_pixels(self, liste_pixel):
self.set_pixels(liste_pixel)
def definir_pixel(self, x, y, *args):
self.set_pixel(x, y, *args)
def lire_pixel(self, x, y):
return self.get_pixel(x, y)
def charger_image(self, chemin_fichier, regenerer=True):
return self.load_image(chemin_fichier, regenerer)
def effacer(self, *args):
self.clear(*args)
def afficher_message(self, chaine_de_caracteres, vitesse_defilement=.1, couleur_texte=[255, 255, 255], couleur_fond=[0, 0, 0]):
self.show_message(chaine_de_caracteres, vitesse_defilement, couleur_texte, couleur_fond)
def afficher_lettre(self, s, couleur_texte=[255, 255, 255], couleur_fond=[0, 0, 0]):
self.show_letter(s, couleur_texte, couleur_fond)
####
# Centrale a inertie (IMU)
####
def configurer_imu(self, activer_boussole, activer_gyroscope, activer_accelerometre):
self.set_imu_config(activer_boussole, activer_gyroscope, activer_accelerometre)
# Joystick
SenseHat_fr.joystick = SenseHat_fr.stick
# Matrice DEL
SenseHat_fr.rotation = SenseHat_fr.rotation
SenseHat_fr.lire_pixels = SenseHat_fr.get_pixels
SenseHat_fr.correction_gamma = SenseHat_fr.gamma
SenseHat_fr.reinitialiser_correction_gamma = SenseHat_fr.gamma_reset
SenseHat_fr.faible_luminosite = SenseHat_fr.low_light
# Capteurs environementaux
SenseHat_fr.lire_humidite = SenseHat_fr.get_humidity
SenseHat_fr.humidite = SenseHat_fr.humidity
SenseHat_fr.lire_temp_d_humidite = SenseHat_fr.get_temperature_from_humidity
SenseHat_fr.lire_temp_de_pression = SenseHat_fr.get_temperature_from_pressure
SenseHat_fr.lire_temp = SenseHat_fr.get_temperature
SenseHat_fr.temp = SenseHat_fr.temp
SenseHat_fr.temperature = SenseHat_fr.temperature
SenseHat_fr.lire_pression = SenseHat_fr.get_pressure
SenseHat_fr.en_pression = SenseHat_fr.pressure
# Capteurs IMU
SenseHat_fr.lire_orientation_radians = SenseHat_fr.get_orientation_radians
SenseHat_fr.orientation_radians = SenseHat_fr.orientation_radians
SenseHat_fr.lire_orientation_degrees = SenseHat_fr.get_orientation_degrees
SenseHat_fr.lire_orientation = SenseHat_fr.get_orientation
SenseHat_fr.orientation = SenseHat_fr.orientation
SenseHat_fr.lire_boussole = SenseHat_fr.get_compass
SenseHat_fr.boussole = SenseHat_fr.compass
SenseHat_fr.lire_boussole_raw = SenseHat_fr.get_compass_raw
SenseHat_fr.boussole_raw = SenseHat_fr.compass_raw
SenseHat_fr.lire_gyroscope = SenseHat_fr.get_gyroscope
SenseHat_fr.gyro = SenseHat_fr.gyro
SenseHat_fr.lire_gyroscope = SenseHat_fr.gyroscope
SenseHat_fr.lire_gyroscope_raw = SenseHat_fr.get_gyroscope_raw
SenseHat_fr.gyro_raw = SenseHat_fr.gyro_raw
SenseHat_fr.gyroscope_raw = SenseHat_fr.gyroscope_raw
SenseHat_fr.lire_accelerometre = SenseHat_fr.get_accelerometer
SenseHat_fr.accel = SenseHat_fr.accel
SenseHat_fr.accelerometre = SenseHat_fr.accelerometer
SenseHat_fr.lire_accelerometre_raw = SenseHat_fr.get_accelerometer_raw
SenseHat_fr.accel_raw = SenseHat_fr.accel_raw
SenseHat_fr.accelerometre_raw = SenseHat_fr.accelerometer_raw
@davidhoness
Copy link

Nice work Alan, I noticed line 104 still has an en_ there, but otherwise this is perfect.

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