def on_wait(self, agent, t): FALLOFF = 1.9 SCAN_SPEED = 4 # ledshim.set_brightness(0.4) ledshim.set_clear_on_exit() ledshim.clear() ledshim.show() # Buffering start and end time to avoid hitting associations, # deauths, and handshakes since it can bug out the wait cycle time.sleep(1) start_time = time.time() while (time.time() - start_time) < (t - 2): delta = (time.time() - start_time) offset = (math.sin(delta * SCAN_SPEED) + 1) / 2 hue = int(round(offset * 360)) max_val = ledshim.NUM_PIXELS - 1 offset = int(round(offset * max_val)) for x in range(ledshim.NUM_PIXELS): sat = 1.0 val = max_val - (abs(offset - x) * FALLOFF) val /= float(max_val) # Convert to 0.0 to 1.0 val = max(val, 0.0) # Ditch negative values r, g, b = [255, 0, 0] ledshim.set_pixel(x, r, g, b, val / 4) ledshim.show() time.sleep(0.001) ledshim.clear() ledshim.show()
def on_deauthentication(self, agent, access_point, client_station): ledshim.set_clear_on_exit() ledshim.clear() ledshim.show() num = 5 while num >= 0: pixels = random.sample(range(ledshim.NUM_PIXELS), random.randint(1, 5)) for i in range(ledshim.NUM_PIXELS): if i in pixels: ledshim.set_pixel(i, 255, 0, 0) else: ledshim.set_pixel(i, 0, 0, 0) ledshim.show() num -= 1 time.sleep(0.02) ledshim.clear() ledshim.show()
def on_handshake(self, agent, filename, access_point, client_station): ledshim.set_clear_on_exit() ledshim.clear() ledshim.show() num = 20 while num >= 0: pixels = random.sample(range(ledshim.NUM_PIXELS), random.randint(1, 5)) for i in range(ledshim.NUM_PIXELS): if i in pixels: ledshim.set_pixel(i, random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) else: ledshim.set_pixel(i, 0, 0, 0) ledshim.show() num -= 1 time.sleep(0.001) ledshim.clear() ledshim.show()
#!/usr/bin/env python import colorsys import time from sys import exit try: import numpy as np except ImportError: exit( 'This script requires the numpy module\nInstall with: sudo pip install numpy' ) import ledshim ledshim.set_clear_on_exit() def make_gaussian(fwhm): x = np.arange(0, ledshim.NUM_PIXELS, 1, float) y = x[:, np.newaxis] x0, y0 = 3.5, (ledshim.NUM_PIXELS / 2) - 0.5 fwhm = fwhm gauss = np.exp(-4 * np.log(2) * ((x - x0)**2 + (y - y0)**2) / fwhm**2) return gauss while True: for z in list(range(1, 10)[::-1]) + list(range(1, 10)): fwhm = 15.0 / z gauss = make_gaussian(fwhm)
def __init__(self): ledshim.set_clear_on_exit() ledshim.set_brightness(1) self.array = [(0, 0, 0)] * ledshim.NUM_PIXELS
def __init__(self): ledshim.set_clear_on_exit() ledshim.set_brightness(1) self.array = [(0,0,0)] * ledshim.NUM_PIXELS
import sys import ledshim def usage(): print('Usage: {} <r> <g> <b>'.format(sys.argv[0])) sys.exit(1) if len(sys.argv) != 4: usage() # Exit if non integer value. int() will raise a ValueError try: r, g, b = [int(x) for x in sys.argv[1:]] except ValueError: usage() # Exit if any of r, g, b are greater than 255 if max(r, g, b) > 255: usage() print('Setting Blinkt to {r},{g},{b}'.format(r=r, g=g, b=b)) ledshim.set_clear_on_exit(False) ledshim.set_all(r, g, b) ledshim.show()