Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some warnings #2081

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at <[email protected]>. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Special hardware is now organised in the folder [`components`](components/). If
<a href="https://www.buymeacoffee.com/MiczFlor" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg"></a>

If you like your Phoniebox, consider to [buy me a coffee](https://www.buymeacoffee.com/MiczFlor)
or donate via [PayPal](https://www.paypal.com) to [email protected] using the *friends* option.
or donate via [PayPal](https://www.paypal.com) to <[email protected]> using the *friends* option.

## Media

Expand All @@ -249,7 +249,7 @@ A new video screencast about

**What makes this Phoniebox easy to install and use:**

* Runs on all Raspberry Pi models (1, 2 and 3) and [Raspberry Zero](https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/15). (jump to the [install instructions](#install))
* Runs on all Raspberry Pi models (1, 2 and 3) and [Raspberry Zero](https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/15).
* Just plug and play using USB, no soldering iron needed.
* Once the Phoniebox is up and running, add music from any computer on your home network.
* Register new RFID cards easily without having to connect to the RPi.
Expand Down
4 changes: 2 additions & 2 deletions components/audio/PirateAudioHAT/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ NOTE: changes to the installation should find their way into the script `setup_p
enabled = true
display = st7789
```
**Attention:** Early revisions of PirateAudio HAT used bcm20 for Volume up, later revisions use bcm24. see also https://github.com/pimoroni/pirate-audio/issues/63#issuecomment-916860634


**Attention:** Early revisions of PirateAudio HAT used bcm20 for Volume up, later revisions use bcm24. see also <https://github.com/pimoroni/pirate-audio/issues/63#issuecomment-916860634>

12. Enable access for modipy user
`sudo usermod -a -G spi,i2c,gpio,video mopidy`
Expand Down
22 changes: 11 additions & 11 deletions components/bluetooth-sink-switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This component provides a mechanism to toggle between both audio sinks through all the usual user interfaces (i.e. GPIO, RFID Card Swipe, Web Interface). The current status is reflected in the Web Interface and through an optional LED.

**Convinced? So, what is the vision?**
## Convinced? So, what is the vision?

When a user powers on their Bluetooth headphones, they connect automatically to the Phoniebox. At the switch of the button (or card swipe, etc) the (already running) audio playback is transferred from the speakers to the headphones. This happens almost seamlessly. Parents feel an instant wave of relief at not having to listen to the 500th iteration of this month favourite song. The small user feels instantly proud at having working headphones much like the mom/dad always uses while doing home-office online meetings. If no Bluetooth headphones are connected, the audio sink toggle request defaults to speakers. An LED indicates the currently active audio sink.

Expand All @@ -14,15 +14,15 @@ If no bluetooth device is connected, the output defaults back to speakers. After

![Web Interface Add-on in settings.php](webif.png "Web Interface Add-on in settings.php")

**Limitations**
### Limitations

This feature only works for the *Classic* Edition. Why? It relies on the mpd multiple output channels feature to switch between outputs. This is no available in mopidy, which is used in the Spotify Edition.

### Installation
## Installation

This looks lengthy, but I the major deal is setting up your audio output devices. I have been rather explicit to avoid confusion.

#### Step 1) Setting up asound.conf
### Step 1) Setting up asound.conf

You need to set up both audio sinks and make sure they work. This is pretty much a prerequisite for everything that follows.

Expand Down Expand Up @@ -58,7 +58,7 @@ $ aplay -D btheadphone /usr/share/sounds/alsa/Front_Center.wav
$ aplay -D hifiberry /usr/share/sounds/alsa/Front_Center.wav
~~~

#### Step 2) Setting up mpd.conf
### Step 2) Setting up mpd.conf

You need to set up two audio_output sections. **The order is important**: the first entry must relate to the soundcard setup, the second entry must relate to the bluetooth setup. Give meaningful names, as they will show up in the Web Interface.

Expand Down Expand Up @@ -98,7 +98,7 @@ Output 2 (Gesas Headphones) is enabled

You may switch with `$ mpc enable only 1` and `$ mpc enable only 2`. Play some music and use these commands to check you mpd configuration. You should be able to switch the audio output between the two devices.

#### Step 3) Run the installer
### Step 3) Run the installer

This sets up the appropriate user rights and registers the component with global settings etc.

Expand All @@ -107,9 +107,9 @@ $ cd components/bluetooth-sink-switch
$ ./install-bt-sink-switch.sh
~~~

#### Step 4) Fine-tuning
### Step 4) Fine-tuning

**Status LED**
#### Status LED

An optional status LED will be turned on if the audio sink is set to bluetooth. If a toggle command is issued, but no bluetooth device is connected, the LED will blink three times. Looks very neat, if you have a button with integrated LED. Add these lines to your `RPi-Jukebox-RFID/settings/gpio_settings.ini`, to use GPIO 13 as LED signal. It is `led_pin` the BCM number of the GPIO pin (i.e. 'led_pin = 13' means GPIO13) and defaults to None. Create the file, if it does not exist.

Expand All @@ -121,7 +121,7 @@ enabled: True
led_pin: 13
~~~

**GPIO control**
#### GPIO control

If you want to toggle from a GPIO button (e.g. on GPIO5), add these lines to your `RPi-Jukebox-RFID/settings/gpio_settings.ini`. Create it, if it does not exist.

Expand All @@ -135,7 +135,7 @@ hold_time: 0.3
functionCall: functionCallBluetoothToggle
~~~

**RFID Card**
#### RFID Card

If you want to toggle by RFID card swipe, set the card id in `rfid_trigger_play.conf`, e.g.:

Expand All @@ -144,7 +144,7 @@ If you want to toggle by RFID card swipe, set the card id in `rfid_trigger_play.
CMDBLUETOOTHTOGGLE="1364237231134"
~~~

**Volume attenuation**
#### Volume attenuation

Speakers and Headphones can have very different maximum volume levels. This sometimes leads to very strong volume level changes when switching between speakers and headphones. Restricting the maximum volume with the Phoniebox-integrated max-volume setting does no yield the desired effect, as this is a single setting and does not differentiate between different audio sinks.

Expand Down
62 changes: 28 additions & 34 deletions components/controls/buttons_usb_encoder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,44 @@ Tested Devices:
2. Navigate to your RPi-Jukebox home directory and run the script `setup-buttons-usb-encoder.sh` to set up your USB Encoder. Then choose the device and map the buttons.

`cd ~/RPi-Jukebox-RFID`

`./components/controls/buttons_usb_encoder/setup-buttons-usb-encoder.sh`

If you make a mistake at the first install you can "remap" the buttons:

- Stop the service: `sudo systemctl stop phoniebox-buttons-usb-encoder.service`
- Run the installation script again: `./components/controls/buttons_usb_encoder/setup-buttons-usb-encoder.sh`
- Restart the service: `sudo systemctl start phoniebox-buttons-usb-encoder.service`
* Stop the service: `sudo systemctl stop phoniebox-buttons-usb-encoder.service`
* Run the installation script again: `./components/controls/buttons_usb_encoder/setup-buttons-usb-encoder.sh`
* Restart the service: `sudo systemctl start phoniebox-buttons-usb-encoder.service`

### Possible Button Mappings

- 'BluetoothToggle': Turn bluetooth on or off
- 'PlayerNext': Play Next
- 'PlayerPause': Pause
- 'PlayerPauseForce': Force Pause?
- 'PlayerPrev': Previous track
- 'PlayerRandomCard': Activate (play?) random card?
- 'PlayerRandomFolder': Play random folder
- 'PlayerRandomTrack': Play random track
- 'PlayerSeekBack': Seek backwards on playing track (x seconds)
- 'PlayerSeekFarBack': Seek backwards on playing track (x seconds)
- 'PlayerSeekFarFwd': Seek forwards on playing track (x seconds)
- 'PlayerSeekFwd': Seek forwards on playing track (x seconds)
- 'PlayerStop': Stop playing
- 'RecordPlayLatest': Play latest recording
- 'RecordStart': Start recording
- 'RecordStop': Stop recording
- 'Shutdown': Shut down the Phoniebox
- 'ToggleWifi': Turn Wifi on or off
- 'Vol0': Volume mute?
- 'VolD': Volume down
- 'VolU': Volume up

* 'BluetoothToggle': Turn bluetooth on or off
* 'PlayerNext': Play Next
* 'PlayerPause': Pause
* 'PlayerPauseForce': Force Pause?
* 'PlayerPrev': Previous track
* 'PlayerRandomCard': Activate (play?) random card?
* 'PlayerRandomFolder': Play random folder
* 'PlayerRandomTrack': Play random track
* 'PlayerSeekBack': Seek backwards on playing track (x seconds)
* 'PlayerSeekFarBack': Seek backwards on playing track (x seconds)
* 'PlayerSeekFarFwd': Seek forwards on playing track (x seconds)
* 'PlayerSeekFwd': Seek forwards on playing track (x seconds)
* 'PlayerStop': Stop playing
* 'RecordPlayLatest': Play latest recording
* 'RecordStart': Start recording
* 'RecordStop': Stop recording
* 'Shutdown': Shut down the Phoniebox
* 'ToggleWifi': Turn Wifi on or off
* 'Vol0': Volume mute?
* 'VolD': Volume down
* 'VolU': Volume up

## Schematics

![USB Encoder schematics](buttons-usb-encoder.jpg)

## Issues & Discussions

- https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1156
- https://github.com/MiczFlor/RPi-Jukebox-RFID/discussions/2013





* <https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1156>
* <https://github.com/MiczFlor/RPi-Jukebox-RFID/discussions/2013>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

sys.path.append(".") # This command should be before imports of components
sys.path.append(".") # This command should be before imports of components

import logging
from evdev import categorize, ecodes, KeyEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

sys.path.append(".") # This command should be before imports of components
sys.path.append(".") # This command should be before imports of components

from evdev import categorize, ecodes, KeyEvent
from io_buttons_usb_encoder import current_device, write_button_map
Expand Down
14 changes: 7 additions & 7 deletions components/displays/HD44780-i2c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

The following files allow using LCD displays based on HD44780 connected via i2c bus for this project. The following displays have been used for testing:

- 2x16 display
- 4x20 display (recommended as more information can be displayed)
* 2x16 display
* 4x20 display (recommended as more information can be displayed)

Various informations such as artist, album, track_number, track_title, track_time and many more can be displayed see main script for more display options.

The required files are:

- components/displays/HD44780-i2c/i2c_lcd.py
- components/displays/HD44780-i2c/i2c_lcd_driver.py
- components/displays/HD44780-i2c/i2c-lcd.service.default.sample
- components/displays/HD44780-i2c/README.md
* components/displays/HD44780-i2c/i2c_lcd.py
* components/displays/HD44780-i2c/i2c_lcd_driver.py
* components/displays/HD44780-i2c/i2c-lcd.service.default.sample
* components/displays/HD44780-i2c/README.md

The first file is the main LCD script that makes use of I2C_LCD_driver.py.

Expand All @@ -25,7 +25,7 @@ The third is used as sample service file that runs the i2c_lcd.py main script at

The fourth file is this file which describes the features, usage and installation of the code.

### Installation
## Installation

* You need to install additional python libraries. Run the following two command in the command line:

Expand Down
16 changes: 8 additions & 8 deletions components/displays/HD44780-i2c/i2c_lcd_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import smbus
from time import sleep


class i2c_device:
def __init__(self, addr, port=I2CBUS):
self.addr = addr
Expand Down Expand Up @@ -100,12 +101,13 @@ def read_block_data(self, cmd):
LCD_BACKLIGHT = 0x08
LCD_NOBACKLIGHT = 0x00

En = 0b00000100 # Enable bit
Rw = 0b00000010 # Read/Write bit
Rs = 0b00000001 # Register select bit
En = 0b00000100 # Enable bit
Rw = 0b00000010 # Read/Write bit
Rs = 0b00000001 # Register select bit


class lcd:
#initializes objects and lcd
# initializes objects and lcd
def __init__(self):
self.lcd_device = i2c_device(ADDRESS)

Expand All @@ -120,7 +122,6 @@ def __init__(self):
self.lcd_write(LCD_ENTRYMODESET | LCD_ENTRYLEFT)
sleep(0.2)


# clocks EN to latch command
def lcd_strobe(self, data):
self.lcd_device.write_cmd(data | En | LCD_BACKLIGHT)
Expand Down Expand Up @@ -165,16 +166,15 @@ def lcd_clear(self):
self.lcd_write(LCD_RETURNHOME)

# define backlight on/off (lcd.backlight(1); off= lcd.backlight(0)
def backlight(self, state): # for state, 1 = on, 0 = off
def backlight(self, state): # for state, 1 = on, 0 = off
if state == 1:
self.lcd_device.write_cmd(LCD_BACKLIGHT)
elif state == 0:
self.lcd_device.write_cmd(LCD_NOBACKLIGHT)

# add custom characters (0 - 7)
def lcd_load_custom_chars(self, fontdata):
self.lcd_write(0x40);
self.lcd_write(0x40)
for char in fontdata:
for line in char:
self.lcd_write_char(line)

1 change: 0 additions & 1 deletion components/gpio_control/GPIODevices/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ def __init__(self, pin, name='StatusLED'):
time.sleep(1)
self.logger.info('phoniebox-startup-scripts service active')
self.on()

46 changes: 23 additions & 23 deletions components/gpio_control/GPIODevices/shutdown_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ def set_led(self, status):
logger.debug('cannot set LED to {}: no LED pin defined'.format(status))

def callbackFunctionHandler(self, *args):
if self.is_pressed: # Should not be necessary, but handler gets called on rising edge too
logger.debug('ShutdownButton pressed, ensuring long press for {} seconds, checking each {}s'.format(
self.hold_time, self.iteration_time
))
t_passed = 0
led_state = True
while t_passed < self.hold_time:
self.set_led(led_state)
time.sleep(self.iteration_time)
t_passed += self.iteration_time
led_state = not led_state
if not self.is_pressed:
break
if t_passed >= self.hold_time:
# trippel off period to indicate command accepted
self.set_led(GPIO.HIGH)
time.sleep(.6)
# leave it on for the moment, it will be off when the system is down
self.when_pressed(*args)
else:
# switch off LED if pressing was cancelled early (during flashing)
self.set_led(GPIO.LOW)
if self.is_pressed: # Should not be necessary, but handler gets called on rising edge too
logger.debug('ShutdownButton pressed, ensuring long press for {} seconds, checking each {}s'.format(
self.hold_time, self.iteration_time
))
t_passed = 0
led_state = True
while t_passed < self.hold_time:
self.set_led(led_state)
time.sleep(self.iteration_time)
t_passed += self.iteration_time
led_state = not led_state
if not self.is_pressed:
break
if t_passed >= self.hold_time:
# trippel off period to indicate command accepted
self.set_led(GPIO.HIGH)
time.sleep(.6)
# leave it on for the moment, it will be off when the system is down
self.when_pressed(*args)
else:
# switch off LED if pressing was cancelled early (during flashing)
self.set_led(GPIO.LOW)

def __repr__(self):
return '<ShutdownButton-{}(pin={},hold_time={},iteration_time={},led_pin={},edge={},bouncetime={},antibouncehack={},pull_up_down={})>'.format(
self.name, self.pin, self.hold_time, self.iteration_time, self.led_pin, print_edge_key(self.edge), self.bouncetime,self.antibouncehack, print_pull_up_down(self.pull_up_down)
self.name, self.pin, self.hold_time, self.iteration_time, self.led_pin, print_edge_key(self.edge), self.bouncetime, self.antibouncehack, print_pull_up_down(self.pull_up_down)
)
Loading