Skip to content

Commit

Permalink
Add settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rdoursenaud committed Mar 22, 2021
1 parent 7567fe6 commit 1397e3d
Show file tree
Hide file tree
Showing 15 changed files with 498 additions and 252 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Denon Remote
============

Control Denon Professional DN-500AV surround preamplifier remotely.

![Screenshot](screenshot-v0.3.0.png)

Author: Raphael Doursenaud <[email protected]>
Expand All @@ -9,9 +11,10 @@ License: [GPLv3+](LICENSE)

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

Dependencies:
Fonts used:

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

### Features

Expand Down Expand Up @@ -41,7 +44,7 @@ Dependencies:

#### Controls

- [ ] Setup
- [x] Setup
- [x] IP address
- [ ] Serial port?
- [ ] COM (Windows)
Expand Down Expand Up @@ -83,6 +86,7 @@ Dependencies:
- [ ] Left/Right VolPreset +/-
- [ ] PgUp/PgDwn SrcPreset +/-
- [x] Systray/Taskbar support using [pystray](https://pypi.org/project/pystray/)
- [ ] Only one instance should be allowed

##### Windows executable

Expand Down
4 changes: 3 additions & 1 deletion denonremote.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ block_cipher = None
added_files = [
('denonremote\\fonts', 'fonts'),
('denonremote\\images', 'images'),
('denonremote\\settings', 'settings')
]

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

a = Analysis(['denonremote\\main.py'],
pathex=['denonremote', '.\\venv\\Lib\\site-packages\\pystray'],
Expand Down
9 changes: 7 additions & 2 deletions denonremote/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import kivy.config
from twisted.internet import reactor

from config import RECEIVER_IP, RECEIVER_PORT
from denon.communication import DenonClientFactory


class DenonRemoteApp:
def run(self):
reactor.connectTCP(RECEIVER_IP, RECEIVER_PORT, DenonClientFactory())
# Get from config
# FIXME: or get from arguments
receiver_ip = kivy.config.Config.get('denonremote', 'receiver_ip')
receiver_port = kivy.config.Config.get('denonremote', 'receiver_port')

reactor.connectTCP(receiver_ip, receiver_port, DenonClientFactory())
reactor.run()
22 changes: 0 additions & 22 deletions denonremote/config.py

This file was deleted.

28 changes: 20 additions & 8 deletions denonremote/denon/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,26 @@ class DenonProtocol(LineOnlyReceiver):
delimiter = b'\r'
ongoing_calls = 0 # Delay handling. FIXME: should timeout after 200 ms.

def connectionMade(self):
logger.debug("Connection made")
if self.factory.gui:
self.factory.app.on_connection(self)

def timeoutConnection(self):
logger.debug("Connection timed out")
self.transport.abortConnection()
if self.factory.gui:
self.factory.app.on_timeout()

def sendLine(self, line):
if b'?' in line:
# A request is made. We need to delay the next calls
self.ongoing_calls += 1
logger.debug("Ongoing calls for delay: %s", self.ongoing_calls)
logger.debug("Will send line: %s", line)
if self.ongoing_calls:
delay = 0
if self.ongoing_calls > 0:
delay = self.DELAY * (self.ongoing_calls - 1)
else:
delay = self.DELAY
logger.debug("Will send line: %s in %f seconds", line, delay)
return task.deferLater(reactor, delay=delay,
callable=super().sendLine, line=line)

Expand Down Expand Up @@ -74,10 +84,6 @@ def lineReceived(self, line):
source = receiver.parameter_code
self.factory.app.set_sources(source)

def connectionMade(self):
if self.factory.gui:
self.factory.app.on_connection(self)

def get_power(self):
self.sendLine('PW?'.encode('ASCII'))

Expand Down Expand Up @@ -132,3 +138,9 @@ def __init__(self, app):
import kivy.logger
global logger
logger = kivy.logger.Logger

def clientConnectionFailed(self, connector, reason):
self.app.on_connection_failed(connector, reason)

def clientConnectionLost(self, connector, reason):
self.app.on_connection_lost(connector, reason)
Loading

0 comments on commit 1397e3d

Please sign in to comment.