diff options
author | Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> | 2018-12-06 00:25:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-06 00:25:38 +0100 |
commit | feab369dacc4d74218af426ab4d0e7b61042d109 (patch) | |
tree | 1fede2c10b8d33dc4e3d1639d7aa2a4dd4d22e3c /src/compileAndRun/pythonSupportFiles/LuxcenaNeo | |
parent | 4ffcd88acefa93075c9f00b9324b4233ad593319 (diff) | |
parent | c796729c5f1f0fdb68f26a16de1d4f164bb7d3d6 (diff) | |
download | Luxcena-Neo-feab369dacc4d74218af426ab4d0e7b61042d109.tar.gz Luxcena-Neo-feab369dacc4d74218af426ab4d0e7b61042d109.zip |
Merge pull request #8 from JakobST1n/dev
Dev
Diffstat (limited to 'src/compileAndRun/pythonSupportFiles/LuxcenaNeo')
-rw-r--r-- | src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py | 34 | ||||
-rw-r--r-- | src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py | 20 |
2 files changed, 44 insertions, 10 deletions
diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py index 0986b45..320da02 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py @@ -22,21 +22,45 @@ def getSegmentRange(segments, n): class Matrix: def __init__(self, segments, matrix): - self.matrix = [] + self.matrix = [] # Holds the matrix + self.xLen = 0 # The width of the matrix + self.yLen = len(matrix) # The heigth of the matrix + for yPos in range(len(matrix)): yVal = matrix[yPos] thisY = [] for xPos in range(len(yVal)): - if matrix[yPos][xPos][1] == True: - thisY += reversed(getSegmentRange(segments, matrix[yPos][xPos][0])) - else: - thisY += getSegmentRange(segments, matrix[yPos][xPos][0]) + # This gets the range of segment n + segmentRange = getSegmentRange(segments, matrix[yPos][xPos][0]) + + # This adds the range to the current row's list + # if in the config [<segment_num>, <reversed>] + # reversed == true, revese the list before adding it + thisY += reversed(segmentRange) if matrix[yPos][xPos][1] else segmentRange + + # This just finds the longest row in the matrix + if (len(thisY) > self.xLen): + self.xLen = len(thisY) + self.matrix.append(thisY) def get(self, x, y): """ Return the value of a place in the matrix given x and y coordinates """ return self.matrix[y][x] + + def dump(self): + nSpacers = (self.xLen*6) // 2 - 6 + print( ("=" * nSpacers) + "Matrix dump" + ("=" * nSpacers) ) + + for y in self.matrix: + thisYLine = "" + for x in y: + thisYLine += ( ' ' * (5 - len(str(x))) ) + str(x) + ' ' + print(thisYLine) + + print("=" * (self.xLen*6)) + if __name__ == "__main__": testMatrix = Matrix( diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py index 8feca0e..c3a913f 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py @@ -29,11 +29,21 @@ class Strip: self.strip.begin() + # Blank out all the LEDs + i = 0 + while True: + self.strip.setPixelColor(i, 0) + i += 1 + if (i > self.LED_COUNT): break + self.strip.show() + # Setup matrix - try: - pixelMatrix = Matrix(self.segments, stripConf["matrix"]) - except: - print("Something went wrong while setting up your self-defined matrix.") + print(" * Generating matrix") + #try: + self.pixelMatrix = Matrix(self.SEGMENTS, stripConf["matrix"]) + self.pixelMatrix.dump() + #except: + # print("Something went wrong while setting up your self-defined matrix.") def show(self): """Update the display with the data from the LED buffer.""" @@ -67,7 +77,7 @@ class Strip: """Set a whole segment to the provided red, green and blue color. Each color component should be a value from 0 to 255 (where 0 is the lowest intensity and 255 is the highest intensity).""" - for n in getSegmentRange(self.segments, segment): + for n in getSegmentRange(self.SEGMENTS, segment): self.strip.setPixelColor(n, Color(red, green, blue, white)) def setBrightness(self, brightness): |