예제 #1
0
    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()
예제 #2
0
def breakup():
    stopAnimations()  # stop animation thread
    showTime = 2.0  # show for 2 seconds
    startTime = time.time()
    while time.time() - startTime < showTime:
        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, 150, 0)
            else:
                ledshim.set_pixel(i, 0, 0, 0)
        ledshim.show()
        time.sleep(0.05)
    ledshim.clear()  # turn off after showTime
    ledshim.show()
예제 #3
0
    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()
예제 #4
0
def on_message(client, userdata, msg):

    data = msg.payload.split(',')
    command = data.pop(0)

    if command == 'clr' and len(data) == 0:
        ledshim.clear()
        ledshim.show()
        return

    if command == 'rgb' and len(data) == 4:
        try:
            pixel = data.pop(0)

            if pixel == '*':
                pixel = None
            else:
                pixel = int(pixel)
                if pixel > 7:
                    print('Pixel out of range: ' + str(pixel))
                    return

            r, g, b = [int(x) & 0xff for x in data]

            print(command, pixel, r, g, b)

        except ValueError:
            print('Malformed command: ' + str(msg.payload))
            return

        if pixel is None:
            for x in range(ledshim.NUM_PIXELS):
                ledshim.set_pixel(x, r, g, b)
        else:
            ledshim.set_pixel(pixel, r, g, b)

        ledshim.show()
        return
예제 #5
0
    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()
예제 #6
0
        pixel_list.pop()
        print('Large rise by: ', diff)
        logging.info('Large rise by: {}'.format(diff))
    elif diff < 0 and diff > -threshold:  # value falls: < 0 and > -(threshold)
        pixel_list.insert(0, fall_1)
        pixel_list.pop()
        print('Small fall by: ', diff)
    elif diff <= -threshold:  # value LARGE FALL: < or = to threshold
        pixel_list.insert(0, fall_2)
        pixel_list.pop()
        print('Large fall by: ', diff)
        logging.info('Large fall by: {}'.format(diff))
    else:  # value unchanged
        pixel_list.insert(0, same)
        pixel_list.pop()
        print('Price unchanged: ', diff)
    prevPrice = nebl_price_in_euros
    #print(pixel_list)
    print()
    return pixel_list


while True:
    ledshim.clear()
    get_NEBL_price_in_btc()
    for num in range(num_of_pixels):
        ledshim.set_pixel(num, *pixel_list[num])
        #print(num, *pixel_list[num]) # Test code
    ledshim.show()
    sleep(wait_secs)
예제 #7
0
    max_value = 255
    if smooth and value <= 1:
        return max_value * value
    else:
        return max_value


def show_info():
    temp = 0
    load = 0
    if mode in ['mixed', 'temp']:
        temp = get_cpu_temperature()
    if mode in ['mixed', 'load']:
        if segmented:
            load = psutil.cpu_percent(percpu=segmented)
        else:
            load = psutil.cpu_percent()
    show_graph(temp, load)


if __name__ == '__main__':
    while True:
        if running:
            show_info()
            time.sleep(interval)
        else:
            break
    # shut off pixels and exit
    output_device.clear()
    output_device.show()
예제 #8
0
 def on_loaded(self):
     logging.info("Fireworks locked and loaded")
     ledshim.clear()
     ledshim.show()
예제 #9
0
 def clear(self):
     ledshim.clear()