Skip to content

Commit 866b2bf

Browse files
committed
Fix garbled wheel led state (#4)
1 parent 25ae2e2 commit 866b2bf

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

nuimo_menue/listener.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,17 @@ def attempt_reconnect(self):
100100
self.nuimoMenue.reconnect()
101101

102102
def showRotationState(self, percent):
103+
103104
fullRotationString = str(
104-
" * "
105+
" *** "
105106
" * * "
106107
" * * "
107108
"* *"
108109
"* *"
109110
"* *"
110111
" * * "
111112
" * * "
112-
" * "
113+
" *** "
113114
)
114115
fullRotationIsCircular = True
115116
'''
@@ -148,30 +149,27 @@ def showRotationState(self, percent):
148149

149150
if(percent != 0):
150151
ledsToShow = math.ceil(percent*ledCnt/100)
151-
print("leds:"+str(ledsToShow))
152152
currentRotationString = list()
153153
itCnt = 0
154-
155154
for c in fullRotationString:
155+
column = itCnt%9
156+
row = itCnt // 9
156157
itCnt += 1
157-
if c == "*" and ledsToShow != 0 and (itCnt%9 > 4 or itCnt%9 ==0 or not fullRotationIsCircular):
158+
if c == "*" and ledsToShow != 0 and (not fullRotationIsCircular or column > 4 or row == 0 and column == 4):
158159
ledsToShow -= 1
159160
currentRotationString.append("*")
160161
else:
161162
currentRotationString.append(" ")
162163

163-
itCnt = 0
164164
if fullRotationIsCircular:
165-
first = True
166-
for c in fullRotationString[::-1]:
167-
itCnt += 1
168-
if c == "*" and ledsToShow != 0 and (itCnt%9 > 4 or itCnt%9 ==0):
169-
if(not first):
170-
ledsToShow -= 1
171-
index = int(abs(itCnt-81))
172-
print("print Led:" + str(index))
173-
currentRotationString[index] = "*"
174-
first = False
165+
itCnt = 80
166+
while(itCnt >= 0):
167+
column = itCnt % 9
168+
row = itCnt // 9
169+
if fullRotationString[itCnt] == "*" and ledsToShow != 0 and column <= 4 and not (row == 0 and column == 4):
170+
ledsToShow -= 1
171+
currentRotationString[itCnt] = "*"
172+
itCnt -= 1
175173

176174
matrix = nuimo.LedMatrix("".join(currentRotationString))
177175
self.nuimoMenue.controller.display_matrix(matrix=matrix,fading=True, ignore_duplicates=True)

0 commit comments

Comments
 (0)