Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding alternative TLC59711Multi driver implementation #5

Open
wants to merge 43 commits into
base: master
from
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
66aa12c
first starts on multi driver. Not Working.
s-light Nov 16, 2018
80cc33e
fix nameing
s-light Dec 25, 2018
dc0978f
prepared multifile version
s-light Dec 26, 2018
38afd72
make pylama happy :-)
s-light Dec 26, 2018
52fa830
make pylama happy :-)
s-light Dec 26, 2018
f92abd2
debugging...
s-light Jan 5, 2019
6f0eec1
working :joy:
s-light Jan 5, 2019
a60dbdb
fix multichip calculations & remove debugging
s-light Jan 5, 2019
640790e
add timing tests
s-light Jan 5, 2019
d994b23
add lookup variant
s-light Jan 5, 2019
21eccb4
switch to lookup variant
s-light Jan 5, 2019
e6502d9
add set_channel
s-light Jan 5, 2019
6351051
optimize set_pixel
s-light Jan 5, 2019
8b465f0
fix spelling
s-light Jan 5, 2019
a1e754b
optimize speed in set_pixel
s-light Jan 5, 2019
a3c78eb
optimize set_pixel
s-light Jan 5, 2019
3678d59
optimize set_pixel
s-light Jan 5, 2019
849e452
make linter happy
s-light Jan 5, 2019
0589b6d
optimize same more
s-light Jan 5, 2019
c4b398d
fix spelling
s-light Jan 5, 2019
5e3a6e5
added set_pixel_16bit_XXXXX
s-light Jan 5, 2019
4a90e3c
added timing test
s-light Jan 5, 2019
1343d3f
added test for pixel get
s-light Jan 5, 2019
cb52b98
more tests and cleanup
s-light Jan 5, 2019
6a1363b
add set_pixels_all
s-light Jan 5, 2019
5830031
added set_pixel_all_16bit_value
s-light Jan 5, 2019
1d26599
cleanup & change asserts
s-light Jan 5, 2019
748eca7
update
s-light Jan 5, 2019
91bc684
simplified simpletest.py
s-light Jan 5, 2019
3697e48
cleaned up *dev.py
s-light Jan 5, 2019
fd845dd
fixed docu and more cleanup of *dev.py
s-light Jan 5, 2019
4252b1f
made pylint complexity checker happy..
s-light Jan 5, 2019
1f7a36b
more test & clean up
s-light Jan 6, 2019
f3a9888
add bcdata test sketch
s-light Jan 6, 2019
208e77a
update and refine BCData things
s-light Jan 6, 2019
c24ae14
some refines for BC-Data
s-light Jan 6, 2019
186b53e
Merge branch 'master' of https://github.com/adafruit/Adafruit_Circuit…
s-light Jan 6, 2019
6bf3378
fix travis for subfolder.
s-light Jan 6, 2019
ee46c93
make sphinx happy ;-)
s-light Jan 6, 2019
4c93b91
fix linting
s-light Jan 6, 2019
f729757
more linting fixes
s-light Jan 6, 2019
7e42ebc
and more linting / cleaningup...
s-light Jan 6, 2019
4095964
rename internals
s-light Jan 25, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

added test for pixel get

  • Loading branch information
s-light committed Jan 5, 2019
commit 1343d3f5515c5939a0b09e70be59b5d2c4dab906
@@ -682,6 +682,11 @@ def _convert_if_float(cls, value):
value = cls._convert_01_float_to_16bit_integer(value)
return value

def _get_channel_16bit_value(self, channel_index):
return self._get_16bit_value_from_buffer(
self._buffer_index_lookuptable[channel_index],
)

def _set_channel_16bit_value(self, channel_index, value):
# self._set_16bit_value_in_buffer(
# self._buffer_index_lookuptable[channel_index],
@@ -715,6 +720,32 @@ def set_pixel_16bit_value(self, pixel_index, value_r, value_g, value_b):
self._buffer[buffer_start + 0] = (value_r >> 8) & 0xFF
self._buffer[buffer_start + 1] = value_r & 0xFF

def set_pixel_float_value(self, pixel_index, value_r, value_g, value_b):
"""
Set the value for pixel.
This is a Fast UNPROTECTED function:
no error / range checking is done.
:param int pixel_index: 0..(pixel_count)
:param int value_r: 0..1
:param int value_g: 0..1
:param int value_b: 0..1
"""
value_r = int(value_r * 65535)
value_g = int(value_g * 65535)
value_b = int(value_b * 65535)
pixel_start = pixel_index * self.COLORS_PER_PIXEL
buffer_start = self._buffer_index_lookuptable[pixel_start + 0]
self._buffer[buffer_start + 0] = (value_b >> 8) & 0xFF
self._buffer[buffer_start + 1] = value_b & 0xFF
buffer_start = self._buffer_index_lookuptable[pixel_start + 1]
self._buffer[buffer_start + 0] = (value_g >> 8) & 0xFF
self._buffer[buffer_start + 1] = value_g & 0xFF
buffer_start = self._buffer_index_lookuptable[pixel_start + 2]
self._buffer[buffer_start + 0] = (value_r >> 8) & 0xFF
self._buffer[buffer_start + 1] = value_r & 0xFF

def set_pixel_16bit_color(self, pixel_index, value):
"""
Set color for pixel.
@@ -782,13 +813,17 @@ def __getitem__(self, key):
Each value is a 16-bit number from 0-65535.
"""
if 0 <= key < self.pixel_count:
pixel_start = key * self.COLORS_PER_PIXEL
return (
self._get_16bit_value_from_buffer(key + 0),
self._get_16bit_value_from_buffer(key + 2),
self._get_16bit_value_from_buffer(key + 4)
self._get_channel_16bit_value(pixel_start + 0),
self._get_channel_16bit_value(pixel_start + 1),
self._get_channel_16bit_value(pixel_start + 2)
)
else:
raise IndexError("index {} out of range".format(key))
raise IndexError(
"index {} out of range [0..{}]"
"".format(key, self.pixel_count)
)

def __setitem__(self, key, value):
"""
@@ -855,14 +890,14 @@ def __setitem__(self, key, value):
# we change channel order here:
# buffer channel order is blue, green, red
pixel_start = key * self.COLORS_PER_PIXEL
# self._set_16bit_value_in_buffer(
# self._buffer_index_lookuptable[pixel_start + 0],
# self._set_channel_16bit_value(
# pixel_start + 0,
# value[2])
# self._set_16bit_value_in_buffer(
# self._buffer_index_lookuptable[pixel_start + 1],
# self._set_channel_16bit_value(
# pixel_start + 1,
# value[1])
# self._set_16bit_value_in_buffer(
# self._buffer_index_lookuptable[pixel_start + 2],
# self._set_channel_16bit_value(
# pixel_start + 2,
# value[0])
# optimize:
# self._set_16bit_value_in_buffer(
@@ -885,6 +920,9 @@ def __setitem__(self, key, value):
self._buffer[buffer_start + 0] = (value[0] >> 8) & 0xFF
self._buffer[buffer_start + 1] = value[0] & 0xFF
else:
raise IndexError("index {} out of range".format(key))
raise IndexError(
"index {} out of range [0..{}]"
"".format(key, self.pixel_count)
)

##########################################
@@ -82,7 +82,6 @@ def set_all_black():
def set_all(color):
"""Set all Pixel to color."""
for i in range(pixel_count):
# pixels[i // 4][i % 4] = color
pixels[i] = color


@@ -139,16 +138,6 @@ def _test():
print("'pixels[3] = (500, 40500, 1000)'")
time_measurement_call(_test, loop_count)

def _test():
pixels.set_pixel_16bit_value(3, 500, 40500, 1000)
print("'pixels.set_pixel_16bit_value(3, 500, 40500, 1000)'")
time_measurement_call(_test, loop_count)

def _test():
pixels.set_pixel_16bit_color(3, (500, 40500, 1000))
print("'pixels.set_pixel_16bit_color(3, (500, 40500, 1000))'")
time_measurement_call(_test, loop_count)

def _test():
pixels[12] = (0.5, 0.5, 0.5)
print("'pixels[12] = (0.5, 0.5, 0.5)'")
@@ -166,6 +155,37 @@ def _test():
print("'pixels[for 0..{}] = (0.5, 0.5, 0.5)'".format(pixel_count))
time_measurement_call(_test, 10)


def time_measurement_pixels_get():
"""Measure timing pixels get."""
print("pixels get:")

set_all((1, 11, 111))

def _test():
print("[", end="")
for i in range(pixel_count):
print("{}:{}, ".format(i, pixels[i]), end="")
print("]", end="")
print("'print('{}:{}, '.format(i, pixels[i]), end='')'")
time_measurement_call(_test, 1)


def time_measurement_pixels_set2():
"""Measure timing pixels set."""
print("pixels set2:")
loop_count = 1000

def _test():
pixels.set_pixel_16bit_value(3, 500, 40500, 1000)
print("'pixels.set_pixel_16bit_value(3, 500, 40500, 1000)'")
time_measurement_call(_test, loop_count)

def _test():
pixels.set_pixel_16bit_color(3, (500, 40500, 1000))
print("'pixels.set_pixel_16bit_color(3, (500, 40500, 1000))'")
time_measurement_call(_test, loop_count)

def _test():
for i in range(pixel_count):
pixels.set_pixel_16bit_value(i, 500, 40500, 1000)
@@ -175,6 +195,29 @@ def _test():
)
time_measurement_call(_test, 10)

def _test():
for i in range(pixel_count):
pixels.set_pixel_16bit_value(
i,
int(0.1 * 65535),
int(0.5 * 65535),
int(0.9 * 65535)
)
print(
"'pixels.set_pixel_16bit_value(0..{}, f2i 0.1, f2i 0.5, f2i 0.9)'"
"".format(pixel_count)
)
time_measurement_call(_test, 10)

def _test():
for i in range(pixel_count):
pixels.set_pixel_float_value(i, 0.1, 0.5, 0.9)
print(
"'pixels.set_pixel_float_value(0..{}, 0.1, 0.5, 0.9)'"
"".format(pixel_count)
)
time_measurement_call(_test, 10)


def time_measurement_channel_set():
"""Measure timing channel set."""
@@ -235,8 +278,10 @@ def time_measurement():
print("meassure timing:")
time_measurement_pixels_show()
time_measurement_pixels_set()
time_measurement_pixels_set2()
# time_measurement_channel_set()
time_measurement_channel_set_internal()
time_measurement_pixels_get()
set_all((0, 1, 1))

##########################################
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.