diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2018-12-05 19:49:51 +0100 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2018-12-05 19:49:51 +0100 |
commit | 354f5b9b2acf9faa6d8117386c2b6c8e3527ecbf (patch) | |
tree | 3d57f79bafffe5b675f1ffce284c5beaa0f740c8 /src/compileAndRun/pythonSupportFiles | |
parent | 0ce45a7d4ba9b590ae86eee48cb3fe6e8c0ba14b (diff) | |
parent | 1ebbb05edbc89d6b428a9324f00b4f9849f49d97 (diff) | |
download | Luxcena-Neo-354f5b9b2acf9faa6d8117386c2b6c8e3527ecbf.tar.gz Luxcena-Neo-354f5b9b2acf9faa6d8117386c2b6c8e3527ecbf.zip |
Merge remote-tracking branch 'origin/python' into python
Diffstat (limited to 'src/compileAndRun/pythonSupportFiles')
-rw-r--r-- | src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py | 28 | ||||
-rw-r--r-- | src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py | 1 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py index 4a93247..320da02 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py @@ -22,16 +22,27 @@ 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): @@ -39,12 +50,17 @@ class Matrix: 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 += str(x) + ( ' ' * (5 - len(str(x))) ) + 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 4856076..c3a913f 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py @@ -38,6 +38,7 @@ class Strip: self.strip.show() # Setup matrix + print(" * Generating matrix") #try: self.pixelMatrix = Matrix(self.SEGMENTS, stripConf["matrix"]) self.pixelMatrix.dump() |