[ANNOUNCE] SqueezeButtonPi - Tool to use buttons and rotary encoders on a RPi

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pippin
    Senior Member
    • Oct 2007
    • 14809

    [ANNOUNCE] SqueezeButtonPi - Tool to use buttons and rotary encoders on a RPi

    SqueezeButtonPi is a tool some of you might find useful if you are trying to build a Raspberry Pi based Squeezebox player and you want to use various buttons or rotary encoders.

    It's currently a bit limited - only supports playback control commands without feedback (play, pause, power, skip, volume) but it could easily be extended to take server feedback and support things like "favorites" although for the latter someone should take the time to create a "hold" gesture detection for a button, something I didn't have the time for so far.

    One nice feature is that it's able to autodetect a common Squeezebox setup so you often don't need to manually configure the MAC, the server etc. and it can do automatic server switching.

    Main features:
    • Supports buttons and rotary encoders
    • Can be run as a daemon at startup and is fully command-line configurable
    • Automatically detects the MAC address of your RPi (or you can configure it manually)
    • Automatically detects what server your player is connected to and switches the server if your player does so it can be used in multi-server setups without a configuration change
    • can use authenticating servers, although only with manual username/password configuration


    Here's the source code and more documentation:



    Usage:

    Code:
    sbpd [OPTION...] [e,pin1,pin2,CMD,edge] [b,pin,CMD,edge...]
    Options arguments:
    Code:
      
        -A, --address=Server-Address   Set server address. Default: autodetect
        -M, --mac=MAC-Address      Set MAC address of player. Deafult: autodetect
        -p, --password=password    Set password for server. Default: none
        -P, --port=xxxx            Set server control port. Default: autodetect
        -u, --username=user name   Set user name for server. Default: none
        -d, --daemonize            Daemonize
        -k, --kill                 Kill daemon
        -s, --silent               Don't produce output
        -v, --verbose              Produce verbose output
        -?, --help                 Give this help list
            --usage                Give a short usage message
        -V, --version              Print program version
    Non-Option arguments.

    At least one needs to be specified for the daemon to do anything useful
    Arguments are a comma-separated list of configuration parameters:
    Code:
      
        For rotary encoders (one, volume only):
            e,pin1,pin2,CMD[,edge]
                "e" for "Encoder"
                p1, p2: GPIO PIN numbers in BCM-notation
                CMD: Command. Unused for encoders, always VOLM for Volume
                edge: Optional. one of
                      1 - falling edge
                      2 - rising edge
                      0, 3 - both
    
        For buttons: 
            b,pin,CMD[,edge]
                "b" for "Button"
                pin: GPIO PIN numbers in BCM-notation
                CMD: Command. One of:
                    PLAY:   Play/pause
                    PREV:   Jump to previous track
                    NEXT:   Jump to next track
                    VOL+:   Increase volume
                    VOL-:   Decrease volume
                    POWR:   Toggle power state
                edge: Optional. one of
                      1 - falling edge
                      2 - rising edge
                      0, 3 - both
    Last edited by pippin; 2017-02-20, 00:15.
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch
  • kingswindsor
    Senior Member
    • Oct 2013
    • 118

    #2
    with PiCorePlayer?

    Originally posted by pippin
    SqueezeButtonPi is a tool some of you might find useful if you are trying to build a Raspberry Pi based Squeezebox player and you want to use various buttons or rotary encoders.

    It's currently a bit limited - only supports playback control commands without feedback (play, pause, power, skip, volume) but it could easily be extended to take server feedback and support things like "favorites" although for the latter someone should take the time to create a "hold" gesture detection for a button, something I didn't have the time for so far.

    One nice feature is that it's able to autodetect a common Squeezebox setup so you often don't need to manually configure the MAC, the server etc. and it can do automatic server switching.

    Main features:
    • Supports buttons and rotary encoders
    • Can be run as a daemon at startup and is fully command-line configurable
    • Automatically detects the MAC address of your RPi (or you can configure it manually)
    • Automatically detects what server your player is connected to and switches the server if your player does so it can be used in multi-server setups without a configuration change
    • can use authenticating servers, although only with manual username/password configuration


    Here's the source code and more documentation:



    Usage:

    Code:
    sbpd [OPTION...] [e,pin1,pin2,CMD,edge] [b,pin,CMD,edge...]
    Options arguments:
    Code:
      
        -A, --address=Server-Address   Set server address. Default: autodetect
        -M, --mac=MAC-Address      Set MAC address of player. Deafult: autodetect
        -p, --password=password    Set password for server. Default: none
        -P, --port=xxxx            Set server control port. Default: autodetect
        -u, --username=user name   Set user name for server. Default: none
        -d, --daemonize            Daemonize
        -k, --kill                 Kill daemon
        -s, --silent               Don't produce output
        -v, --verbose              Produce verbose output
        -?, --help                 Give this help list
            --usage                Give a short usage message
        -V, --version              Print program version
    Non-Option arguments.

    At least one needs to be specified for the daemon to do anything useful
    Arguments are a comma-separated list of configuration parameters:
    Code:
      
        For rotary encoders (one, volume only):
            e,pin1,pin2,CMD[,edge]
                "e" for "Encoder"
                p1, p2: GPIO PIN numbers in BCM-notation
                CMD: Command. Unused for encoders, always VOLM for Volume
                edge: Optional. one of
                      1 - falling edge
                      2 - rising edge
                      0, 3 - both
    
        For buttons: 
            b,pin,CMD[,edge]
                "b" for "Button"
                pin: GPIO PIN numbers in BCM-notation
                CMD: Command. One of:
                    PLAY:   Play/pause
                    PREV:   Jump to previous track
                    NEXT:   Jump to next track
                    VOL+:   Increase volume
                    VOL-:   Decrease volume
                    POWR:   Toggle power state
                edge: Optional. one of
                      1 - falling edge
                      2 - rising edge
                      0, 3 - both
    Pippin

    Many thanks for posting all this detailed information on the Tivoli radio and software - it's very helpful but I'm stuck on one point. I think you were using PcP in the radio (?) but to install the software needs git and Wiring Pi, I believe.

    I could do it on Raspbian and there are plenty of guides around but as PcP is based on TinyCore, I'm not sure how to install git or the Wiring Pi library, or where to save the SqueezeButtonPi code to. Would you be able to help?
    many thanks

    Comment

    • pippin
      Senior Member
      • Oct 2007
      • 14809

      #3
      Originally posted by kingswindsor
      I could do it on Raspbian and there are plenty of guides around but as PcP is based on TinyCore, I'm not sure how to install git or the Wiring Pi library, or where to save the SqueezeButtonPi code to. Would you be able to help?
      many thanks
      Yes, I should probably also have posted the extensions I used in pCP.
      You can install them as additional modules through the web interface.

      I think what you need is:
      • the compiler and development libraries. That's the module "compiletc.tcz"
      • wiringPi
      • probably libCurl (not 100% sure whether that's included in "compile.tcz"
      • git (if that's not included in "compile.tcz")


      The you can download the whole project via "git clone https://github.com/coolio107/SqueezeButtonPi-Daemon.git" to some folder you create.
      Then go to the main folder (typically "SqueezeButtonPi-Daemon") and just do a "make".

      Important: this needs to be in one of the folders being backed up, e.g. you user folder or you also need to change the list of folders being backed up by pCP. The pCP documentation has details.
      You need to do a backup (again: through the web interface) after you have downloaded and compiled sbpd otherwise it gets deleted on the next powerdown.

      This gives you a file called "sbpd" which you can add to the startup commands in pCP, they also guarantee it's being run as "root" which wiringPi requires, at least in pCP 3.0 (newer versions might have that requirement dropped).
      ---
      learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
      Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
      at penguinlovesmusic.com
      New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

      Comment

      • kingswindsor
        Senior Member
        • Oct 2013
        • 118

        #4
        Originally posted by pippin

        I think what you need is:
        • the compiler and development libraries. That's the module "compiletc.tcz"
        • wiringPi
        • probably libCurl (not 100% sure whether that's included in "compile.tcz"
        • git (if that's not included in "compile.tcz")

        Thanks! I'll have a go and report back but it may not be tonight.

        UPDATE:
        I'm using PcP 3.10 Audio
        - compiletc.tcz installed fine
        - wiringPi installed fine
        - libCurl not listed but curl.tcz is but failed on install
        - git available but failed on install

        Would I have a better chance not using the Audio version and is there any logging I should turn on and view?
        Last edited by kingswindsor; 2017-02-27, 21:58.

        Comment

        • ralphy
          Senior Member
          • Jan 2006
          • 3298

          #5
          Originally posted by kingswindsor
          Thanks! I'll have a go and report back but it may not be tonight.

          UPDATE:
          I'm using PcP 3.10 Audio
          - compiletc.tcz installed fine
          - wiringPi installed fine
          - libCurl not listed but curl.tcz is but failed on install
          - git available but failed on install

          Would I have a better chance not using the Audio version and is there any logging I should turn on and view?
          I've added a test sbpd.tcz package to the beta files area for pcp 3.1x.

          ssh to picoreplayer as tc user and run these commands.

          Code:
          pcp bu  # save pcp config
          
          cd /mnt/mmcblk0p2/tce/optional
          
          wget http://downloads.sourceforge.net/project/picoreplayer/beta/sbpd.tcz.md5.txt
          
          wget http://downloads.sourceforge.net/project/picoreplayer/beta/sbpd.tcz
          
          md5sum sbpd.tcz # make sure the file downloaded correctly
          f0157164d10b86325b38fee0cb8d709e  sbpd.tcz
          
          cat sbpd.tcz.md5.txt # does it match the line above?
          f0157164d10b86325b38fee0cb8d709e  sbpd.tcz
          
          echo "sbpd.tcz" >> /mnt/mmcblk0p2/tce/onboot.lst
          
          pcp rb  # you must reboot!
          You can start /usr/local/sbin/sbpd at boot from the user commands in the the web gui. Adding command line options as needed.
          Last edited by ralphy; 2017-03-02, 13:11. Reason: Updated libwiringpi v2.42 for pi0W support.
          Ralphy

          1-Touch, 5-Classics, 3-Booms, 2-UE Radio
          Squeezebox client builds donations always appreciated.

          Comment

          • pippin
            Senior Member
            • Oct 2007
            • 14809

            #6
            Originally posted by ralphy
            I've added a test sbpd.tcz package to the beta files area for pcp 3.1x.

            ssh to picoreplayer as tc user and run these commands.

            Code:
            pcp bu  # save pcp config
            
            cd /mnt/mmcblk0p2/tce/optional
            
            wget http://downloads.sourceforge.net/project/picoreplayer/beta/sbpd.tcz.md5.txt
            
            wget http://downloads.sourceforge.net/project/picoreplayer/beta/sbpd.tcz
            
            md5sum sbpd.tcz # make sure the file downloaded correctly
            909de67c040e8c41c10ced1949154f7a  sbpd.tcz
            
            cat sbpd.tcz.md5.txt # does it match the line above?
            909de67c040e8c41c10ced1949154f7a  sbpd.tcz
            
            echo "sbpd.tcz" >> /mnt/mmcblk0p2/tce/onboot.lst
            
            pcp rb  # you must reboot!
            You can start /usr/local/sbin/sbpd at boot from the user commands in the the web gui. Adding command line options as needed.
            [emoji41] coolio! Thanks for that!
            ---
            learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
            Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
            at penguinlovesmusic.com
            New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

            Comment

            • kingswindsor
              Senior Member
              • Oct 2013
              • 118

              #7
              Originally posted by ralphy
              I've added a test sbpd.tcz package to the beta files area for pcp 3.1x.

              ssh to picoreplayer as tc user and run these commands.

              Code:
              pcp bu  # save pcp config
              
              cd /mnt/mmcblk0p2/tce/optional
              
              wget http://downloads.sourceforge.net/project/picoreplayer/beta/sbpd.tcz.md5.txt
              
              wget http://downloads.sourceforge.net/project/picoreplayer/beta/sbpd.tcz
              
              md5sum sbpd.tcz # make sure the file downloaded correctly
              909de67c040e8c41c10ced1949154f7a  sbpd.tcz
              
              cat sbpd.tcz.md5.txt # does it match the line above?
              909de67c040e8c41c10ced1949154f7a  sbpd.tcz
              
              echo "sbpd.tcz" >> /mnt/mmcblk0p2/tce/onboot.lst
              
              pcp rb  # you must reboot!
              You can start /usr/local/sbin/sbpd at boot from the user commands in the the web gui. Adding command line options as needed.
              Ralpy

              Thanks for that. I have followed these steps and rebooted but what do I do next?

              Comment

              • pippin
                Senior Member
                • Oct 2007
                • 14809

                #8
                You need to configure sbpd (with the path above) as a startup command in the pCP web interface.
                The parameters you need to set are described above or in the reader file on github
                ---
                learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
                Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
                at penguinlovesmusic.com
                New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

                Comment

                • pippin
                  Senior Member
                  • Oct 2007
                  • 14809

                  #9
                  [ANNOUNCE] SqueezeButtonPi - Tool to use buttons and rotary encoders on a RPi

                  Something like
                  Code:
                   /usr/local/sbin/sbpd -d -s e,23,24,VOLM,0 b,25,PLAY,1
                  This example assumes you are using a rotary encoder connected to the BCM 23 and 24 pins for volume and a button connected to pin BCM 25 for play/pause
                  I believe you don't need -s and -d but they are the safe choice.
                  ---
                  learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
                  Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
                  at penguinlovesmusic.com
                  New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

                  Comment

                  • ralphy
                    Senior Member
                    • Jan 2006
                    • 3298

                    #10
                    I've respun the sbpd.tcz in post #5 to support the pi0W which was added to libwiringpi v2.42 released on March 1st.

                    It's untested at this point. Don't have a pi0W yet.
                    Ralphy

                    1-Touch, 5-Classics, 3-Booms, 2-UE Radio
                    Squeezebox client builds donations always appreciated.

                    Comment

                    • pippin
                      Senior Member
                      • Oct 2007
                      • 14809

                      #11
                      Wow, that's fast
                      Will need to get myself a pi0W, too, are they already available at all?
                      ---
                      learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
                      Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
                      at penguinlovesmusic.com
                      New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

                      Comment

                      • mherger
                        Babelfish's Best Boy
                        • Apr 2005
                        • 24643

                        #12
                        [ANNOUNCE] SqueezeButtonPi - Tool to usebuttons and rotary encoders on a RPi

                        > Will need to get myself a pi0W, too, are they already available at all?

                        The German distributor linked from the Pi website claims to have them.
                        But then I've only seen bundles, like the 800EU bundle for schools...
                        but not the computer alone.

                        --

                        Michael
                        Michael

                        "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
                        (LMS: Settings/Information)

                        Comment

                        • ralphy
                          Senior Member
                          • Jan 2006
                          • 3298

                          #13
                          Originally posted by pippin
                          Will need to get myself a pi0W, too, are they already available at all?
                          You can buy just the board from Canakit in north america, limited to 1 per customer.
                          Ralphy

                          1-Touch, 5-Classics, 3-Booms, 2-UE Radio
                          Squeezebox client builds donations always appreciated.

                          Comment

                          • paul-
                            Senior Member
                            • Jan 2013
                            • 5778

                            #14
                            Originally posted by ralphy
                            You can buy just the board from Canakit in north america, limited to 1 per customer.
                            Ordered mine this afternoon. Supposedly in stock.

                            Ralphy, we should talk about moving wiringpi to dynamic linked....I was going to submit 2.39 to the repo last weekend. Man it's hard to keep up sometimes, I'll repack the 2.42 this weekend.

                            I would keep libcurl and it's dependencies static for now.
                            Last edited by paul-; 2017-03-03, 03:55.
                            piCorePlayer a small player for the Raspberry Pi in RAM.
                            Homepage: https://www.picoreplayer.org

                            Please donate if you like the piCorePlayer

                            Comment

                            • paul-
                              Senior Member
                              • Jan 2013
                              • 5778

                              #15
                              Originally posted by pippin
                              Something like
                              Code:
                               /usr/local/sbin/sbpd -d -s e,23,24,VOLM,0 b,25,PLAY,1
                              This example assumes you are using a rotary encoder connected to the BCM 23 and 24 pins for volume and a button connected to pin BCM 25 for play/pause
                              I believe you don't need -s and -d but they are the safe choice.
                              What is the other side of the button connected to? I played with this over the weekend and couldn't get it to respond. Are you pulling up or pulling down?
                              piCorePlayer a small player for the Raspberry Pi in RAM.
                              Homepage: https://www.picoreplayer.org

                              Please donate if you like the piCorePlayer

                              Comment

                              Working...