-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpimpdradio.py
86 lines (68 loc) · 2.69 KB
/
pimpdradio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Raspberry Pi Internet Radio
# using an HD44780 LCD display
# Rotary encoder version 4 x 20 character LCD version
#
# $Id: rradio4.py,v 1.42 2014/08/21 13:33:46 bob Exp $
#
# Author : Bob Rathbone
# Site : http://www.bobrathbone.com
# Author : (2014-2015) Julien Bellion
#
# This program uses Music Player Daemon 'mpd'and it's client 'mpc'
# See http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki
#
# License: GNU V3, See https://www.gnu.org/copyleft/gpl.html
#
# Disclaimer: Software is provided as is and absolutly no warranties are
# implied or given. The authors shall not be liable for any loss or damage
# however caused.
#
import time
import logging
from bottle import route, run, template
# Class imports
from display.lcd_class import Lcd
from utils.config_class import Config
# from encoders.gaugette_class import RotaryEncoder
# from encoders.rotary_class import RotaryEncoder
from encoders.simplerotary_class import RotaryEncoder
from maincontroler_class import MainControler
from controlers.MpdService import MPDService
from controlers.BluetoothDisplay import BluetoothDisplay
config = Config('/etc/pimpdradio.cfg')
logging.basicConfig(filename=config.getLogFile(), level=config.getLogLevel(), format='%(asctime)s - %(levelname)s - %(module)s - %(funcName)s - %(lineno)s - %(message)s')
mpdService = MPDService(config)
tempo = 0.3
lcd = Lcd(config, mpdService)
logging.info('Initializing main controller ...')
mainControler = MainControler(config, lcd, mpdService)
bluetoothDisplay = BluetoothDisplay(config, lcd, mpdService, mainControler)
time.sleep(5)
logging.info('Initializing tuner controls ...')
tunerknob = RotaryEncoder(config.getSwitchMenuUp(),
config.getSwitchMenuDown(),
config.getSwitchMenuButton(),
mainControler.tuner_event)
logging.info('Initializing volume controls ...')
volumeknob = RotaryEncoder(config.getSwitchVolumeUp(),
config.getSwitchVolumeDown(),
config.getSwitchVolumeButton(),
mainControler.volume_event)
mainControler.setReady(True)
previousControler = None
@route('/bluetooth/<action>')
def index(action):
global mainControler, mpdService, previousControler, bluetoothDisplay
if action == "start":
previousControler = mainControler.currentControler
mainControler.setControler(bluetoothDisplay)
mainControler.setReady(True)
elif action == "stop":
mainControler.setControler(previousControler)
mainControler.setReady(True)
return template('<b>Bluetooth {{action}}</b>', action=action)
run(port=8888)
# End of script