Add sample scripts.

Currently they need to be in the parent directory, because we do not
install the module in any way.

Also, note the minimal difference between the demo scripts (*_demo.py)
and the actual scripts intended to run on Omnia (the rest)
demo
LEdoian 2 years ago
parent 2bc55ca5d6
commit 89da337407

@ -0,0 +1,30 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
strip = leds.OmniaStrip
def set_leds(br):
for led in strip:
st = led.state
st.brightness = br
st.autonomous = False
led.set(st)
def continuous_brightness_change(start, step, stop, wait):
for x in range(start, stop, step):
set_leds(x)
sleep(wait)
def inhale():
print('inhaling')
continuous_brightness_change(0, 30, 255, .1)
def exhale():
print('exhaling')
continuous_brightness_change(255, -30, 0, .1)
while True:
inhale()
exhale()

@ -0,0 +1,30 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
strip = leds.OmniaStrip
def set_leds(br):
br = max(1, br)
r, g, b = 1, 0, 0
st = leds.LedState(int(r*br), int(g*br), int(b*br), 1, False)
strip.apply([st], leds.PatternFitting.Repeat)
def continuous_brightness_change(start, step, stop, wait):
for x in range(start, stop, step):
set_leds(x)
# sleep(wait)
def inhale():
print('inhaling')
continuous_brightness_change(-30, 1, 128, .02)
def exhale():
print('exhaling')
continuous_brightness_change(128, -1, -30, .02)
while True:
inhale()
exhale()

@ -0,0 +1,31 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
import pygame_demo as demo
strip = demo.my_strip
def set_leds(br):
br = max(1, br)
r, g, b = 1, 0, 0
st = leds.LedState(int(r*br), int(g*br), int(b*br), 1, False)
strip.apply([st], leds.PatternFitting.Repeat)
def continuous_brightness_change(start, step, stop, wait):
for x in range(start, stop, step):
set_leds(x)
# sleep(wait)
def inhale():
print('inhaling')
continuous_brightness_change(-30, 1, 128, .02)
def exhale():
print('exhaling')
continuous_brightness_change(128, -1, -30, .02)
while True:
inhale()
exhale()

@ -0,0 +1,30 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
strip = leds.OmniaStrip
def set_leds(br):
br = max(1, br)
r, g, b = 1, 0.5, 0
st = leds.LedState(int(r*br), int(g*br), int(b*br), 1, False)
strip.apply([st], leds.PatternFitting.Repeat)
def continuous_brightness_change(start, step, stop, wait):
for x in range(start, stop, step):
set_leds(x)
# sleep(wait)
def inhale():
print('inhaling')
continuous_brightness_change(-30, 1, 128, .02)
def exhale():
print('exhaling')
continuous_brightness_change(128, -1, -30, .02)
while True:
inhale()
exhale()

@ -0,0 +1,31 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
import pygame_demo as demo
strip = demo.my_strip
def set_leds(br):
br = max(1, br)
r, g, b = 1, 0.5, 0
st = leds.LedState(int(r*br), int(g*br), int(b*br), 1, False)
strip.apply([st], leds.PatternFitting.Repeat)
def continuous_brightness_change(start, step, stop, wait):
for x in range(start, stop, step):
set_leds(x)
# sleep(wait)
def inhale():
print('inhaling')
continuous_brightness_change(-30, 1, 128, .02)
def exhale():
print('exhaling')
continuous_brightness_change(128, -1, -30, .02)
while True:
inhale()
exhale()

@ -0,0 +1,41 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
import pygame_demo as demo
strip = demo.my_strip
def set_leds(br):
for led in strip:
st = led.state
st.brightness = br
st.autonomous = False
led.set(st)
def continuous_brightness_change(start, step, stop, wait):
for x in range(start, stop, step):
set_leds(x)
sleep(wait)
def inhale():
print('inhaling')
continuous_brightness_change(0, 30, 255, .1)
def exhale():
print('exhaling')
continuous_brightness_change(255, -30, 0, .1)
# Initialize to random colors:
for led in strip:
led.set(leds.LedState(
r = min(255, randint(1,64) * 4),
g = min(255, randint(1,64) * 4),
b = min(255, randint(1,64) * 4),
brightness = 0,
autonomous = False,
))
while True:
inhale()
exhale()

@ -0,0 +1,22 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
strip = leds.LedStrip(leds.omnia_led_order)
def random():
# Víc kvantizované
return randint(1, 4)*64
while True:
for led in strip:
led.set(leds.LedState(
r = random(),
g = random(),
b = random(),
brightness = random(),
autonomous = False,
))
sleep(.25)

@ -0,0 +1,23 @@
#!/usr/bin/python3
from omnia import leds
from random import randint
from time import sleep
import pygame_demo as demo
strip = demo.my_strip
def random():
# Víc kvantizované
return min(255, randint(1, 4)*64)
while True:
for led in strip:
led.set(leds.LedState(
r = random(),
g = random(),
b = random(),
brightness = random(),
autonomous = False,
))
sleep(.25)
Loading…
Cancel
Save