sens hat
This commit is contained in:
parent
b2738a2d0d
commit
cbd4870b0c
@ -1,19 +1,21 @@
|
||||
import numpy as np
|
||||
from sense_hat import SenseHat
|
||||
|
||||
|
||||
class SENS_HAT:
|
||||
temp = 0
|
||||
humidity = 0
|
||||
pressure = 0
|
||||
|
||||
roll = 0
|
||||
picht = 0
|
||||
pitch = 0
|
||||
yaw = 0
|
||||
|
||||
x = 0
|
||||
y = 0
|
||||
z = 0
|
||||
|
||||
led_matrix = np.zeros((7, 7, 3), dtype=np.uint8)
|
||||
|
||||
def __init__(self):
|
||||
self.sense = SenseHat()
|
||||
|
||||
@ -26,10 +28,22 @@ class SENS_HAT:
|
||||
acceleration = self.sense.get_accelerometer_raw()
|
||||
|
||||
self.roll = orientation["roll"]
|
||||
self.picht = orientation["picht"]
|
||||
self.pitch = orientation["pitch"]
|
||||
self.yaw = orientation["yaw"]
|
||||
|
||||
self.x = acceleration["x"]
|
||||
self.y = acceleration["y"]
|
||||
self.z = acceleration["z"]
|
||||
|
||||
def led_clear(self):
|
||||
self.sense.clear()
|
||||
|
||||
def led_set_pixel(self, x, y, r, g, b):
|
||||
if not (0 <= x <= 7) or not (0 <= y <= 7):
|
||||
print("x und y müssen zwischen 0 und 7 sein!")
|
||||
return
|
||||
if not (0 <= r <= 255) or not (0 <= g <= 255) or not (0 <= b <= 255):
|
||||
print("r, g, b müssen zwischen 0 und 255 sein!")
|
||||
return
|
||||
|
||||
self.sense.set_pixel(x, y, r, g, b)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user