Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Turner1200
    replied
    Switch types

    Originally posted by paul-
    Hmm, anyway to replace the mechanical button mechanism with standard push buttons?
    For this project, I really want to preserve the outside and interface of the old radio. While this means in principle keeping the non-momentary original switches (buttons), you make we wonder if there is an indirect way to have the non-momentary switches activate a second set of momentary switches on their way to the GPIO pins, maybe through a time delay circuit or relay? I’ll have to do some reading.

    On the software side, I wonder if I could modify the code that monitors the pins to register a button push if a connection is made via my non-momentary button. It could fire after a fixed time delay if the signal is maintained on specified pin. After a longer delay, if there was no further activity, the pin could be reset so it’s not left floating. Any thoughts on which portion of the source code I would need to look at?

    Alternatively, maybe I could take the idea of a delay / second button and execute it in software. Maybe a script that reacts to a change on pin 1, triggered by my mechanical non-momentary switch, and then momentarily flips a second pin on and off on the Pi, which sbpd could interpret as a button push?

    I’ll try and work through a few possibilities and share any results.

    Leave a comment:


  • paul-
    replied
    Hmm, anyway to replace the mechanical button mechanism with standard push buttons?

    Leave a comment:


  • Turner1200
    replied
    Toggle switches

    Originally posted by paul-
    There is no config for a toggle style switch.

    What do you intend to do with these switches?
    I would like each toggle switch to launch a preset from LMS. Favourite / preset radio station buttons in practice.

    Leave a comment:


  • paul-
    replied
    There is no config for a toggle style switch.

    What do you intend to do with these switches?

    Leave a comment:


  • Turner1200
    replied
    Support for non-toggle buttons

    First of all, thank you to the community that contributes to this forum!

    I have read through all the posts in recent days, and as a result was able to successfully get a pCP up and running with a working instance of the SqueezeButtonPi Daemon allowing me to collect the input from a few simple push-buttons on a breadboard despite having no particular experience with "physical computing".

    I would now like to move beyond the breadboard and replace my prototype push-buttons. I want instead to wire the pCP into an old radio enclosure and use the radio's old 1950s selector buttons. These buttons are mechanical and depressing them shifts a metal contact between two sets of lugs/pins. I am not sure how to capture this action using SBPD and am looking for some help.

    With the breadboard push-buttons, I had wired one end to a GPIO pin and the other to a ground pin on the Raspberry Pi. I can see that depressing the button momentarily closes the contact between the two before the button pops back, breaking the contact. As far as I can tell the default behaviour for SBPD is to read the breaking of the contact as the button comes back up as a "button push" event.

    I've started the daemon with this command to define a button using pin 21.

    sbpd --verbose b,21,CMD1 -f /home/tc/sbpd_commands.cfg

    This works great, but in the radio enclosure with a different style of switch/button, once pushed, the button stays pushed (in a depressed position). The contact is made, but not subsequently broken (unless and until I push a second selector button).

    Is there a command option I can pass to sbpd that will recognize the simple action of making, but not subsequently breaking, the contact on a single pin as a button push event?

    I was hopeful at first that the CMD_LONG option would fire once the specified millisecond period had elapsed, but on testing found again that it only recognizes a button push if I break the contact.

    I was able to get some function going by starting the daemon with the CMD_LONG option, and by flipping the GPIO pin state option to 1 from 0.

    sbpd --verbose b,21,RDO1,2,0,RDO2,1500

    With that command running, I got the following results: 1) pushing the button down to make the contact - no action; 2) disengaging the button to break the contact, no action; and 3) then finally pushing the button down a second time to re-engage the contact - sbpd finally recognized a long button push.

    Still, I'm hopeful there is an alternative way to structure this so that the first time I push down one of the radio enclosure's mode selector buttons and connect the circuit that a button push event can be recognized by sbpd.

    I would really appreciate any ideas or suggestions.

    I've attached an image of the mode selector buttons if it helps to visualize this. The mechanism allows for any one of the 4 mode selector buttons to be engaged at one time. Pushing any of the other three while one is depressed will disengage the previous selection. There is also a fifth "off" button which disengages whichever of the 4 mode selector buttons may potentially be engaged. Click image for larger version

Name:	IMG_3758.jpg
Views:	1
Size:	109.9 KB
ID:	1573244

    Leave a comment:


  • paul-
    replied
    A bit out of scope for this tool. Both squeezelite and jivelite support ir remotes for controlling.

    Leave a comment:


  • mfraser
    replied
    Originally posted by Krazystar
    Self-update:

    I found this https://forums.pimoroni.com/t/issue-...oode-6-3/11875

    I did what they sort of recommended, issuing the pigpiod command with -t 0, which turns the clock from PCM to PWM. This solved all of my previous issues and sound now plays normally across all devices, buttons & encoders work, etc. YAY!

    Note that unlike the user in that post, i don't utilize an IR remote, so that issue is of no impact to me.

    However, i'm not sure if this has other repercussions or was the intended behavior? Someone with more knowledge than me may be able to answer. I just got a little worried when i read the final comment: "I’m thinking the use of any DAC for sound is going to have the same problem, they all use i2s, as far as I know anyway." (and i'm pretty sure the vast majority of the DAC options use i2s).
    Has anyone successfully found an alternative way of receiving IR signals with an external DAC?

    Leave a comment:


  • pille
    replied
    Encoder KY-040

    Hello,
    I am trying to get the encoder KY-040 with SBPD up an running (same encoder as skywalker posted in post #393). As far as I know the encoder hast built in pull-up resistors for SW (switch), DT and CLK. SBPD is running, and I already tried many configurations for gpio ports, with + connected or not, ... . Enoder is recognized by SBPD, LMS Server is found automatically, but when I turn the encoder no output appears in the -v debug screen.

    Code:
    tc@pCP:~$ sbpd -v e,23,22,VOLU,2
    1629728608.6509 6 sbpd.c,316: Options parsing: Set verbose mode
    1629728608.6512 6 sbpd.c,505: Using builtin button configuration
    1629728608.6512 6 control.c,108: Adding Command PLAY: Fragment ["pause"]
    1629728608.6513 6 control.c,108: Adding Command VOL+: Fragment ["button","volup"]
    1629728608.6513 6 control.c,108: Adding Command VOL-: Fragment ["button","voldown"]
    1629728608.6514 6 control.c,108: Adding Command PREV: Fragment ["button","rew"]
    1629728608.6514 6 control.c,108: Adding Command NEXT: Fragment ["button","fwd"]
    1629728608.6514 6 control.c,108: Adding Command POWR: Fragment ["button","power"]
    1629728608.6515 6 GPIO.c,312: Initializing GPIO
    1629728608.6560 6 control.c,406: Rotary encoder defined: Pin 23, 22, Mode: Detent, Fragment:
    ["mixer","volume","%s%d"]
    1629728608.6562 6 discovery.c,385: MAC address found: b8:27:eb:0e:12:87
    1629728608.6563 6 servercomm.c,176: Initializing CURL
    1629728608.6644 6 sbpd.c,264: Starting main loop polling
    1629728608.6648 6 discovery.c,238: Found server E900A8C0. A new address
    1629728608.7656 6 discovery.c,349: discovery packet: port: 9002, name: LogitechMediaServer, uuid: 4c8f7f40-0a39-49da-8038-9f2eef43e701
    1629728608.7658 6 discovery.c,130: Squeezebox control port found: 9002
    1629728608.7658 6 discovery.c,149: Server address found: 192.168.0.233
    My sbpd-script.sh looks like that:
    Code:
    #!/bin/sh
    
    # start pigpiod daemon
    #pigpiod
    #pigpiod -t 1
    pigpiod
    
    # give the daemon a moment to start up before issuing the sbpd command
    sleep 1
    
    # load uinput module, then set the permission to group writable, so you don't need to run sbpd with root permissions
    sudo modprobe uinput
    sudo chmod g+w /dev/uinput
    
    # issue the sbpd command
    sbpd -d -s e,23,22,VOLU,2
    Thank god i also have a "naked" encoder ( https://www.ttelectronics.com/produc...oders/en12-vs/ ) which work like a charm. With the same ports and the same config the KY-040 is not working an the "normal" encoder works very well.

    As far as I read in the feed, some oter users already got KY-040 encoders up an running. I also tried the posted expample configs, but no success. I do not have attached any hat at the moment.

    Any idea where the problem could be ? Maybe the pullup resistors of the KY-040 ?

    Thank you for your help
    pille

    Leave a comment:


  • paul-
    replied
    The gpio version works fine. I found the touch to be way too sensitive. I reverted to using mechanical switches.

    Leave a comment:


  • mfraser
    replied
    Capacitive touch buttons

    Has anyone tried using one of these https://www.adafruit.com/product/1362 with SqueezeButtonPi?
    Looks like it just needs 3V power and then connecting to whichever GPIO you want.
    There is also https://www.adafruit.com/product/198...m/product/1982, but that is I2C.

    Leave a comment:


  • ShaneC80
    replied
    Originally posted by paul-
    Make sure you used the extension provided by pCP. pcp-sbpd.tcz

    curl is a dependency of sbpd, and is loaded if you use our extension.
    that might be the error then. I *think* I (originally) manually loaded sbpd without grabbing the pCP extension. I'll try purging and reinstalling in a bit.

    Leave a comment:


  • paul-
    replied
    Make sure you used the extension provided by pCP. pcp-sbpd.tcz

    curl is a dependency of sbpd, and is loaded if you use our extension.

    Leave a comment:


  • ShaneC80
    replied
    finally have everything laid out on the table, hardware connected, but I think I'm still missing something (and it may be from reading TOO much in the thread).

    Encoder 1 is connected to GPIO 17, GND, GPIO27, with button on GPIO22 and 3.3V
    Encoder 2 is connected to GPIO5, GND, GPIO6, with button on GPIO13 and 3.3V

    script location: ~/spd.sh

    Code:
    #!/bin/sh                                                                                                                                                                                     
                                                                                                                                                                                                  
    # start pigpiod daemon                                                                                                                                                                        
                                                                                                                                                                                                  
    pigpiod                                                                                                                                                                                       
                                                                                                                                                                                                  
    # give the daemon a moment to start up before issuing the sbpd command                                                                                                                        
                                                                                                                                                                                                  
    sleep 1                                                                                                                                                                                       
                                                                                                                                                                                                  
    # load uinput module, then set the permission to group writable, so you don't need to run sbpd with root permissions                                                                          
                                                                                                                                                                                                  
    sudo modprobe uinput                                                                                                                                                                          
                                                                                                                                                                                                  
    sudo chmod g+w /dev/uinput                                                                                                                                                                    
                                                                                                                                                                                                  
    # issue the sbpd command                                                                                                                                                                      
                                                                                                                                                                                                  
    # This command will cause encoder to move selection right or left; Press=Enter; long press=down                                                                                               
                                                                                                                                                                                                  
    sbpd e,17,27,KEY:KEY_LEFT-KEY_RIGHT,4  b,22,KEY:KEY_ENTER,4,0,KEY:KEY_DOWN,500


    I get the following error:


    Code:
    tc@pCP:~$ ./spd.sh 
    2021-06-26 23:43:58 initCheckPermitted: 
    +---------------------------------------------------------+
    |Sorry, you don't have permission to run this program.    |
    |Try running as root, e.g. precede the command with sudo. |
    +---------------------------------------------------------+
    
    
    Can't initialise pigpio library
    sbpd: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
    
    
    tc@pCP:~$ sudo ./spd.sh 
    2021-06-26 23:44:05 initInitialise: Can't lock /var/run/pigpio.pid
    Can't initialise pigpio library
    sbpd: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
    tc@pCP:~$

    Leave a comment:


  • ShaneC80
    replied
    Originally posted by paul-
    Rpi has internal pull-up/down resistors, set by software.

    The safest way to wire the button is to set the resisors as pull-up, and then connect the gpio pin to ground with the button. Do the same with encoders….connect the center to ground.
    Ok, that's what I was leaning toward, but wasn't sure.

    You can still get contacT bounce, but the software has debounce timers in the setup.
    Ditto. Was pretty sure it was accounted for, but not 100%

    Thanks! Now just to get the time to put it together.

    Leave a comment:


  • paul-
    replied
    Rpi has internal pull-up/down resistors, set by software.

    The safest way to wire the button is to set the resisors as pull-up, and then connect the gpio pin to ground with the button. Do the same with encoders….connect the center to ground.

    You can still get contacT bounce, but the software has debounce timers in the setup.

    Leave a comment:

Working...
X
😀
🥰
🤢
😎
😡
👍
👎