aboutsummaryrefslogtreecommitdiff
path: root/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2021-10-11 20:02:04 +0200
committerGitHub <noreply@github.com>2021-10-11 20:02:04 +0200
commitc67531161e56488166a33232f87566309ba8676e (patch)
tree846e59a020e80bea48557d5a06af5728e44961ff /src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
parente6880cd8ccf82d993f222cb14b4860581654acb8 (diff)
parentc1b6eec770b885a9829e1f62bad5cc99389ca429 (diff)
downloadLuxcena-Neo-c67531161e56488166a33232f87566309ba8676e.tar.gz
Luxcena-Neo-c67531161e56488166a33232f87566309ba8676e.zip
Merge pull request #24 from JakobST1n/rebuild
v1.0.0
Diffstat (limited to 'src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py')
-rw-r--r--src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
deleted file mode 100644
index 320da02..0000000
--- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
+++ /dev/null
@@ -1,73 +0,0 @@
-def getSegmentRange(segments, n):
- """ Return a list of all the actual led-numbers in a segment """
- # Sum all the segments prior to the one we are looking for
- i = 0
- start = 0
- while True:
- if i >= n: break
- start += segments[i] # Add number of leds in this segment to the start-index
- i += 1
-
- # Add all numbers in the segment we are looking for to a list
- i = start
- breakPoint = i + segments[n]
- range = []
- while True:
- range.append(i)
- i += 1
- if i >= breakPoint: break
- return range
-
-
-class Matrix:
-
- def __init__(self, segments, 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)):
- # 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(
- [2, 2, 2, 2, 2, 2, 2, 2, 2],
- [
- [[0, False], [1, True], [2, False]],
- [[3, True], [4, False], [5, True]],
- [[6, False], [7, True], [8, False]]
- ]
- )