Skip to content

Commit e7518c4

Browse files
committed
Use dimming controls to remove flickering.
1 parent af58b2e commit e7518c4

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

awelc.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def battery_flashing(elc):
6161
elc.set_default_animation(DC_LOW)
6262

6363
def set_static(red, green, blue):
64+
set_dim(0)
6465
elc, device = init_device()
6566
apply_action(elc, 0, 0, 0, DURATION_MAX, TEMPO_MIN,
6667
AC_SLEEP, COLOR) # Off on AC Sleep
@@ -82,6 +83,7 @@ def set_static(red, green, blue):
8283
device.reset()
8384

8485
def set_morph(red, green, blue, duration):
86+
set_dim(0)
8587
elc, device = init_device()
8688
apply_action(elc, 0, 0, 0, DURATION_MAX, TEMPO_MIN,
8789
AC_SLEEP, COLOR) # Off on AC Sleep
@@ -103,7 +105,7 @@ def set_morph(red, green, blue, duration):
103105
device.reset()
104106

105107
def remove_animation():
106-
set_static(0,0,0)
108+
set_dim(100)
107109
elc, device = init_device()
108110
elc.remove_animation(AC_SLEEP)
109111
elc.remove_animation(AC_CHARGED)
@@ -114,6 +116,14 @@ def remove_animation():
114116
# elc.remove_animation(DEFAULT_POST_BOOT)
115117
# elc.remove_animation(RUNNING_START)
116118
# elc.remove_animation(RUNNING_FINISH)
117-
elc.get_animation_count()
118-
elc.get_status()
119+
animations = elc.get_animation_count()
120+
while animations != (0,0):
121+
print("Removing unknown animation {}".format(animations[1]))
122+
elc.remove_animation(animations[1])
123+
animations = elc.get_animation_count()
119124
device.reset()
125+
126+
def set_dim(level):
127+
elc, device = init_device()
128+
elc.dim(ZONES,level)
129+
device.reset()

main.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,24 @@ def apply_morph(self):
334334

335335
def remove_animation(self):
336336
awelc.remove_animation()
337+
self.settings.setValue("State", "Off")
337338

338339
# Apply last action when called from system tray
339340
def tray_on(self):
340-
if self.settings.value("Action", "Static Color") == "Static Color":
341-
self.apply_static()
342-
elif self.settings.value("Action", "Static Color") == "Morph":
343-
self.apply_morph()
344-
else: #Off
345-
self.remove_animation()
341+
# if self.settings.value("Action", "Static Color") == "Static Color":
342+
# self.apply_static()
343+
# elif self.settings.value("Action", "Static Color") == "Morph":
344+
# self.apply_morph()
345+
# else: #Off
346+
# self.remove_animation()
347+
awelc.set_dim(0)
346348
self.settings.setValue("State", "On")
347349

350+
348351
def tray_off(self):
349352
# awelc.set_static(0, 0, 0)
350-
awelc.remove_animation()
353+
# awelc.remove_animation()
354+
awelc.set_dim(100)
351355
self.settings.setValue("State", "Off")
352356

353357

0 commit comments

Comments
 (0)