From 2e83511edaf9518537cb11587967ef2545ef790d Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Tue, 4 Dec 2018 16:49:28 +0100 Subject: :construction: Add blank LED's on start, and debug pixel-matrix --- src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/compileAndRun') diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py index 8feca0e..e4e355a 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py @@ -29,9 +29,17 @@ class Strip: self.strip.begin() + # Blank out all the LEDs + i = 0 + while True: + self.strip.setPixelColor(i, 0) + i += 1 + self.strip.show() + # Setup matrix + pixelMatrix = Matrix(self.segments, stripConf["matrix"]) try: - pixelMatrix = Matrix(self.segments, stripConf["matrix"]) + print("TESTING") except: print("Something went wrong while setting up your self-defined matrix.") -- cgit v1.2.3 From 35697c7a3d643d02640a00b0ea7f3c892e9ca2c6 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Tue, 4 Dec 2018 16:52:21 +0100 Subject: :construction: Endless loop while turning off LEDs --- src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/compileAndRun') diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py index e4e355a..b7519df 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py @@ -34,6 +34,7 @@ class Strip: while True: self.strip.setPixelColor(i, 0) i += 1 + if (i > self.LED_COUNT): break self.strip.show() # Setup matrix -- cgit v1.2.3 From 7799a9bf44f6afdacb7742768d3da0cce0f06186 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Tue, 4 Dec 2018 16:57:10 +0100 Subject: :construction: Change varname to the correct one --- src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/compileAndRun') diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py index b7519df..e671d42 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py @@ -38,7 +38,7 @@ class Strip: self.strip.show() # Setup matrix - pixelMatrix = Matrix(self.segments, stripConf["matrix"]) + pixelMatrix = Matrix(self.SEGMENTS, stripConf["matrix"]) try: print("TESTING") except: -- cgit v1.2.3 From ec3b7655b3b265cfe0086d7ad20ffa28cfa8629d Mon Sep 17 00:00:00 2001 From: jakobst1n Date: Tue, 4 Dec 2018 16:19:02 +0000 Subject: :sparkles: Matrix is now setting itself up correctly Have bypassed a try-catch for now --- package-lock.json | 44 +++++++++++++++------- .../pythonSupportFiles/LuxcenaNeo/Matrix.py | 8 ++++ .../pythonSupportFiles/LuxcenaNeo/Strip.py | 12 +++--- 3 files changed, 45 insertions(+), 19 deletions(-) (limited to 'src/compileAndRun') diff --git a/package-lock.json b/package-lock.json index ac5f897..8b1b5de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2651,7 +2651,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2672,12 +2673,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2692,17 +2695,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2819,7 +2825,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2831,6 +2838,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2845,6 +2853,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2852,12 +2861,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2876,6 +2887,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2956,7 +2968,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2968,6 +2981,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3053,7 +3067,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3089,6 +3104,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3108,6 +3124,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3151,12 +3168,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -4383,8 +4402,7 @@ "monaco-editor": { "version": "0.14.3", "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.14.3.tgz", - "integrity": "sha512-RhaO4xXmWn/p0WrkEOXe4PoZj6xOcvDYjoAh0e1kGUrQnP1IOpc0m86Ceuaa2CLEMDINqKijBSmqhvBQnsPLHQ==", - "dev": true + "integrity": "sha512-RhaO4xXmWn/p0WrkEOXe4PoZj6xOcvDYjoAh0e1kGUrQnP1IOpc0m86Ceuaa2CLEMDINqKijBSmqhvBQnsPLHQ==" }, "move-concurrently": { "version": "1.0.1", diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py index 0986b45..4a93247 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py @@ -37,6 +37,14 @@ class Matrix: 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): + for y in self.matrix: + thisYLine = "" + for x in y: + thisYLine += str(x) + ( ' ' * (5 - len(str(x))) ) + print(thisYLine) + if __name__ == "__main__": testMatrix = Matrix( diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py index e671d42..4856076 100644 --- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py +++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Strip.py @@ -38,11 +38,11 @@ class Strip: self.strip.show() # Setup matrix - pixelMatrix = Matrix(self.SEGMENTS, stripConf["matrix"]) - try: - print("TESTING") - except: - print("Something went wrong while setting up your self-defined 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.""" @@ -76,7 +76,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): -- cgit v1.2.3 From 1ebbb05edbc89d6b428a9324f00b4f9849f49d97 Mon Sep 17 00:00:00 2001 From: jakobst1n Date: Tue, 4 Dec 2018 21:47:06 +0000 Subject: :construction: Matrix function --- .../pythonSupportFiles/LuxcenaNeo/Matrix.py | 28 +++++++++++++++++----- .../pythonSupportFiles/LuxcenaNeo/Strip.py | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/compileAndRun') 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 [, ] + # 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() -- cgit v1.2.3