Skip to content

Commit 6caeed1

Browse files
added mapping file for all usable gpio pins, added helper class to get gpio mappings
1 parent 7f4edaa commit 6caeed1

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

helper/GpioHelper.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import json
2+
3+
from helper.Constants import Constants
4+
5+
c = Constants()
6+
7+
8+
class GpioHelper:
9+
GPIO_SETTINGS_PATH = f"{c.settings_path()}/gpio-pin-mapping.json"
10+
11+
def get_mappings(self) -> dict:
12+
with open(self.GPIO_SETTINGS_PATH) as file:
13+
data = json.load(file)
14+
return data
15+
16+
def rotary_volume_up(self) -> int:
17+
return self.get_mappings()["ROTARY_VOLUME_UP"]
18+
19+
def rotary_volume_down(self) -> int:
20+
return self.get_mappings()["ROTARY_VOLUME_DOWN"]
21+
22+
def rotary_volume_press(self) -> int:
23+
return self.get_mappings()["ROTARY_VOLUME_PRESS"]
24+
25+
def rotary_bass_up(self) -> int:
26+
return self.get_mappings()["ROTARY_BASS_UP"]
27+
28+
def rotary_bass_down(self) -> int:
29+
return self.get_mappings()["ROTARY_BASS_DOWN"]
30+
31+
def rotary_pitch_up(self) -> int:
32+
return self.get_mappings()["ROTARY_PITCH_UP"]
33+
34+
def rotary_pitch_down(self) -> int:
35+
return self.get_mappings()["ROTARY_PITCH_DOWN"]

settings/gpio-pin-mapping.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ROTARY_VOLUME_UP": 6,
3+
"ROTARY_VOLUME_DOWN": 12,
4+
"ROTARY_VOLUME_PRESS": 13,
5+
"ROTARY_BASS_UP": 4,
6+
"ROTARY_BASS_DOWN": 14,
7+
"ROTARY_PITCH_UP": 11,
8+
"ROTARY_PITCH_DOWN": 8,
9+
"START_PARTY_MODE_BUTTON": 21
10+
}

0 commit comments

Comments
 (0)