removed unused methods

changed fade steps from 30 to 25
This commit is contained in:
Elektrospy 2019-01-20 01:44:31 +01:00
parent 549c1b7e48
commit db36907d64
7 changed files with 4 additions and 37 deletions

View File

@ -42,10 +42,8 @@ except:
class Layer: class Layer:
def __init__(self, new_path): def __init__(self, new_path):
self.path = new_path self.path = new_path
# read png file # read png file and get gray scale map as 3 dimension rgb array
self.png_reader = png.Reader(self.path) self.gray_scale_map_small_direct = png.Reader(self.path).asRGB8()
# gray_scale_map_small = png_reader.read()
self.gray_scale_map_small_direct = self.png_reader.asRGB8()
# get png data from png object # get png data from png object
self.png_width = self.gray_scale_map_small_direct[0] self.png_width = self.gray_scale_map_small_direct[0]
self.png_height = self.gray_scale_map_small_direct[1] self.png_height = self.gray_scale_map_small_direct[1]
@ -56,7 +54,7 @@ class Layer:
self.rgb_buffer_length = (self.png_width * self.png_height) * self.color_values self.rgb_buffer_length = (self.png_width * self.png_height) * self.color_values
self.layer_buffer_current_color = np.zeros(self.color_values, np.uint8) self.layer_buffer_current_color = np.zeros(self.color_values, np.uint8)
self.layer_buffer_array = np.zeros(self.rgb_buffer_length, np.uint8) self.layer_buffer_array = np.zeros(self.rgb_buffer_length, np.uint8)
self.png_image_data_flatten = np.array(self.flatten_rgb_array_from_png(self.png_image_data)) self.png_image_data_flatten = np.array(self.png_image_data).flatten()
# internal event states # internal event states
self.layer_current_event_value = 0 self.layer_current_event_value = 0
self.animation_finished = True self.animation_finished = True
@ -76,7 +74,7 @@ class Layer:
def run_next_fade_color(self): def run_next_fade_color(self):
if not self.animation_finished and self.animation_current_brightness > 0: if not self.animation_finished and self.animation_current_brightness > 0:
# fade rgb values # fade rgb values
self.animation_current_brightness -= 30 self.animation_current_brightness -= 25
# set current layer color brightness to animation brightness # set current layer color brightness to animation brightness
for i in range(3): for i in range(3):
@ -143,19 +141,6 @@ class Layer:
# print("new_color: " + str(current_value) + ":" + str(mapping_value) + "=" + str(new_value)) # print("new_color: " + str(current_value) + ":" + str(mapping_value) + "=" + str(new_value))
return new_value return new_value
# helper method to flatted the png array payload, called only once on init
def flatten_rgb_array_from_png(self, rgb_array):
output_array = np.zeros(self.rgb_buffer_length, np.uint8)
current_value_index = 0
# got over every row of png
for current_row in rgb_array:
# go over value in payload
for current_value in current_row:
# write current value to output array buffer
output_array[current_value_index] = current_value
current_value_index += 1
return output_array
# ------------------------------------ # ------------------------------------
# Websocket event part start # Websocket event part start
@ -290,20 +275,8 @@ def on_open(ws):
# Websocket event part end # Websocket event part end
# ------------------------------------ # ------------------------------------
def get_higher_color_value(value1, value2):
new_value = value2
if value1 > value2:
new_value = value1
return new_value
def merge_layer_arrays(layer_first, layer_second): def merge_layer_arrays(layer_first, layer_second):
return np.maximum(layer_first, layer_second) return np.maximum(layer_first, layer_second)
# output_array = np.zeros(buffer_length, np.uint8)
# for idx in range(0, buffer_length):
# output_array[idx] = get_higher_color_value(layer_first[idx], layer_second[idx])
# return output_array
def get_merged_layers_array(): def get_merged_layers_array():
@ -316,12 +289,6 @@ def get_merged_layers_array():
return output_array return output_array
def millis():
dt = datetime.now()
cur_millis = dt.microsecond / 1000
return int(round((time_.time() * 1000) + int(cur_millis)))
if __name__ == "__main__": if __name__ == "__main__":
buffer_length = Nx * Ny * 3 buffer_length = Nx * Ny * 3
# create layer objects for the lights # create layer objects for the lights

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 B

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 172 B