|
a/hwctl/swgpio.py |
|
b/hwctl/swgpio.py |
1 |
#!/usr/bin/env python
|
1 |
#!/usr/bin/env python
|
2 |
from __future__ import print_function
|
2 |
from __future__ import print_function
|
3 |
|
3 |
|
4 |
import sys
|
4 |
import sys
|
5 |
import time
|
5 |
import time
|
6 |
import rclconfig
|
6 |
import conftree
|
7 |
|
7 |
|
8 |
def perr(s):
|
8 |
def perr(s):
|
9 |
print("%s"%s, file=sys.stderr)
|
9 |
print("%s"%s, file=sys.stderr)
|
10 |
|
10 |
|
11 |
try:
|
11 |
try:
|
|
... |
|
... |
16 |
|
16 |
|
17 |
# We do things in several executions. A channel already setup is normal
|
17 |
# We do things in several executions. A channel already setup is normal
|
18 |
def init():
|
18 |
def init():
|
19 |
GPIO.setwarnings(False)
|
19 |
GPIO.setwarnings(False)
|
20 |
GPIO.setmode(GPIO.BCM)
|
20 |
GPIO.setmode(GPIO.BCM)
|
21 |
fconfig = rclconfig.ConfSimple('/etc/audioswitch.conf')
|
21 |
fconfig = conftree.ConfSimple('/etc/audioswitch.conf')
|
22 |
global speaker_channel, line_channel
|
22 |
global speaker_channel, line_channel
|
23 |
speaker_channel = int(fconfig.get("speaker_channel"))
|
23 |
speaker_channel = int(fconfig.get("speaker_channel"))
|
24 |
line_channel = int(fconfig.get("line_channel"))
|
24 |
line_channel = int(fconfig.get("line_channel"))
|
25 |
|
25 |
|
26 |
def setup_gpio():
|
26 |
def setup_gpio():
|