t
This commit is contained in:
parent
fdf4e771ac
commit
21532c1ef8
2 changed files with 19 additions and 2 deletions
|
@ -10,7 +10,7 @@ def defaultPattern(n, t, pv):
|
|||
|
||||
|
||||
class LightStrip:
|
||||
def __init__(self, data_pin=board.D18, string_length=300, brightness=1, pixel_order=neopixel.GRB, max_changes=5):
|
||||
def __init__(self, data_pin=board.D18, string_length=300, brightness=0.7, pixel_order=neopixel.GRB, max_changes=5):
|
||||
self.data_pin = data_pin
|
||||
|
||||
self.np = neopixel.NeoPixel(
|
||||
|
|
19
pattern.py
19
pattern.py
|
@ -21,7 +21,9 @@ this.values = {
|
|||
"g": 0,
|
||||
"b": 0,
|
||||
"tick": 0,
|
||||
"index": 0
|
||||
"index": 0,
|
||||
"fadeval": 0,
|
||||
"fadeinc": True
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +53,20 @@ def mod(target, arg, index):
|
|||
return (target % arg, index)
|
||||
|
||||
|
||||
def fade(target, arg, index):
|
||||
value = this.values['fadeval']
|
||||
if this.values['fadeinc']:
|
||||
value += 1
|
||||
if value >= arg:
|
||||
this.values['fadeinc'] = False
|
||||
else:
|
||||
value -= 1
|
||||
if value <= 0:
|
||||
this.values['fadeinc'] = True
|
||||
this.values['fadeval'] = value
|
||||
return (value, index)
|
||||
|
||||
|
||||
def rand(target, arg, index):
|
||||
return (random.randrange(0, 255), index)
|
||||
|
||||
|
@ -110,6 +126,7 @@ this.instructions = {
|
|||
"MULTIPLY": mult,
|
||||
"DIVIDE": div,
|
||||
"MODULO": mod,
|
||||
"FADE": fade,
|
||||
"RANDOM": rand,
|
||||
"JMP": jmp,
|
||||
"JNZ": jnz,
|
||||
|
|
Loading…
Reference in a new issue