Control With buttons or screen?

Thanks for the python script, however the script returns no output and exits immediately when running it.

Any Idea?

I forgot a while :sweat:

This is the updated script. The script does not stop by itself, to stop press control+c.

Thanks @9and3r I have the script working and it is interesting to see the output from the button presses.

one example of the behavior is this:
Volume Down button is pressed and the output shows this (highlighted with red):

I made the edits you suggested by removing
GPIO.IN, pull_up_down=GPIO.PUD_UP

Also can you explain the bouncetime and longpress time?

I keep getting duplicate responses with one quick button press. (seems to have a reaction on button down and button release) Will decreasing the bouncetime remove this error?

I found some errors on the code :sweat:. So here is the updated script (Hope this time is all ok).

I donā€™t see any reason that when you press vol- button previous is triggered. This is quite strange.

If you are having duplicate responses bouncetime can help. It is the time that changes will be ignored so you should increase the value to prevent duplicates.

The script should give you a message when you press a button and another one when you release it.

Longpress

I use the same button for diferent purposes. For example if you make a short press in main button it will play/pause but if you make a long press it will go to menu.

To know if it is a short or long press I save the second you made the press and compare it when you release it. If the difference is bigger than longpress (by default 0.3 second) it will be detected as long press.

Hi @9and3r sorry for the delayed response.

I initially thought that I was having a grounding issue because when I set up the buttons like you specified EX: (pin 17 -> button -> ground) nothing was happening, so I bought a case for my Pi.

When I use the Adafruit T-Cobbler with a breadboard, I only get responses from your script when Iā€™m inserting or removing a cable, but nothing happens when I press a buttonā€¦

I was looking in the logs and saw this suspicious warning:

2015-05-31 16:07:06,534 - WARNING  /usr/local/lib/python2.7/dist-packages/mopidy_ttsgpio/gpio_input_manager.py:29: RuntimeWarning: This channel is already in use, continuing anyway. GPIO.setwarnings(False) to disable warnings.
  GPIO.setup(self.led_pin, GPIO.OUT)

Full logs:

2015-05-31 16:06:57,410 - INFO     Starting Mopidy 0.19.5
2015-05-31 16:06:59,175 - INFO     Loading config from: builtin defaults, /etc/mopidy/extensions.d/spotify.conf, /etc/mopidy/mopidy.conf, command line options
2015-05-31 16:06:59,727 - INFO     Enabled extensions: stream, spotify_tunigo, podcast-gpodder, scrobbler, http-kuechenradio, softwaremixer, moped, websettings, tunein, mopify, spotify, podcast-itunes, local, alarmclock, mpd, http, ttsgpio, dirble, soundcloud, mobile, local-sqlite, youtube, simple-webclient, local-whoosh
2015-05-31 16:06:59,728 - INFO     Disabled extensions: alsamixer, gmusic, somafm, subsonic, internetarchive, musicbox_webclient, podcast, audioaddict
2015-05-31 16:06:59,729 - WARNING  Found alsamixer configuration errors, the extension has been automatically disabled:
2015-05-31 16:06:59,730 - WARNING    alsamixer/control must be set.
2015-05-31 16:06:59,731 - WARNING    alsamixer/card must be set.
2015-05-31 16:06:59,732 - WARNING  Found musicbox_webclient configuration errors, the extension has been automatically disabled:
2015-05-31 16:06:59,732 - WARNING    musicbox_webclient/musicbox unknown config key.
2015-05-31 16:06:59,733 - WARNING  Please fix the extension configuration errors or disable the extensions to silence these messages.
2015-05-31 16:07:05,928 - INFO     Starting Mopidy mixer: SoftwareMixer
2015-05-31 16:07:05,931 - INFO     Mixing using GStreamer software mixing
2015-05-31 16:07:05,936 - INFO     Mixer volume set to 55
2015-05-31 16:07:05,937 - INFO     Starting Mopidy audio
2015-05-31 16:07:05,942 - INFO     Starting Mopidy backends: SpotifyTunigoBackend, TuneInBackend, LocalBackend, StreamBackend, SoundCloudBackend, YoutubeBackend, SpotifyBackend, DirbleBackend
2015-05-31 16:07:06,073 - INFO     Audio output set to "alsasink"
2015-05-31 16:07:06,110 - INFO     Loaded 0 local playlists from /var/lib/mopidy/playlists
2015-05-31 16:07:06,140 - INFO     Loaded 1 local tracks using sqlite
2015-05-31 16:07:06,276 - INFO     Mopidy uses SPOTIFY(R) CORE
2015-05-31 16:07:06,300 - INFO     Starting Mopidy core
2015-05-31 16:07:06,442 - INFO     Starting Mopidy frontends: TtsGpio, MpdFrontend, HttpFrontend, ScrobblerFrontend
2015-05-31 16:07:06,534 - WARNING  /usr/local/lib/python2.7/dist-packages/mopidy_ttsgpio/gpio_input_manager.py:29: RuntimeWarning: This channel is already in use, continuing anyway. GPIO.setwarnings(False) to disable warnings.
  GPIO.setup(self.led_pin, GPIO.OUT)

2015-05-31 16:07:06,545 - INFO     MPD server running at [::ffff:0.0.0.0]:6600
2015-05-31 16:07:06,554 - INFO     HTTP server running at [::ffff:0.0.0.0]:6680
2015-05-31 16:07:06,923 - INFO     Connected to Spotify
2015-05-31 16:07:07,168 - INFO     Scrobbler connected to Last.fm
2015-05-31 16:07:24,847 - INFO     Loaded 114 Spotify playlists

Do you have any idea why Iā€™m not getting any reaction when I press a button using your recommended config?

Thanks,
Lunz

Just in case. Are you sure that the button is connected correctly?

I canā€™t be sure as I canā€™t see well but it seems that you are connecting the legs incorrectly. One cable should be on 28 and the other on 30.

Edit: The warning is a bug on mopidy-ttsgpio if you run mopidy more than once but it should not affect functionality.

Thanks for that. I was playing around with different wire positions before I took the picture

Iā€™ve corrected it to what you suggested and still no luck.

Iā€™m thinking about doing a fresh install to rule everything else out

As you say that you get inputs when the cable is inserted or removed I think that the problem is more related to hardware than software.

Did you try the script with the button to see the output?
If you have a led you can make 3.3v->Button->Led->Ground to be sure that the circuit is working correctly.

My code is based in this tutorial.

If the circuit is working correctly I donā€™t see any other reason to prevent mopidy-ttsgpio to work.

I enjoy the challenge of adding new things to the pi or musicbox and this is one of the best add onā€™s to musicbox Iā€™ve found, thank you for all your work, installed it, connected it up and it worked straight away, with my limited knowledge itā€™s a treat to get something working easily!!
Only thing I wondered about is once the album has been selected, is there a way of turning off the track introduction on every track?

Currently not supported but you can try this:

git clone https://github.com/9and3r/mopidy-ttsgpio.git

(If git is not installed use sudo apt-get install git to install it)

Edit the file frontend.py and remove lines 31 and 32.

cd mopidy-ttsgpio
sudo python setup.py install

This should disable the track announcement.

Glad you liked the extension and good luck!

Brilliant, that did it. Thank you
If you have time I would really appreciate it if you could explain what I have done, Iā€™m doing my best to learn but itā€™s not easy :smile:
If I want to reinstate the track listing would I just do it again and put the lines 31 and 32 back in.

Thanks again

Steve

Mopidy extensions can listen to mopidy events.

In this case mopidy calls the function you just removed when a new track is started and it gives you the track info.

From the info I extract the track name and artist and give the string to the tts.

When you remove that function you say to mopidy that you do not want to be notified when a track is started and nothing will be called when a new track starts.

If you want to recover the default behaviour you can put again the lines (You can also do git reset --hard. This will recover the last commit, so that the lines will be recovered) and install it again.

Thank you - also helped solve another query I had.

9and3r - you said the the Mopidy-TTSGPIO plugin can control with a keyboard ā€¦ by this do you mean a standard USB keyboard ? I have an xbmc remote that emulates a keyboard and would like to use this as a remote for PI music box.

I had a quick look at the config and readme files on github and it didnā€™t seem to mention keyboards, just GPIO.

The keyboard support is not on the plugin.
My message was not very accurate. Keyboard support was planed but not done currently.

Mopidy-Touchscreen has keyboard support as it is already using pygame is easy to detect key presses. I have to check how to detect key presses without pygame to implement it on ttsgpio.

I have followed the discussion for some time now, but i am havin issues installing the plugin by 9and3r with my musicbox piā€¦
If i try to isntall it via pip my pi tells me downloading and extracting and then stops working after some timeā€¦
i have tried it several times now and it does not seem to get betterā€¦

Hi @9and3r,

Iā€™m trying to use your Mopidy-TTSGPIO extension but I actually only need the pause/play button (pin_button_main) function to support the clicky part of a rotary encoder connected to GPIO 17+gournd.

However, it seems that the following configuration lines must be set for the extension to load:
[ttsgpio]
pin_button_main = 17
pin_button_next = 22
pin_button_previous = 23
pin_button_vol_up = 24
pin_button_vol_down = 25
pin_play_led = 18

If I comment out the 5 lines I donā€™t need (some of these GPIO pins are already in use for other things), the extension is automatically disabled. Is there a way to use just the pin_button_main?

Thanks!

Hi.
If you comment the lines on the config Mopidy-TTSGPIO will use default pins (The pins are not disabled).

As a workaround you could comment the lines here (lines 14-35) to disable the buttons you are not using.

Thanks for your reply! But it seems that you pointed to the mopidy-touchscreen extension instead of mopidy-ttsgpio, which I want to use.

So far, I could not get my Musicbox installation to respond to my clicking of the rotary encoder. Maybe I did not connect it correctly, but it seems straightforward: the rotary encoder has 5 terminals (2 on one side, 3 on the other side). The 3 terminals are for the rotary function, so that leaves the 2 left over terminals for the switch function. I connected these to a ground pin and GPIO 17 on my Pi.

Sorry for the late response. My laptop broke this week.

Yes. The link is not correct. This is the correct one. (lines 33-57)

It could be possible that mopidy-ttsgpio is not working because the GPIO pins that is trying to use are already setupby you.