diff --git a/demo_adc_lightnings.py b/demo_adc_lightnings.py index 54fbb4d..65d2f97 100644 --- a/demo_adc_lightnings.py +++ b/demo_adc_lightnings.py @@ -21,7 +21,7 @@ def capture(tr): print("Capture! ") print(data) np.save("lightning-%s"%now.isoformat(), data) - led.pulse_ms(250, confirm=False) + led.pulse_ms(1000, confirm=False) with gex.Client(gex.TrxRawUSB()) as client: adc = gex.ADC(client, 'adc') diff --git a/demo_neo2.py b/demo_neo2.py index 749aa1a..ab092a5 100644 --- a/demo_neo2.py +++ b/demo_neo2.py @@ -4,12 +4,12 @@ import time with gex.Client(gex.TrxRawUSB()) as client: # Neopixel strip - strip = gex.Neopixel(client, 'neo') + strip = gex.Neopixel(client, 'npx') # Load RGB to the strip strip.load([0xFF0000, 0xFFFF00, 0x00FF00, 0x0000FF, 0xFF00FF]) for i in range(0,255): strip.load([0xFF0000+i, 0xFFFF00, 0x00FF00, 0x0000FF, 0xFF00FF]) - time.sleep(0.001) + time.sleep(0.01) strip.clear() diff --git a/demo_neo3.py b/demo_neo3.py new file mode 100644 index 0000000..ea9aadd --- /dev/null +++ b/demo_neo3.py @@ -0,0 +1,39 @@ +#!/bin/env python3 +import gex +import time + +# this shows a spinny animation on a 30-pixel strip forming a circle + +def draw_comet(buf, index): + r = 0xFF + g = 0x22 + b = 0x00 + steps = 5 + fades = [0.05, 1, 0.5, 0.1, 0.05] + + for i in range(steps): + fade = fades[i] + buf[(len(buf) + index - i)%len(buf)] = \ + round(r * fade)<<16 | \ + round(g * fade)<<8 | \ + round(b * fade) + +with gex.Client(gex.TrxRawUSB()) as client: + # Neopixel strip + strip = gex.Neopixel(client, 'npx') + + markers = [0, 15] + for i in range(1000): + buf = [0]*30 + for j in range(len(markers)): + n = markers[j] + + draw_comet(buf, n) + + n = n + 1 if n < len(buf)-1 else 0 + markers[j] = n + + strip.load(buf) + time.sleep(0.02) + + strip.clear() diff --git a/gex/units/Neopixel.py b/gex/units/Neopixel.py index 6264a80..dd53660 100644 --- a/gex/units/Neopixel.py +++ b/gex/units/Neopixel.py @@ -10,7 +10,7 @@ class Neopixel(gex.Unit): def get_len(self): """ Get the neopixel strip length """ - resp = self._query(0x04) + resp = self._query(10) pp = gex.PayloadParser(resp) return pp.u16() @@ -24,10 +24,10 @@ class Neopixel(gex.Unit): pb = gex.PayloadBuilder(endian='big' if reverse else 'little') for c in colors: pb.u24(c) - self._send(0x01, pb.close(), confirm=confirm) + self._send(1, pb.close(), confirm=confirm) def clear(self, confirm=True): """ Reset the strip (set all to black) """ - self._send(0x00, confirm=confirm) + self._send(0, confirm=confirm)