From acc8625c563a3b05b1cbfdbc94d39870c7a71b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Wed, 29 Nov 2023 11:05:18 +0100 Subject: jelka --- prog/jelka/jelka_hardware.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 prog/jelka/jelka_hardware.py (limited to 'prog/jelka/jelka_hardware.py') diff --git a/prog/jelka/jelka_hardware.py b/prog/jelka/jelka_hardware.py new file mode 100644 index 0000000..7361ed7 --- /dev/null +++ b/prog/jelka/jelka_hardware.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import jelka_config +from sys import argv +from rpi_ws281x import PixelStrip, Color + +LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!). +LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz) +LED_DMA = 10 # DMA channel to use for generating signal (try 10) +LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest +LED_INVERT = False # True to invert the signal (when using NPN transistor level shift) +LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53 + +luči = LED_COUNT + +strip = PixelStrip(luči, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) +strip.begin() + +def nastavi(luč, barva): + strip.setPixelColor(luč, Color(barva[0], barva[1], barva[2])) + +def izriši(): + strip.show() + +if __name__ == '__main__': + print(argv[0] + "hardware test ...") + i = 0 + try: + while True: + for k in range(luči): + if (i % 2 == 0): + strip.setPixelColor(k, Color(255, 255, 255)) + else: + strip.setPixelColor(k, Color(0, 0, 0)) + strip.show() + time.sleep(0.1) + i += 1 + + except KeyboardInterrupt: + pass -- cgit v1.2.3