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

change hw to plughw and sound card variable #340

Merged
merged 2 commits into from
Sep 21, 2024
Merged
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
25 changes: 14 additions & 11 deletions rpitx.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ def increment_mode():
print(txLedOn)
GPIO.setup(txLed, GPIO.OUT)

card = "Headphones" # default using pcm audio output of Pi Zero
# card = "Device" # using USB sound card for audio output

print("Programming FM module!\n");
output(pd, 1)
output (ptt, 1)
Expand Down Expand Up @@ -387,7 +390,7 @@ def increment_mode():
# output(pd, 1)
# output (ptt, 0)
# sleep(0.1)
# system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav")
# system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/morse.wav")
# sleep(0.1)
# output (ptt, 1)
# output(pd, 0)
Expand Down Expand Up @@ -448,7 +451,7 @@ def increment_mode():
sleep(0.1) # add delay before transmit
output (ptt, 0)
sleep(0.3) # add even more time at start
system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav")
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/telem.wav")
sleep(0.2) # add more time at end
output (ptt, 1)
# output(pd, 0)
Expand Down Expand Up @@ -499,7 +502,7 @@ def increment_mode():
# output (pd, 1)
sleep(0.3)
output (ptt, 0)
system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav")
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/morse.wav")
sleep(0.1)
output (ptt, 1)
# output (pd, 0)
Expand Down Expand Up @@ -559,7 +562,7 @@ def increment_mode():
if (txc):
# output(pd, 1)
output (ptt, 0)
system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav")
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav")
output (ptt, 1)
# output(pd, 0)
else:
Expand Down Expand Up @@ -619,7 +622,7 @@ def increment_mode():
if (txc):
# output(pd, 1)
output (ptt, 0)
system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav")
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav")
output(ptt, 1)
# output (pd, 0)
else:
Expand Down Expand Up @@ -656,7 +659,7 @@ def increment_mode():
if (txc):
# output(pd, 1)
output (ptt, 0)
system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav")
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav")
output(ptt, 1)
# output (pd, 0)
else:
Expand Down Expand Up @@ -692,7 +695,7 @@ def increment_mode():
if (txc):
# output(pd, 1)
output (ptt, 0)
system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav")
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav")
output(ptt, 1)
# output (pd, 0)
else:
Expand Down Expand Up @@ -723,7 +726,7 @@ def increment_mode():
if (txc):
# output(pd, 1)
output (ptt, 0)
system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv.wav")
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv.wav")
output(ptt, 1)
# output (pd, 0)
else:
Expand Down Expand Up @@ -783,11 +786,11 @@ def increment_mode():
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
# system("arecord -D hw:CARD=Device,DEV=0 | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
## system("arecord -D hw:CARD=Device,DEV=0 -f S16_LE -r 48000 -c 1 | csdr convert_s16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
# system("arecord -D plughw:CARD=Device,DEV=0 | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
## system("arecord -D plughw:CARD=Device,DEV=0 -f S16_LE -r 48000 -c 1 | csdr convert_s16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
system("sudo nc -l 8011 | csdr convert_i16_f | csdr gain_ff 16000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
sleep(1)
system("sudo arecord -D plughw:1 -r48000 -fS16_LE -c1 | nc localhost 8011 &")
system("sudo arecord -D plugplughw:1 -r48000 -fS16_LE -c1 | nc localhost 8011 &")
GPIO.output(powerPin, 1)
sleep(0.5)
GPIO.output(powerPin, 0)
Expand Down