Skip to content

Commit

Permalink
Add unitled support
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav Hansen committed Aug 29, 2017
1 parent 79766d0 commit d97c701
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 4 deletions.
13 changes: 13 additions & 0 deletions hue-gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,19 @@
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="unitLEDBtn">
<property name="geometry">
<rect>
<x>840</x>
<y>50</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Toggle Unit LED</string>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
Expand Down
16 changes: 16 additions & 0 deletions hue_plus/hue.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def main():
parser_power = subparsers.add_parser('power', help="Control power to the channels")
parser_power.add_argument("state", type=str, help="State (on/off)")

parser_unitled = subparsers.add_parser('unitled', help="Control power to the unit LED")
parser_unitled.add_argument("state", type=str, help="State (on/off)")

parser_profile = subparsers.add_parser('profile', help="Add or remove or apply profiles")
subparsers_profile = parser_profile.add_subparsers(help="The type of profile action", dest='profile_command')

Expand Down Expand Up @@ -136,6 +139,8 @@ def main():
custom(ser, args.gui, args.channel, args.colors, args.mode, args.speed)
elif args.command == 'power':
power(ser, args.channel, args.state)
elif args.command == 'unitled':
unitled(ser, args.state)
elif args.command == 'profile':
if args.profile_command == 'add':
profile_add(args.name)
Expand Down Expand Up @@ -539,6 +544,17 @@ def power(ser, channel, state):
else:
raise InvalidCommand("No such power state")

def unitled(ser, state):
outputs = [70, 0, 192, 0, 0, 0, 0]
if state.lower() == 'on':
outputs[6] = 255
elif state.lower() == 'off':
outputs[5] = 255
else:
raise InvalidCommand("No such unit led state")
ser.write(bytearray(outputs))
ser.read()

def custom(ser, gui, channel, colors, mode, speed):
strips = [strips_info(ser, 1), strips_info(ser, 2)]

Expand Down
4 changes: 4 additions & 0 deletions hue_plus/hue_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ def setupUi(self, MainWindow):
self.label_6.setFont(font)
self.label_6.setWordWrap(True)
self.label_6.setObjectName("label_6")
self.unitLEDBtn = QtWidgets.QPushButton(self.centralwidget)
self.unitLEDBtn.setGeometry(QtCore.QRect(840, 50, 121, 21))
self.unitLEDBtn.setObjectName("unitLEDBtn")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
Expand Down Expand Up @@ -729,4 +732,5 @@ def retranslateUi(self, MainWindow):
self.label.setText(_translate("MainWindow", "Port:"))
self.portTxt.setText(_translate("MainWindow", "/dev/ttyACM0"))
self.label_6.setText(_translate("MainWindow", "Now with support for turning on and off at specific times, audio on Windows, a way to make your own modes, and more!"))
self.unitLEDBtn.setText(_translate("MainWindow", "Toggle Unit LED"))

17 changes: 16 additions & 1 deletion hue_plus/hue_ui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
VERSION="1.4.1"
VERSION="1.4.2"
import sys
from time import sleep
import os
Expand Down Expand Up @@ -125,6 +125,8 @@ def __init__(self):

self.animatedColors = []

self.unitLEDBtn.clicked.connect(self.toggleUnitLED)

self.fixedAdd.clicked.connect(self.fixedAddFunc)
self.fixedDelete.clicked.connect(self.fixedDeleteFunc)
self.breathingAdd.clicked.connect(self.breathingAddFunc)
Expand Down Expand Up @@ -192,6 +194,8 @@ def __init__(self):
self.audioThread = None
self.animatedThread = None

self.unitLED = 'on'

def closeEvent(self, event):
self.checkAudio()
event.accept()
Expand Down Expand Up @@ -247,6 +251,15 @@ def getColors(self, modeList):
return ['FF0000']
return colors

def toggleUnitLED(self):
if self.unitLED == 'on':
self.unitLED = 'off'
else:
self.unitLED = 'on'

with serial.Serial(self.portTxt.text(), 256000) as ser:
hue.unitled(ser, self.unitLED)

def timeDaemon(self):
pre = previous.list_profile()
if 'previous' in pre:
Expand All @@ -265,6 +278,7 @@ def timeDaemon(self):
with serial.Serial(self.portTxt.text(), 256000) as ser:
print("Turning off")
hue.power(ser, 0, 'off')
hue.unitled(ser, 'off')
self.doneOff = True
self.doneOn = False
except serial.serialutil.SerialException:
Expand All @@ -276,6 +290,7 @@ def timeDaemon(self):
with serial.Serial(self.portTxt.text(), 256000) as ser:
print("Turning on")
hue.profile_apply(ser, pre)
hue.unitled(ser, 'on')
self.doneOn = True
self.doneOff = False
except serial.serialutil.SerialException:
Expand Down
2 changes: 1 addition & 1 deletion installer.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Application]
name=hue_plus
version=1.4.1
version=1.4.2
publisher=Gustav Hansen
# How to launch the app - this calls the 'main' function from the 'myapp' package:
entry_point=hue_plus.hue_ui:main
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

setup(name='hue_plus',
version='1.4.1',
version='1.4.2',
description='A utility to control the NZXT Hue+ in Linux',
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.4.2

0 comments on commit d97c701

Please sign in to comment.