Skip to content

Commit

Permalink
add ws2811 destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Feb 28, 2016
1 parent cd5797f commit 453e3ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 0 additions & 2 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class Client():

def __init__(self, server):

self.server = server
self.connection = None

Expand Down Expand Up @@ -47,7 +46,6 @@ def recv(self):
print("[!] Error receiving data from server: " + str(e))

def get_state(self):

return self.current_state

def process(self):
Expand Down
11 changes: 6 additions & 5 deletions visuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ def __init__(self):
if self.resp != 0:
raise RuntimeError('ws2811_init failed with code {0}'.format(self.resp))

def set_lights_off(self):
# set all lights to off
for i in range(self.LED_COUNT):
ws.ws2811_led_set(self.channel, i, 0x000000)

def __del__(self):
# Ensure ws2811_fini is called before the program quits.
ws.ws2811_fini(self.leds)
# Example of calling delete function to clean up structure memory. Isn't
# strictly necessary at the end of the program execution here, but is good practice.
ws.delete_ws2811_t(self.leds)

def set_lights_off(self):
# set all lights to off
for i in range(self.LED_COUNT):
ws.ws2811_led_set(self.channel, i, 0x000000)

def update(self, matrix):

if len(matrix) > self.LED_COUNT:
Expand Down

0 comments on commit 453e3ab

Please sign in to comment.