DavisNT / mopidy-alarmclock

A Mopidy extension for using it as an alarm clock.
https://pypi.org/project/Mopidy-AlarmClock/
Apache License 2.0
39 stars 14 forks source link

feature request: gpio pwm output #1

Open hschokker opened 8 years ago

hschokker commented 8 years ago

Hello,

Not really an issue, more of a request for addition...

First request moved to Issue #2 Google Calendar integration

Would it be difficult to also include setting a GPIO pin on the raspberry pi to rise a PWM signal slowly over half an hour. Ideally I would like to let 1 PWM pin rise from 0 to 100% (yellow "sun"light) over 15 minutes starting half an hour before the alarm, then have a second PWM pin rise from 0 to 100% (bright white light) over 15 minutes. After that it is really time to wake up so then the alarm (music) can start. If it is also possible to set an extra pin to low/high standard and flipped while pwm output is given than it is possible to use a relay to shut off AC power to the lights while they are not used. (saving power)

If all this could be included it would make for a fantastic wakeup light. :)

DavisNT commented 8 years ago

Thanks for the ideas!

I have split this issue (see #2 for Google Calendar integration).

My first priority is enhanced scheduler.

Most likely this will be implemented as ability to run command lines upon each alarm (I need to think how to make configuration simple and elastic).

hschokker commented 8 years ago

Hello Davis,

Thank you for the reply. A friend of mine and I might get together next weekend and have a look at the code ourselves. I am not experienced with python but he is so we might be able to contribute a little.

Kind regards, Hendrik Schokker

Op 27 okt. 2015 om 22:27 heeft Dāvis Mošenkovs notifications@github.com het volgende geschreven:

Thanks for the ideas!

I have split this issue (see #2 for Google Calendar integration).

My first priority is enhanced scheduler.

Most likely this will be implemented as ability to run command lines upon each alarm (I need to think how to make configuration simple and elastic).

— Reply to this email directly or view it on GitHub.

DavisNT commented 8 years ago

Great!

I believe the best option would be creating a new application/script that does the GPIO stuff (e.g. by using https://pypi.python.org/pypi/RPi.GPIO).

That new application/script could be run from Mopidy-AlarmClock as a command line app (it would be great if you could clone this repo and track your changes in GitHub).

Regarding GPIO PWM tool as a separate application/script/project: I think implementing too specific GPIO logic in AlarmClock would be unpractical (instead allowing AlarmClock to run configurable command lines before/during alarm would be very practical and extensible). Another, even cooler, approach would be implementing GPIO PWM in AlarmClock and making it fully configurable (i.e. adding a configurable GPIO manipulation engine to the AlarmClock :cool: :sunglasses:). I can imagine a string with some kind of commands, like W-1800:-4:~3,50,5:W120:~3,50,25:W120:~3,50,45:W120:~3,50,65:W120:~3,50,85:W120:+3 that would mean start 1800 seconds before the alarm; switch off GPIO 4; PWM GPIO 3 at 50 Hz with duty cycle 5; wait 120 seconds; PWM GPIO 3 at 50 Hz with duty cycle 25; wait 120 seconds; PWM GPIO 3 at 50 Hz with duty cycle 45; wait 120 seconds; PWM GPIO 3 at 50 Hz with duty cycle 65; wait 120 seconds; PWM GPIO 3 at 50 Hz with duty cycle 85; wait 120 seconds; switch GPIO 3 on.

Br, Davis

michaellunzer commented 8 years ago

using a guide from Adafruit: https://learn.adafruit.com/neopixels-on-raspberry-pi?view=all#software you can learn to control a LED strip. It only works with a 1st gen raspberry pi.

I've taken their code and made a web page to input alarm times and also control a Bluetooth lightbulb. http://michaellunzer.com/lunzpi/lunrise/

I agree with Davis that if we can congfigure the alarm clock to run a configurable command (ex: sudo python /home/pi/path/to/script.py) then this would allow for more configuration .... like running a LED strip and then turning on my bluetooth controlled lightbulb when the alarm goes off!

hschokker commented 8 years ago

We (@FSX and I) started working on a script for controlling GPIO as described by Davis. Unfortunately we spend most of the day trying to get rpi.gpio working. In the end we tried it on a fresh raspbian installation and it worked right away. Turns out something in the musicbox distro thwarts the functionality of the 'rpi.gpio' module. Any ideas what this could be?

DavisNT commented 8 years ago

@warcow I don't know what exactly breaks rpi.gpio on Pi MusicBox (IMHO unfortunately Pi MusicBox has tons of technical/quality issues, however it's much better from the technical point of view (and more mature) than RuneAudio). I think its worth reporting Pi MusicBox issues on their GitHub! May be it's worth updating Raspbian and kernel of Pi MusicBox by:

apt-get update
apt-get -y dist-upgrade
apt-get -y install url wget rpi-update ca-certificates
SKIP_WARNING=1 rpi-update
sed -i 's/#\?blacklist r8188eu/#blacklist r8188eu/g' /etc/modprobe.d/* 
michaellunzer commented 8 years ago

Hi @DavisNT, How is the overhaul coming along? I think it would be better to set a specific python script to run when an alarm goes off rather than trying to integrate too much into the default alarm app.

Thoughts?

dylanbruinsma commented 7 years ago

@DavisNT what is the progress on implementing the pwm and google calender function?