Skip to content

Commit fd803b9

Browse files
use "dynamic" gpio mappings from settings
1 parent 6caeed1 commit fd803b9

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

components/RotaryBass.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44

55
from helper.Audio import Audio
66
from helper.AudioEffects import AudioEffects
7+
from helper.GpioHelper import GpioHelper
78

89
audio_helper = Audio()
910
audio_effects = AudioEffects()
11+
gpio_helper = GpioHelper()
1012

1113

1214
class RotaryBass:
1315
COUNTER = 0
1416
BASS_STEP = 2
1517

16-
CLK_PIN = 4 # PIN 7
17-
DT_PIN = 14 # PIN 8
18+
CLK_PIN = gpio_helper.rotary_bass_up()
19+
DT_PIN = gpio_helper.rotary_bass_down()
1820

1921
def __init__(self, on_taskbar_update):
2022
rotary = pyky040.Encoder(CLK=self.CLK_PIN, DT=self.DT_PIN)

components/RotaryPitch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
from pyky040 import pyky040
44

55
from helper.AudioEffects import AudioEffects
6+
from helper.GpioHelper import GpioHelper
67

78
audio_effects = AudioEffects()
9+
gpio_helper = GpioHelper()
810

911

1012
class RotaryPitch:
1113
COUNTER = 0
1214
PITCH_STEP = 1
13-
CLK_PIN = 11 # PIN 23
14-
DT_PIN = 8 # PIN 24
15+
CLK_PIN = gpio_helper.rotary_pitch_up()
16+
DT_PIN = gpio_helper.rotary_pitch_down()
1517

1618
taskbar = None
1719

components/RotaryVolume.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
from pyky040 import pyky040
44

55
from helper.Audio import Audio
6+
from helper.GpioHelper import GpioHelper
67

78
audio_helper = Audio()
9+
gpio_helper = GpioHelper()
810

911

1012
class RotaryVolume:
1113
COUNTER = 0
1214
VOLUME_STEP = 6
13-
SW_PIN = 13 # PIN 33
14-
DT_PIN = 12 # PIN 32
15-
CLK_PIN = 6 # PIN 31
15+
SW_PIN = gpio_helper.rotary_volume_up()
16+
DT_PIN = gpio_helper.rotary_volume_down()
17+
CLK_PIN = gpio_helper.rotary_volume_press()
1618

1719
def __init__(self, on_taskbar_update, on_strip_toggle_mute, on_strip_update_sound):
1820
rotary = pyky040.Encoder(CLK=self.CLK_PIN, DT=self.DT_PIN, SW=self.SW_PIN)

helper/GpioHelper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ def rotary_pitch_up(self) -> int:
3333

3434
def rotary_pitch_down(self) -> int:
3535
return self.get_mappings()["ROTARY_PITCH_DOWN"]
36+
37+
def start_party_button(self) -> int:
38+
return self.get_mappings()["START_PARTY_MODE_BUTTON"]

scripts/button.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
import RPi.GPIO as GPIO
44

5+
from helper.GpioHelper import GpioHelper
56
from helper.SystemHelper import SystemHelper
67

8+
gpio_helper = GpioHelper()
9+
710
# Hierbei handelt es sich um ein Überbleibsel aus Zeiten des Radio's des BSZ Wiesau, um bei offiziellen Veranstaltungen
811
# das Soundboard zu verstecken. Dabei muss dieses Skript in der main.py importiert werden.
912
# Um das Soundboard zu aktivieren, ...
1013

1114
GPIO.setmode(GPIO.BCM)
1215

13-
PIN = 21
16+
PIN = gpio_helper.start_party_button()
1417

1518
GPIO.setup(PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
1619

0 commit comments

Comments
 (0)