Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| lx:pi:sensehat [15.09.2022 23:22] – angelegt Andy Haubenschmid | lx:pi:sensehat [12.11.2022 01:14] (aktuell) – Andy Haubenschmid | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== SenseHat ====== | ====== SenseHat ====== | ||
| + | {{ : | ||
| + | |||
| + | |||
| + | ==== Links ==== | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| + | ==== Python Scripts ==== | ||
| + | |||
| + | <file python laufschrift.py> | ||
| + | # | ||
| + | from sense_hat import SenseHat | ||
| + | sense = SenseHat() | ||
| + | sense.rotation = 180 # Display-Rotation | ||
| + | sense.low_light = True # Dimm LEDs | ||
| + | sense.show_message(" | ||
| + | </ | ||
| + | |||
| + | <file python rollpixel.py> | ||
| + | # | ||
| + | from sense_hat import SenseHat | ||
| + | from time import sleep | ||
| + | |||
| + | # LED an aktueller Position einschalten, | ||
| + | # bisherigen ausschalten | ||
| + | def setLED(x, y): | ||
| + | global oldX, oldY | ||
| + | # LED an alter Position ausschalten ... | ||
| + | sense.set_pixel(oldX, | ||
| + | # und an neuer Position einschalten (rot) und | ||
| + | # diese Position merken | ||
| + | sense.set_pixel(x, | ||
| + | (oldX, oldY) = (x, y) | ||
| + | |||
| + | # Setup | ||
| + | sense = SenseHat() | ||
| + | sense.clear() | ||
| + | sense.rotation = 0 | ||
| + | (x, y) = (4, 4) # Startposition | ||
| + | (oldX, oldY) = (0, 0) # vorige Position | ||
| + | setLED(x, y) | ||
| + | |||
| + | # Event-Loop | ||
| + | print(" | ||
| + | try: | ||
| + | while True: | ||
| + | o = sense.get_orientation() | ||
| + | print(o) | ||
| + | if 20 < o[' | ||
| + | x -= 1 | ||
| + | if 270 < o[' | ||
| + | x += 1 | ||
| + | if 270 < o[' | ||
| + | y -= 1 | ||
| + | if 20 < o[' | ||
| + | y += 1 | ||
| + | # LED an neuer Position einschalten | ||
| + | setLED(x, y) | ||
| + | sleep(0.3) | ||
| + | |||
| + | except KeyboardInterrupt: | ||
| + | sense.clear() | ||
| + | print(" | ||
| + | </ | ||