sjoerd82 / defender-headunit Goto Github PK
View Code? Open in Web Editor NEWVery early development, not suitable for downloading yet!!
Very early development, not suitable for downloading yet!!
Add Keyboard control.
Linked to:
boppreh/keyboard#126
Support saved playlists
Add logging to syslog:
https://docs.python.org/2/library/logging.handlers.html
Now that we move the code into smaller microservices, logging to file deserves some attention. Logging to the same file is not longer feasible, from a file locking p.o.v.
Logging to separate files is useful (better than no logging), but it will lack the context. To understand a situation one would need to piece back together all separate files to really appreciate what happened.
Before closing the issue, make sure that if a future improvement is wanted, to create an issue for that.
Options:
..somehow..
Add hotspot mode, if so configured.
Folder lists keep track of the directory start positions in the playlist, to skip to the next folder.
Generating them may take a few secs, so you don't want to do it too often.
Currently they are saved, but not re-used.
Devise a smart way that minimises the re-creation, and re-use them where possible.
Now that the project is growing, more and more configurable options are starting to pop into existence. Some of which are crucial for playback, such as the correct PulseAudio sink and MPD output.
Remote configuration/setup/bootstrapping becomes more and more important, esp. if a setting cannot be defaulted or auto-detected.
Proposed solution:
-config-tool.py, for R/W on configuration.json
-hu.py may R from configuration.json (and call it for initialization, if the config file is missing)
-A web API (flask?) can call config-tool.py to configure the application (and restart hu.py)
Random button:
normal press:
[Off] <-> normal press<-> [All tracks]
[Random Current Folder] -> [Off]
[Random Current Genre] -> [Off]
long press:
[Off] -> long press -> [Random Current Folder]
[Random Current Folder] -> [Random Current Genre]
S91update, don't just bring down all services and do an update. Only do this if there's something new...
Feedback (GPIO, LED / SFX) to notify long operations (esp. if blocking) are still going on.
Auto-detect on first run.
Implementation options:
ecasound
Pros: Quality?
Cons: Can we update on-the-fly??
pulse
Pros: EQ already build-in. On-The-Fly.
Cons: PA has, so-far, not been easy to control (in 9.0.. try new v11). Quality?
alsa
Pros: on-the-fly
Cons: Add package alsaequal (custom, seems a bit deprecated?). How to control? Quality?
Currently only DSP is supported via a PIPE output in MPD to ECASOUND.
Perhaps a JACK daemon could solve this?
Hopefully resolves the SegFault..
Make the updater configurable to update only "real" releases or also development commits.
Use configuration.json ["daemons"] to stop/start daemons
Old:
If there are new init scripts after an update these need to be started.
Possibly restart all hu-related scripts? (=easiest)
Test the "updated raspberry pi audio driver"
audio_pwm_mode =2
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=136445
Requirement for this is that first we can run without the DAC, see issue #20 .
Implement/Fix
The relative module path ".." doesn't work when the Python script is executed from a different path, i.e from /etc/init.d. Perhaps using the -m switch works (so far didn't really understand the explanations in PEP-338 about this), and/or using .pth files and/or using the site package.
Current workaround: Scripts inject the path to the Python path at startup.
PEP-338
https://www.python.org/dev/peps/pep-0338/
SITE, pth files:
https://docs.python.org/2/library/site.html
Add inotify watchers on SMB and Local media folders (SMB might be tricky).
New/Deleted files must trigger hu.py to update db and playlists, as smart as possible.
hu.py already has a signal for ifup, but haven't figured out yet how to send it from the ifupdown scripts using dbus-send.
WORKAROUND:
As a workaround the cb_ifup() function is plugged in the MPD message system.
mpc sendmessage ifup XXX
mpc sendmessage ifdown XXX
ACTION: figure out the syntax for dbus-send, add it to the ifupdown scripts and remove the workaround.
Ifupdown scripts are here:
/etc/network/if-up.d
/etc/network/if-down.d
Re-Integrate from version 0.1.0a
Version: 0.1.0-777-g39c2807
[ MPD ] DBUS event received: player
[SYSTEM] Detected MPD event: player. Retrieving MPD state.
ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 230, in maybe_handle_message
File "./hu.py", line 441, in cb_mpd_event
status = mpdc.mpc_get_status()
File "/mnt/PIHU_APP/defender-headunit/hu_mpd.py", line 356, in mpc_get_status
self.mpdc.command_list_ok_begin()
File "usr/lib/python2.7/site-packages/mpd.py", line 583, in command_list_ok_begin
File "usr/lib/python2.7/site-packages/mpd.py", line 279, in _write_command
File "usr/lib/python2.7/site-packages/mpd.py", line 259, in _write_line
File "usr/lib/python2.7/socket.py", line 307, in flush
error: [Errno 32] Broken pipe
Support multiple SMB locations as sub-source.
Q. Self-Discovery of Shares or Pre-Configured File with locations?
A. For now, let's use the file approach to keep it simple.
Read from shares list file (similar to streams.txt) -- !PER SSID/NETWORK!.
ATT doesn't toggle back
In /var/log/messages ... something to do with locales and/or unicode
Implement a crossover. Consider ecasound w/ MPD integration.
Hardware: Required is a multi-channel output. Use HDMI (with audio grabber) or a USB soundcard, or something (TODO: figure out what the requirements are). HDMI seems good, as it outputs 24bit.
Requirements: First implement #20.
Sources:
http://rtaylor.sites.tru.ca/2013/06/25/digital-crossovereq-with-open-source-software-howto/
http://www.instructables.com/id/Raspberry-Pi-Music-Server-With-Built-in-Crossover-/
or google: ecasound DSP on raspberry pi
Add infrared control (LIRC?).
Challenge: find a panel mount / flanged IR receiver
Sub-Issues:
-Configuration
-State
-Control
-API
reminder: select wifi mode
Analyze init order
Analyze actual init execution order (seems that this is not necessarily as defined)
Watchdog needs to restart main or any daemon script that may somehow have stopped/crashed.
Create a plugin to output events to GPIO pins.
These pins can be hooked up to a LED or a beeper, etc.
Supported events:
Must be configurable
There are a number of Linux tools available, plan to support all of these, but implement only the one for the D-Link USB FM radio.
Place this function in the global hu_utils package. Parsing would be a simple split by space (?) on:
with open('/proc/mounts','r') as f:
mounts = [line.split()[1] for line in f.readlines()]
Format of /proc/mounts is similar to /etc/fstab
https://linux.die.net/man/5/fstab
Fields:
1: (fs_spec) device
2: (fs_file) mountpoint
3: (fs_vfstype) filesystem
4: (fs_mntops) mount options
5: (fs_freq) determines when to backup, used by dump (ignore)
6: (fs_passno) determines how to check, used by fsck (ignore)
At this time, I think we only need the first two fields.
Create a virtual sink for this? So far, unsuccessful...
Use DBUS to determine if main or daemon scripts are already running.
Goal: Fastest possible resume of audio playback
Do:
@1) /root/S1, /root/S2, /root/S3
@2) idea:
Scripts folder:
contains the init scripts that are part of this custom initialization
init scripts must either be here or in the regular init.d folder, not both
/etc/init.d/scripts/
Customizations:
folders that contain softlinks to the scripts folder, the softlinks can be renamed to change the order of execution of the scripts.
/etc/init.d/locmus/
/etc/init.d/smb/
etc.
ex for smb:
..
S31mpd => S70
S40network => S70
S70headunit => S72
S40bluetooth => S73
..
@3) "QuickPlay", does a "rcS" on the appropriate customization folder, based on the source flag.
/etc/init.d/03quickplay
Sanity checks:
Number of scripts in the scripts folder must be equal to the number of softlinks in the customization OR all scripts must be accounted for in customization.
If sanity check fails, or there is no previously recorded source, we can instead execute the /scripts, in their defined order.
THINK:
Refine more..
THINK:
Currently we have /etc/init.d/controls, but I'm not sure that's the best way fwd.
There are a number of (Python) daemons that need to be executed at various stages in the init
Config options:
- resume track on restart <Y*|N>
- resume track at source change <Y*|N>
*Threshold and Expiry settings (if present) will be applied
Thresholds:
Resume thresholds (for each of the above):
- Min. Track Length (don’t save progress if it’s shorter): (default “30”, if not specified)
- Min. Progress (don’t save progress until after this duration): (default “20”, if not specified)
Expiry/Timeout:
- Expiry/Timeout
Don’t restore progress after has passed. (default “0” (no expiry), if not specified)
THINK:
We could make it so that it can be overridden per source, but I feel this overly complicates things, yet yielding little real-world benefit. Use case: Audio books source, where you definitely want to keep track of progress. In this case perhaps, it could even more useful to save progress for EVERY audio track!
Must be templateable
Bootstrap
There are flask plugins (but is that needed?)
http://getbootstrap.com/
https://pythonhosted.org/Flask-Bootstrap/index.html
Skeleton
Seems very lightweight
http://getskeleton.com/
Foundation
Somewhat lightweight?
https://foundation.zurb.com/sites.html
https://pypi.python.org/pypi/Flask-Foundation
PureCSS
Tiny!
https://purecss.io/
Ink
http://bootzee.com/comparing-css-frameworks
https://www.agriya.com/blog/15-alternatives-bootstrap-foundation-skeleton/
Should resolve the problem with multiple users of the same GPIO pins.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.