Skip to content

Commit 1397e3d

Browse files
committed
Add settings
1 parent 7567fe6 commit 1397e3d

15 files changed

Lines changed: 498 additions & 252 deletions

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Denon Remote
22
============
33

4+
Control Denon Professional DN-500AV surround preamplifier remotely.
5+
46
![Screenshot](screenshot-v0.3.0.png)
57

68
Author: Raphael Doursenaud <rdoursenaud@gmail.com>
@@ -9,9 +11,10 @@ License: [GPLv3+](LICENSE)
911

1012
Language: [Python](https://python.org) 3
1113

12-
Dependencies:
14+
Fonts used:
1315

1416
- [Unicode Power Symbol](https://unicodepowersymbol.com/) Copyright (c) 2013 Joe Loughry licensed under MIT
17+
- [Free Serif](https://savannah.gnu.org/projects/freefont/) licensed under GPLv3
1518

1619
### Features
1720

@@ -41,7 +44,7 @@ Dependencies:
4144

4245
#### Controls
4346

44-
- [ ] Setup
47+
- [x] Setup
4548
- [x] IP address
4649
- [ ] Serial port?
4750
- [ ] COM (Windows)
@@ -83,6 +86,7 @@ Dependencies:
8386
- [ ] Left/Right VolPreset +/-
8487
- [ ] PgUp/PgDwn SrcPreset +/-
8588
- [x] Systray/Taskbar support using [pystray](https://pypi.org/project/pystray/)
89+
- [ ] Only one instance should be allowed
8690

8791
##### Windows executable
8892

denonremote.spec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ block_cipher = None
99
added_files = [
1010
('denonremote\\fonts', 'fonts'),
1111
('denonremote\\images', 'images'),
12+
('denonremote\\settings', 'settings')
1213
]
1314

1415
dependencies = get_deps_all() # FIXME: minimize dependencies
15-
dependencies['hiddenimports'].append('pystray._win32')
16+
dependencies['hiddenimports'].append(
17+
'pystray._win32') # FIXME: use the hook at https://github.com/moses-palmer/pystray/issues/55
1618

1719
a = Analysis(['denonremote\\main.py'],
1820
pathex=['denonremote', '.\\venv\\Lib\\site-packages\\pystray'],

denonremote/cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import kivy.config
12
from twisted.internet import reactor
23

3-
from config import RECEIVER_IP, RECEIVER_PORT
44
from denon.communication import DenonClientFactory
55

66

77
class DenonRemoteApp:
88
def run(self):
9-
reactor.connectTCP(RECEIVER_IP, RECEIVER_PORT, DenonClientFactory())
9+
# Get from config
10+
# FIXME: or get from arguments
11+
receiver_ip = kivy.config.Config.get('denonremote', 'receiver_ip')
12+
receiver_port = kivy.config.Config.get('denonremote', 'receiver_port')
13+
14+
reactor.connectTCP(receiver_ip, receiver_port, DenonClientFactory())
1015
reactor.run()

denonremote/config.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

denonremote/denon/communication.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,26 @@ class DenonProtocol(LineOnlyReceiver):
2222
delimiter = b'\r'
2323
ongoing_calls = 0 # Delay handling. FIXME: should timeout after 200 ms.
2424

25+
def connectionMade(self):
26+
logger.debug("Connection made")
27+
if self.factory.gui:
28+
self.factory.app.on_connection(self)
29+
30+
def timeoutConnection(self):
31+
logger.debug("Connection timed out")
32+
self.transport.abortConnection()
33+
if self.factory.gui:
34+
self.factory.app.on_timeout()
35+
2536
def sendLine(self, line):
2637
if b'?' in line:
2738
# A request is made. We need to delay the next calls
2839
self.ongoing_calls += 1
2940
logger.debug("Ongoing calls for delay: %s", self.ongoing_calls)
30-
logger.debug("Will send line: %s", line)
31-
if self.ongoing_calls:
41+
delay = 0
42+
if self.ongoing_calls > 0:
3243
delay = self.DELAY * (self.ongoing_calls - 1)
33-
else:
34-
delay = self.DELAY
44+
logger.debug("Will send line: %s in %f seconds", line, delay)
3545
return task.deferLater(reactor, delay=delay,
3646
callable=super().sendLine, line=line)
3747

@@ -74,10 +84,6 @@ def lineReceived(self, line):
7484
source = receiver.parameter_code
7585
self.factory.app.set_sources(source)
7686

77-
def connectionMade(self):
78-
if self.factory.gui:
79-
self.factory.app.on_connection(self)
80-
8187
def get_power(self):
8288
self.sendLine('PW?'.encode('ASCII'))
8389

@@ -132,3 +138,9 @@ def __init__(self, app):
132138
import kivy.logger
133139
global logger
134140
logger = kivy.logger.Logger
141+
142+
def clientConnectionFailed(self, connector, reason):
143+
self.app.on_connection_failed(connector, reason)
144+
145+
def clientConnectionLost(self, connector, reason):
146+
self.app.on_connection_lost(connector, reason)

0 commit comments

Comments
 (0)