Skip to content

Commit

Permalink
Updates to vast to better support FPP 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Mar 26, 2020
1 parent 8d35893 commit ee4c4c8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 38 deletions.
13 changes: 10 additions & 3 deletions pluginInfo.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"repoName": "fpp-vastfmt",
"name": "Vast V-FMT212R/Si4713",
"name": "Si4713/Vast V-FMT212R",
"author": "Daniel Kulp",
"description": "Basic RDS/Audio support for the Vast Electronics V-FMT212R USB FM Transmitter and Si4713 I2C modules",
"description": "RDS/Audio support for the Vast Electronics V-FMT212R USB FM Transmitter and Si4713 I2C modules",
"homeURL": "https://github.com/FalconChristmas/fpp-vastfmt",
"srcURL": "https://github.com/FalconChristmas/fpp-vastfmt.git",
"bugURL": "https://github.com/FalconChristmas/fpp-vastfmt/issues",
Expand Down Expand Up @@ -30,10 +30,17 @@
},
{
"minFPPVersion": "3.3",
"maxFPPVersion": "3.99",
"branch": "master",
"sha": "8d3589395ae7615148ce7a29311408e1533ea423",
"allowUpdates": 0
},
{
"minFPPVersion": "4.0",
"maxFPPVersion": "0",
"branch": "master",
"sha": "",
"allowUpdates": 0
"allowUpdates": 1
}
]
}
Expand Down
79 changes: 46 additions & 33 deletions plugin_setup.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
<?php

$defaultGPIO = "4";
if ($settings['Platform'] == "BeagleBone Black") {
$defaultGPIO = "14";
}

$curGpio = ReadSettingFromFile("ResetPin", "fpp-vastfmt");

$defaultGPIO = "4";
if ($settings['Platform'] == "BeagleBone Black") {
$defaultGPIO = "99";
}
echo "<!-- " . $curGpio . " " . $defaultGPIO . " -->\n";
$data = file_get_contents('http://127.0.0.1:32322/gpio');
$gpiojson = json_decode($data, true);
$gpioPins = Array();
foreach($gpiojson as $gpio) {
$pn = $gpio['pin'] . ' (GPIO: ' . $gpio['gpio'] . ')';
$gpioPins[$pn] = $gpio['gpio'];

if ($curGpio == $gpio['pin']) {
$defaultGPIO = $gpio['gpio'];
$pluginSettings["ResetPin"] = $defaultGPIO;
WriteSettingToFile("ResetPin", $defaultGPIO, "fpp-vastfmt");
}
}
echo "<!-- " . $curGpio . " " . $defaultGPIO . " -->\n";
?>

<script type="text/javascript">
<!--
function toggle(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';

function OnConnectionChanged() {
var value = $('#Connection').val();
if (value == "USB") {
$('#ResetPinInfo').hide();
} else {
$('#ResetPinInfo').show();
}
//-->
}
</script>


<div id="VASTFMTPluginhw" class="settings">
<fieldset>
<legend>VAST-FMT/Si4713 Hardware</legend>
<p>Connection: <?php PrintSettingSelect("Connection", "Connection", 1, 0, "USB", Array("USB"=>"USB", "I2C"=>"I2C"), "fpp-vastfmt", ""); ?></p>
<p>Reset GPIO: <?php PrintSettingTextSaved("ResetPin", 1, 0, 6, 6, "fpp-vastfmt", $defaultGPIO); ?><br />
I2C connection requires a GPIO pin to reset the Si4713. Can either be a kernal GPIO number or a pin name like "P9-30". Setting is unused for USB connection. </p>
<p>Connection: <?php PrintSettingSelect("Connection", "Connection", 2, 0, "USB", Array("USB"=>"USB", "I2C"=>"I2C"), "fpp-vastfmt", "OnConnectionChanged"); ?></p>
<p class="ResetPinInfo" id="ResetPinInfo">Reset GPIO: <?php PrintSettingSelect("ResetPin", "ResetPin", 2, 0, $defaultGPIO, $gpioPins, "fpp-vastfmt", ""); ?><br />
I2C connection requires a GPIO pin to reset/enable the Si4713.</p>
</fieldset>
</div>

Expand All @@ -33,9 +50,9 @@ function toggle(id) {
<div id="VASTFMTPluginsettings" class="settings">
<fieldset>
<legend>VAST-FMT/Si4713 Plugin Settings</legend>
<p>Start at: <?php PrintSettingSelect("Start", "Start", 1, 0, "FPPDStart", Array("FPPD Start (default)"=>"FPPDStart", "Playlist Start"=>"PlaylistStart", "Never - RDS Only"=>"RDSOnly", "Never"=>"Never"), "fpp-vastfmt", ""); ?><br />
<p>Start at: <?php PrintSettingSelect("Start", "Start", 2, 0, "FPPDStart", Array("FPPD Start (default)"=>"FPPDStart", "Playlist Start"=>"PlaylistStart", "Never - RDS Only"=>"RDSOnly", "Never"=>"Never"), "fpp-vastfmt", ""); ?><br />
At Start, the hardware is reset, FM settings initialized, will broadcast any audio played, and send static RDS messages (if enabled).</p>
<p>Stop at: <?php PrintSettingSelect("Stop", "Stop", 1, 0, "Never", Array("Playlist Stop"=>"PlaylistStop", "Never (default)"=>"Never"), "fpp-vastfmt", ""); ?><br />
<p>Stop at: <?php PrintSettingSelect("Stop", "Stop", 2, 0, "Never", Array("Playlist Stop"=>"PlaylistStop", "Never (default)"=>"Never"), "fpp-vastfmt", ""); ?><br />
At Stop, the hardware is reset. Listeners will hear static.</p>
</fieldset>
</div>
Expand All @@ -45,11 +62,11 @@ function toggle(id) {
<div id="VASTFMTsettings" class="settings">
<fieldset>
<legend>VAST-FMT/Si4713 FM Settings</legend>
<p>Frequency (76.00-108.00): <?php PrintSettingTextSaved("Frequency", 1, 0, 6, 6, "fpp-vastfmt", "100.10"); ?>MHz</p>
<p>Power (88-115, 116-120<sup>*</sup>): <?php PrintSettingTextSaved("Power", 1, 0, 3, 3, "fpp-vastfmt", "110"); ?>dB&mu;V
<p>Frequency (76.00-108.00): <?php PrintSettingTextSaved("Frequency", 2, 0, 6, 6, "fpp-vastfmt", "100.10"); ?>MHz</p>
<p>Power (88-115, 116-120<sup>*</sup>): <?php PrintSettingTextSaved("Power", 2, 0, 3, 3, "fpp-vastfmt", "110"); ?>dB&mu;V
<br /><sup>*</sup>Can be set as high as 120dB&mu;V, but voltage accuracy above 115dB&mu;V is not guaranteed.</p>
<p>Preemphasis: <?php PrintSettingSelect("Preemphasis", "Preemphasis", 1, 0, "75us", Array("50&mu;s (Europe, Australia, Japan)"=>"50us", "75&mu;s (USA, default)"=>"75us"), "fpp-vastfmt", ""); ?></p>
<p>Antenna Tuning Capacitor (0=Auto, 1-191): <?php PrintSettingText("AntCap", 1, 0, 3, 3, "fpp-vastfmt", "0"); ?> * 0.25pF </p>
<p>Preemphasis: <?php PrintSettingSelect("Preemphasis", "Preemphasis", 2, 0, "75us", Array("50&mu;s (Europe, Australia, Japan)"=>"50us", "75&mu;s (USA, default)"=>"75us"), "fpp-vastfmt", ""); ?></p>
<p>Antenna Tuning Capacitor (0=Auto, 1-191): <?php PrintSettingText("AntCap", 2, 0, 3, 3, "fpp-vastfmt", "0"); ?> * 0.25pF </p>
</fieldset>
</div>

Expand All @@ -58,18 +75,18 @@ function toggle(id) {
<div id="VASTFMTRDSsettings" class="settings">
<fieldset>
<legend>VAST-FMT/Si4713 RDS Settings</legend>
<p>Enable RDS: <?php PrintSettingCheckbox("EnableRDS", "EnableRDS", 1, 0, "True", "False", "fpp-vastfmt", ""); ?></p>
<p>Enable RDS: <?php PrintSettingCheckbox("EnableRDS", "EnableRDS", 2, 0, "True", "False", "fpp-vastfmt", ""); ?></p>
<p>RDS Station - Sent 8 characters at a time. Max of 64 characters.<br />
Station Text: <?php PrintSettingTextSaved("StationText", 1, 0, 64, 32, "fpp-vastfmt", "Merry Christ- mas"); ?>
Station Text: <?php PrintSettingTextSaved("StationText", 2, 0, 64, 32, "fpp-vastfmt", "Merry Christ- mas"); ?>

<br />

<p>RDS Text: <?php PrintSettingTextSaved("RDSTextText", 1, 0, 64, 32, "fpp-vastfmt", "[{Artist} - {Title}]"); ?>
<p>RDS Text: <?php PrintSettingTextSaved("RDSTextText", 2, 0, 64, 32, "fpp-vastfmt", "[{Artist} - {Title}]"); ?>
<p>
Place {Artist} or {Title} where the media artist/title should be placed. Area's wrapped in brackets ( [] ) will not be output unless media is present.


<p>Program Type (PTY North America / Europe): <?php PrintSettingSelect("Pty", "Pty", 1, 0, 2,
<p>Program Type (PTY North America / Europe): <?php PrintSettingSelect("Pty", "Pty", 2, 0, 2,
Array(
"0 - None / None"=>0,
"1 - News / News"=>1,
Expand Down Expand Up @@ -106,10 +123,6 @@ function toggle(id) {
</div>

<br />

<div id='fileViewer' title='File Viewer' style="display: none">
<div id='fileText'>
</div>
</div>

<br />
<script>
OnConnectionChanged()
</script>
10 changes: 8 additions & 2 deletions src/FPPVastFM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static void padTo(std::string &s, int l) {
class FPPVastFMPlugin : public FPPPlugin {
public:
bool enabled = true;
bool rdsEnabled = false;
FPPVastFMPlugin() : FPPPlugin("fpp-vastfmt") {
setDefaultSettings();
if (settings["Start"] == "FPPDStart") {
Expand Down Expand Up @@ -109,7 +110,8 @@ class FPPVastFMPlugin : public FPPPlugin {
std::string ts = si4713->getTuneStatus();
LogInfo(VB_PLUGIN, "VAST-FMT: %s\n", ts.c_str());

if (settings["EnableRDS"] == "True") {
rdsEnabled = settings["EnableRDS"] == "True";
if (rdsEnabled) {
initRDS();
}
}
Expand Down Expand Up @@ -199,7 +201,7 @@ class FPPVastFMPlugin : public FPPPlugin {


virtual void playlistCallback(const Json::Value &playlist, const std::string &action, const std::string &section, int item) {
if (action == "stop") {
if (action == "stop" && rdsEnabled) {
formatAndSendText(settings["StationText"], "", "", true);
formatAndSendText(settings["RDSTextText"], "", "", false);
}
Expand All @@ -211,6 +213,9 @@ class FPPVastFMPlugin : public FPPPlugin {

}
virtual void mediaCallback(const Json::Value &playlist, const MediaDetails &mediaDetails) {
if (!rdsEnabled) {
return;
}
std::string title = mediaDetails.title;
std::string artist = mediaDetails.artist;
std::string album = mediaDetails.album;
Expand Down Expand Up @@ -252,6 +257,7 @@ class FPPVastFMPlugin : public FPPPlugin {
} else if (!emptyAllowed && settings[s] == "") {
settings[s] = v;
}
LogDebug(VB_PLUGIN, "Setting \"%s\": \"%s\"\n", s.c_str(), settings[s].c_str());
}

Si4713 *si4713 = nullptr;
Expand Down

0 comments on commit ee4c4c8

Please sign in to comment.