Main > Project Announcements
RPi Jukebox, based on XLobby and Mountain Jukebox design
<< < (5/7) > >>
Gilrock:
Probably be safer to buy one of those SD card extension cables for around $7
DaOld Man:

--- Quote from: Gilrock on May 06, 2021, 12:56:24 pm ---Probably be safer to buy one of those SD card extension cables for around $7

--- End quote ---

You are probably right. Shopping now. :)
DaOld Man:
Thanks to Gilrocks suggestion, I have moved the SDCard position to a more accessible place.

Ordered a extender adapter from amazon. It was around 10 bucks, but was shipped from within US, not China, so it arrived in 3 days.
(Im sure it was made in China, but thats way to common these days.)

I folded the cable and tapped it down as flat as I could.



The adapter came with some double sided tape. I tapped it down to back of monitor. Its a little whoppy-jawed (crooked), but the tape sticks like crazy, guess I can live with it.



I then placed the monitor circuit board back on top of it, and replaced the plexi chassis.



I like this a lot more, but it's a shame I had to do that to start with.
DaOld Man:
Here is the code for the encoder to control volume.
I still need to get current volume setting when starting. (I cant seem to find the command for this).
I got the code from the credited website, but had to modify it quite a bit for my use.


--- Code: ---#!/usr/bin/env python3

# set master volume with encoder for rpi. KRR 05/10/2021

#  adapted to suit my needs from https://github.com/bruceiow/rPiVolumeControl/blob/master/VolumeControl.py

from RPi import GPIO
from time import sleep
import subprocess
from subprocess import call

# These are the GPIO numbers for the clk,dt and mute switch pins from the encoder
clk =35
dt = 37
mute_pin=11

GPIO.setmode(GPIO.BOARD)
GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(mute_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

counter = 50 # need to get current volume setting from amixer
oldcounter=counter
clkLastState = not GPIO.input(clk) # using NOT because Im using GND for switch commons
mute=False


def switch_mute(channel):
    global mute
    if mute:
        mute=False
        call (["amixer","set", "Master","unmute"])   
    else:
        mute=True
        call (["amixer","set", "Master","mute"])
   
GPIO.add_event_detect(mute_pin, GPIO.FALLING, callback=switch_mute, bouncetime=100)


try:
   while True:
     if not mute:
       clkState = not GPIO.input(clk)
       dtState = not GPIO.input(dt)
       if clkState != clkLastState:
         clkLastState = clkState
         if dtState != clkState:
           if counter <101: 
            counter += 1
         else:
           if counter >1:
            counter -= 1
         #if counter<1:counter=1
         #if counter>100: counter=100
         
       if counter!= oldcounter:
         call (["amixer","sset", "Master",str(counter)+"%"])
         oldcounter=counter
       #sleep(0.1) # may need to adjust
finally:
      GPIO.cleanup()


--- End code ---
DaOld Man:
Bad news from the front:
The SD Card crapped out. Kept getting "input/output error". Lost everything on the card.
Reformatted card and re-installed everything (I had backups on my pc). Still got the errors.
I removed the extension cable adapter, installed card directly into RPi. Still got the errors.
Im thinking that card is toast.
I formatted another card, installed OS (Debian Buster) image, then spent a good part of the day re-installing software and scripts.
So far so good.
Im afraid now to use that extension adapter, what if that is what crapped on my first sdcard?
Navigation
Message Index
Next page
Previous page

Go to full version