Skip to content

an alarm clock with a simple audio player and weather forecast

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
COPYING.txt
Notifications You must be signed in to change notification settings

qwertologe/myradio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myradio(1) -- An alarm clock with a simple audio player and weather forecast

SYNOPSIS

myradio [path_to_configfile.ini]

DESCRIPTION

A highly configurable alarm clock with support for playing audio files from your filesystem and weather forecast from forecast.io. All works without X - framebuffer is enough.

Currently it works well with a raspberry and the new released 7 inch touch display - more information. Backlight control works with some flaws - see [KNOWN ISSUES].

You can configure which KV-screens you want to see [CONFIGURATION]. It may be possible, that a screen references another - e.g. 'player' has a link to 'alarm' (alarm settings).

The player works file-based - one reason, why i developed myradio. Support of filetypes depends on gstreamer and his plugins (the second reason).

Until now there are five screens:

  • Player: Main screen with audio player, digital clock, complete alarm view
  • Clock: Analog clock with remaining sleep time
  • Alarm: Alarm settings (two alarms)
  • Weather: Hourly weather forecast for today and tomorrow - powered by forecast.io - if you get an apikey
  • System: The possibility to reboot/shutdown and update 'myradio' (using git)

SCREENSHOTS

If you read this using man: Screenshots are not converted by ronn. Go to GitHub instead.

alarm alarm_snooze clock player weather system

PREREQUISITE

It depends on your configuration. Here is, what i have done for my Raspberry PI:

  • Install Python and Kivy - maybe all steps upto 15 at the time of writing this document; maybe try this newer documentation
  • Install additional required Python packages sudo pip install python-forecastio pytz tzlocal
  • git must be installed (online update)

Weather (for details see [CONFIGURATION])

  • There is no problem if you have no APIKEY but you can't get weather forecast :-)
  • Get your APIKEY
  • Identify your language
  • Determine latitude and longitude

If your commands in myradio.ini use sudo, you must configure it (man sudoers).

As last part you need a myradio.ini. This file is used by myradio to save the alarm settings. Ensure write access is available.

CONFIGURATION

It runs without an initial myradio.ini if you use the stable branch of kivy. Otherwise you must configure at least monofont = RobotoMono-Regular in section [system]. Here follows a description of all configuration settings:

vi myradio.ini # you see the default values with comments here

[alarm]
# path from which the analog clock will randomly pick an alarm file
analog_dir = analog
# same for digital clock
digital_dir = digital
# in how many seconds to alarm again after you have used "snooze"
snooze_seconds = 60

[alarm1]
# alarm settings for alarm1
# ...

[alarm2]
# ...

[weather]
# Determine latitude and longitude http://itouchmap.com/latlong.html
latitude = 52.370235
longitude = 4.903549
# Get your APIKEY http://developer.forecast.io/
apikey =
# Identify your language https://developer.forecast.io/docs/v2#options
language = en

[audio]
# comma-separated list of root directories for your audio files
# use absolute paths - a path with / at the beginning
# environment variables like $HOME get expanded to their values.
dirs = $HOME
# comma-separated list of extensions which will be shown in the player
# and will be used for alarm, too
# it's up to you, to configure your system for these formats (gstreamer)
formats = flac,mp3,ogg
# The side from which we should shorten the file and directory names
# possible values: left, center or right
shorten_from = right

[system]
# for kivy >1.9 stable you can use RobotoMono-Regular
monofont = DroidSansMono
# comma-separated list of screen which will be shown
# you can deactivate and order the screens here
screens = player,clock,weather,alarm,system
# For faster reboot/poweroff consider adding parameter "-f"
reboot = sudo /sbin/reboot &
shutdown = sudo /sbin/halt &
# post_save_cmd will enable a button at the alarm settings
# if you press the button, this command will be executed e.g.:
# sudo mount -o remount,rw /;cp /run/shm/myradio.ini ~; sudo mount -o remount,ro /
post_save_cmd =
# backlight_cmd will be called if you change the brightness
# a simple alternative if your display can be set with xbacklight:
# backlight_cmd = xbacklight -set {}
backlight_cmd = sudo sh -c "echo $(({}*255/100)) >/sys/class/backlight/rpi_backlight/brightness"
# number of seconds to wait until the display is turned off (brightness 0)
# touching the screen will revert the brightness (if possible)
backlight_timeout = 120
# normally a value in percent - but see [KNOWN ISSUES]
backlight_percent = 60

[git]
# should return true if update is available, otherwise false
# an empty check disables update button and check
check_update_cmd = remote=`git ls-remote $(git rev-parse --abbrev-ref @{u} | tr / " ")` || false && test $(git rev-parse HEAD) != $(echo "$remote" | cut -f1)
# pre could be used to remount rw if you use a ro filesystem
pre_update_cmd =
# pre could be used to remount ro if you use a ro filesystem
post_update_cmd =
update_cmd = git merge origin/master

# Short version:

[alarm]
analog_dir = analog
digital_dir = digital
snooze_seconds = 60

[weather]
latitude = 52.370235
longitude = 4.903549
apikey =
language = en

[audio]
dirs = $HOME
formats = flac,mp3,ogg
shorten_from = right

[system]
monofont = DroidSansMono
screens = player,clock,weather,alarm,system
reboot = sudo /sbin/reboot &
shutdown = sudo /sbin/halt &
post_save_cmd =
backlight_cmd = sudo sh -c "echo $(({}*255/100)) >/sys/class/backlight/rpi_backlight/brightness"
backlight_timeout = 120
backlight_percent = 60

[git]
check_update_cmd = remote=`git ls-remote $(git rev-parse --abbrev-ref @{u} | tr / " ")` || false && test $(git rev-parse HEAD) != $(echo "$remote" | cut -f1)
pre_update_cmd =
post_update_cmd =
update_cmd = git merge origin/master

RECOMMENDATIONS

  • Use a network only runlevel or even better: Do not install an X server. It may be possible with Minibian in the future (Jessie will be released soon) or Raspbian network install. This will reduce boot time and the time for software upgrades and at last the writes on your SD-card.

  • Configure your raspberry for read-only operation. This helps if you have temporary power outage and eliminates problems with your SD-card. Use tmpfs for myradio.ini, configure post_save_cmd and consider parameter '-f' for the shutdown/reboot commands.

  • At least use noatime option for your filesystems

  • Have a look at the prerequisites and setup.sh as a starting point

  • If you use a distribution with systemd and have problems mounting a NFS volume timely - here is a solution:

    192.168.178.1:/nfsexport /mnt nfs ro,noatime,nolock,noauto,x-systemd.automount 0 0

KNOWN ISSUES

  • Backlight control is implemented but can only be on or off forum for official 7-inch touch display. Until now /sys/class/backlight/rpi_backlight/brightness can be set to a value from 0 to 255 but a value lower than 128 will turn it off, higher will turn it on. Ensure that the slider is above 50% which will result in a value >= 128. Additional, your touch to activate the brightness can affect a widget (if you hit one).
  • General code cleanup necessary (remove odds and ends from showcase)
  • Code quality is probably not the best - it is my first python and kivy project
  • No unit tests
  • Setting alarms in the next minute is not possible (comparable to cron)
  • Problems arise if you scroll the listview with touch. You can instead scroll it using the slider at the bottom kivy issue 3418

WISH LIST 1

  • Display error messages from external commands

WISH LIST 2

The following are not realizeable for me. Feel free to participate!

  • Maybe volume control, timer in the action bar
  • Icons: hail.png sleet.png wind.png (maybe needed in the future)
  • Themes (change color, iconset) on the fly
  • Nice graphics from an artist :-)
  • Additional KV screens - mine are all finished

KV/Kivy improvements

  • Improve KV layout for better performance (i use it on a Raspberry PI)
  • Device independence to make it useable for other displays
  • Fixes for the Listview problems (doubletab and scrolling with fingers is not useable)

WISH LIST 3

I am not sure if there is really a need for it - but i am interested...

  • Generic settings KV(!) file for all configuration options with on-screen-keyboard - would need to move the remaining configuration variables to properties

EXAMPLES

myradio # normal start with myradio.ini in working dir
myradio /run/shm/myradio.ini # start with specific ini

AUTHOR

Michael Arlt

LICENSE

myRadio - an alarm clock with a simple audio player and weather forecast
Copyright (C) 2015  Michael Arlt, GPL3 or higher - see LICENSE

Used source from Kivy Showcase: MIT

Most icons from gnome-accessibility-themes (HighContrast): presumably GPL 2 or higher

Logo icon based on:

2010-07-20 Black windup alarm clock face by Sun Ladder - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons https://commons.wikimedia.org/wiki/File:2010-07-20_Black_windup_alarm_clock_face.jpg

Analog alarms:

Digital alarms:

THANKS

Thanks to the whole community - especially the task force from #kivy: bionoid, dessant, inclement, kovak, kived, tshirtman and all who i have forgotten.

SEE ALSO

kivy.org

About

an alarm clock with a simple audio player and weather forecast

Resources

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
COPYING.txt

Stars

Watchers

Forks

Releases

No releases published

Packages