Home of the Squeezebox™ & Transporter® network music players.
Page 24 of 27 FirstFirst ... 142223242526 ... LastLast
Results 231 to 240 of 269
  1. #231
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    1,269
    Could this be related?

  2. #232
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    2,174
    There is a command line utility, but that works using an extra daemon running. You can read and set pins directly from a shell, there is no need for external commands.

    https://raspberrypi-aa.github.io/session2/bash.html
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  3. #233
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    1,269
    Quote Originally Posted by paul- View Post
    You can read and set pins directly from a shell, there is no need for external commands.

    https://raspberrypi-aa.github.io/session2/bash.html
    Perfect, thank you.

  4. #234
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    2,174
    A few updates.

    pigpio library is interesting, but I was using it sort of wrong.....here is a new sbpd binary, its dynamically linked now.

    https://dl.dropboxusercontent.com/s/...r26t8ii35/sbpd

    Requirements:
    • pigpio.tcz - library and tools extension
    • First start pigpiod with root access. This self daemonizes, and there are no command line options.
    • Then run sbpd as you normally would, except note the change in encoder setup. I've added a detent mode, which will only increment based on a detent. (Assuming most encoders are 4 steps per physical detent) This really smooths out the enocder increments.


    Code:
    For rotary encoders (one, volume only):
        e,pin1,pin2,CMD[,mode]
            "e" for "Encoder"
            p1, p2: GPIO PIN numbers in BCM-notation
            CMD: Command. one of.
                        VOLU for Volume
                        TRAC for Prev/Next track
            mode: Optional. one of
                    0 - Detent mode - Assumes 1 dial click is 4 steps.
                    1 - Step mode (default)

    To your last question, the pigpio extension includes a program called pigs which is a command line interface to the gpio. It's a bit clunky, but you can set and read pins through this command.....it requires the pigpiod to be running.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  5. #235
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    1,269
    Quote Originally Posted by paul- View Post
    A few updates.

    pigpio library is interesting, but I was using it sort of wrong.....here is a new sbpd binary, its dynamically linked now.

    https://dl.dropboxusercontent.com/s/...r26t8ii35/sbpd

    Requirements:
    • pigpio.tcz - library and tools extension
    • First start pigpiod with root access. This self daemonizes, and there are no command line options.
    • Then run sbpd as you normally would, except note the change in encoder setup. I've added a detent mode, which will only increment based on a detent. (Assuming most encoders are 4 steps per physical detent) This really smooths out the enocder increments.


    Code:
    For rotary encoders (one, volume only):
        e,pin1,pin2,CMD[,mode]
            "e" for "Encoder"
            p1, p2: GPIO PIN numbers in BCM-notation
            CMD: Command. one of.
                        VOLU for Volume
                        TRAC for Prev/Next track
            mode: Optional. one of
                    0 - Detent mode - Assumes 1 dial click is 4 steps.
                    1 - Step mode (default)
    Thanks Paul. Just back from a weekend away and I've been trying this out. I installed pigpiod.tcz from the piCorePlayer repository, and I included the command to start it as the first line of my sbpd script that is called at boot as a User Command from the [Tweaks] page.

    Then I downloaded your latest sbpd from your dropbox link, copied it into my home directory and changed its permissions to 755 so that I could execute it from a shell.

    All the buttons work exactly as before, as does the rotary encoder when called with mode 1.

    When I call the encoder with mode 0 it's working much more uniformly, but not exactly as I expected from your description. I was expecting a volume increment of 4 for every click of the encoder, but instead I'm getting an increment of 1 for every two encoder clicks. I guess my encoder is not the same as yours. Could you perhaps allow the user to define their encoder's number of steps per click as part of the mode 0 call?

    Quote Originally Posted by paul- View Post
    To your last question, the pigpio extension includes a program called pigs which is a command line interface to the gpio. It's a bit clunky, but you can set and read pins through this command.....it requires the pigpiod to be running.
    I ended up using the methods described in your earlier link:
    Code:
    # Export pin to userspace
    if [ ! -e /sys/class/gpio/gpio$pin ]; then
    	echo "$pin" > /sys/class/gpio/export
    fi
    
    # set control pin to output mode
    echo "out" > /sys/class/gpio/gpio$pin/direction
    
    # set pin to "0" to turn fan off initially
    echo "0" > /sys/class/gpio/gpio$pin/value
    
    .
    .
    .
    
    # turn fan on
    echo "1" > /sys/class/gpio/gpio$pin/value

  6. #236
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    2,174
    Likely a different encoder. Iĺll make it so you put a number in there that will define the steps......

    Iĺm busy at work this week, so it might take till next weekend.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  7. #237
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    1,269
    No rush at all on my part - both modes work, so we're only talking about tweaking the user experience here. My encoder is a Keyes KY-040.

  8. #238
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    2,174
    For those wanting to interface buttons and encoders with jivelite, rather than sending commands to LMS, adding the uinput keyboard driver was rather trivial.

    For now I'm just planning to add single key commands.......

    For example on an encoder

    e,p1,p2,CMD[,mode] e,20,21,KEY:103-108

    would define an encoder on pins 20 and 20, which would send KEY_UP or KEY_DOWN based on the direction of the encoder.

    Would like some ideas before I get to far along.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  9. #239
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    1,269
    Excellent news. I can't say I've got any bright ideas at this point, but being able to navigate Jivelite will be very useful. If the encoder supports a 'push' as well, then I'd probably set that up as the 'right' arrow, and I'd probably put the 'left' arrow on a long push.

  10. #240
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    2,174
    Chill,

    Would you mind testing this out for me. My current jivelite setup is a bit difficult to add encoders and buttons to......but I did verify that I'm getting keyboard events.

    https://dl.dropboxusercontent.com/s/...pkskgzj4c/sbpd

    This is the latest source using pigpio, so make sure you have that library setup.
    We are using the kernel uinput module, so you need to load it, then set the permission to group writable, so you don't need to run sbpd with root permissions.
    Code:
    sudo modprobe uinput
    sudo chmod g+w /dev/uinput
    Here is the help info......linux key names are found https://github.com/raspberrypi/linux...-event-codes.h
    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. one of. \n\
                    VOLU for Volume\n\
                    TRAC for Prev/Next track\n\
                    KEY:<Positive key_name>-<Negative key_name>
                mode: Optional. one of\n\
                    1   - Step mode (default)\n\
                    2-9 - Detent mode - Assumes 1 dial click is x steps.
    
        For buttons: 
            b,pin,CMD[,resist,pressed,CMD_LONG,long_time]
                "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
                     Commands can be defined in config file
                         use -f option, ref:sbpd_commands.cfg 
                     Command type SCRIPT.
                       SCRIPT:/path/to/shell/script.sh
                     Command type KEY.
                          KEY:<linux key_name>.
                resist: Optional. one of
                    0 - Internal resistor off
                    1 - pull down         - input puts 3v on GPIO pin
                    2 - pull up (default) - input pulls GPIO pin to ground
                pressed: Optional GPIO pinstate for button to read pressed
                    0 - state is 0 (default)
                    1 - state is 1
                CMD_LONG: Command to be used for a long button push, see above command list
                long_time: Number of milliseconds to define a long press
    For example
    Code:
    ./sbpd -v e,20,21,KEY:KEY_UP-KEY_DOWN,4  b,20,KEY:KEY_RIGHT,2,0,KEY:KEY_LEFT,500
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •