@@ -64,9 +64,6 @@ def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False, brightness=12
64
64
65
65
self ._gamma = gamma
66
66
67
- # Keep track of successful init so we don't call ws2811_fini unecessarily
68
- self ._init_successful = False
69
-
70
67
# Create ws2811_t structure and fill in parameters.
71
68
self ._leds = ws .new_ws2811_t ()
72
69
@@ -97,23 +94,12 @@ def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False, brightness=12
97
94
# Substitute for __del__, traps an exit condition and cleans up properly
98
95
atexit .register (self ._cleanup )
99
96
100
- def __del__ (self ):
101
- # Required because Python will complain about memory leaks
102
- # However there's no guarantee that "ws" will even be set
103
- # when the __del__ method for this class is reached.
104
- if ws != None :
105
- self ._cleanup ()
106
-
107
97
def _cleanup (self ):
108
98
# Clean up memory used by the library when not needed anymore.
109
99
if self ._leds is not None :
110
- if self ._init_successful :
111
- ws .ws2811_fini (self ._leds )
112
-
113
100
ws .delete_ws2811_t (self ._leds )
114
101
self ._leds = None
115
102
self ._channel = None
116
- # Note that ws2811_fini will free the memory used by led_data internally.
117
103
118
104
def setGamma (self , gamma ):
119
105
if type (gamma ) is list and len (gamma ) == 256 :
@@ -130,8 +116,6 @@ def begin(self):
130
116
str_resp = ws .ws2811_get_return_t_str (resp )
131
117
raise RuntimeError ('ws2811_init failed with code {0} ({1})' .format (resp , str_resp ))
132
118
133
- self ._init_successful = True
134
-
135
119
def show (self ):
136
120
"""Update the display with the data from the LED buffer."""
137
121
resp = ws .ws2811_render (self ._leds )
0 commit comments