Is there a hook or routine we could use / tie to to activate a retracted antenna when using Hudiy with an SDR to listen to FM radio?
We have a CarPiHat that has several GPIO switchable outputs e.g. BCM27 that we could activate with the selection of radio if we knew how to link that to the Hudiy code for radio selection. The CPH outputs provide 12V with enough current to activate rising the antenna.TIA.
NOOB question on activating a retracted antenna
Re: NOOB question on activating a retracted antenna
How exactly is the antenna supposed to behave (retract/extend)? When you press play on the FM Radio player, the antenna should extend, and when you press stop/pause (or switch to another player), it should retract?
If so, you could use the API for this. Using the API, you can check which player currently has audio focus and whether it is in play or pause state. Based on the MediaSource (e.g. MEDIA_SOURCE_FM_RADIO) and is_playing, you can then control the state of a GPIO pin that extends or retracts the antenna.
There is an example on our GitHub showing how to use this part of the API. You would just need to add GPIO control logic based on the values of source and is_playing, e. g:
Links:
https://github.com/wiboma/hudiy/blob/ma ... proto#L147
https://github.com/wiboma/hudiy/blob/ma ... proto#L100
https://github.com/wiboma/hudiy/blob/ma ... diaData.py
If so, you could use the API for this. Using the API, you can check which player currently has audio focus and whether it is in play or pause state. Based on the MediaSource (e.g. MEDIA_SOURCE_FM_RADIO) and is_playing, you can then control the state of a GPIO pin that extends or retracts the antenna.
There is an example on our GitHub showing how to use this part of the API. You would just need to add GPIO control logic based on the values of source and is_playing, e. g:
Code: Select all
def on_media_status(self, client, message):
if message.source == hudiy_api.MediaSource.MEDIA_SOURCE_FM_RADIO:
if message.is_playing:
# source is FM Radio and it is playing - extend the antenna
else:
# source is FM Radio but playback is paused - retract the antenna
else:
# source is not FM Radio, retract the antenna
https://github.com/wiboma/hudiy/blob/ma ... proto#L147
https://github.com/wiboma/hudiy/blob/ma ... proto#L100
https://github.com/wiboma/hudiy/blob/ma ... diaData.py
Re: NOOB question on activating a retracted antenna
Just raise the antenna when the FM Radio player is selected. Pausing play or muting should not effect the extended condition. Changing to other audio source e.g. a thumb drive of MP3s should deactivate the GPIO pin. (WOW thanx for the quick info.)
Re: NOOB question on activating a retracted antenna
You're welcome. In that case, using just the source should be enough to control the antenna (one of the triggers for the media status is the change of the audio source within Hudiy), e. g.:gwynethh wrote: Mon Nov 24, 2025 6:42 pm Just raise the antenna when the FM Radio player is selected. Pausing play or muting should not effect the extended condition. Changing to other audio source e.g. a thumb drive of MP3s should deactivate the GPIO pin. (WOW thanx for the quick info.)
Code: Select all
def on_media_status(self, client, message):
if message.source == hudiy_api.MediaSource.MEDIA_SOURCE_FM_RADIO:
# source is FM Radio - extend the antenna
else:
# source is not FM Radio, retract the antenna