diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults index 43215e5..b329455 100644 --- a/birdnet.conf-defaults +++ b/birdnet.conf-defaults @@ -206,6 +206,13 @@ RAW_SPECTROGRAM=0 HEARTBEAT_URL= +## CUSTOM_IMAGE and CUSTOM_IMAGE_TITLE allow you to show a custom image on the +## Overview page of your BirdNET-Pi. This can be used to show a dynamically +## updating picture of your garden, for example. + +CUSTOM_IMAGE= +CUSTOM_IMAGE_TITLE= + ## These are just for debugging LAST_RUN= THIS_RUN= diff --git a/scripts/advanced.php b/scripts/advanced.php index 0fd2ecf..02ac542 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -211,6 +211,22 @@ if(isset($_GET['submit'])) { $contents2 = preg_replace("/RAW_SPECTROGRAM=.*/", "RAW_SPECTROGRAM=0", $contents2); } + if(isset($_GET["custom_image"])) { + $custom_image = $_GET["custom_image"]; + if(strcmp($custom_image,$config['CUSTOM_IMAGE']) !== 0) { + $contents = preg_replace("/CUSTOM_IMAGE=.*/", "CUSTOM_IMAGE=$custom_image", $contents); + $contents2 = preg_replace("/CUSTOM_IMAGE=.*/", "CUSTOM_IMAGE=$custom_image", $contents2); + } + } + + if(isset($_GET["custom_image_label"])) { + $custom_image_label = $_GET["custom_image_label"]; + if(strcmp($custom_image_label,$config['CUSTOM_IMAGE_TITLE']) !== 0) { + $contents = preg_replace("/CUSTOM_IMAGE_TITLE=.*/", "CUSTOM_IMAGE_TITLE=$custom_image_label", $contents); + $contents2 = preg_replace("/CUSTOM_IMAGE_TITLE=.*/", "CUSTOM_IMAGE_TITLE=$custom_image_label", $contents2); + } + } + $fh = fopen('/etc/birdnet/birdnet.conf', "w"); $fh2 = fopen("./scripts/thisrun.txt", "w"); fwrite($fh, $contents); @@ -301,6 +317,12 @@ foreach($formats as $format){ >
+ +
+ + +
+

BirdNET-Lite Settings

diff --git a/scripts/install_config.sh b/scripts/install_config.sh index f5e3698..cdc386b 100755 --- a/scripts/install_config.sh +++ b/scripts/install_config.sh @@ -233,6 +233,13 @@ SILENCE_UPDATE_INDICATOR=0 RAW_SPECTROGRAM=0 +## CUSTOM_IMAGE and CUSTOM_IMAGE_TITLE allow you to show a custom image on the +## Overview page of your BirdNET-Pi. This can be used to show a dynamically +## updating picture of your garden, for example. + +CUSTOM_IMAGE= +CUSTOM_IMAGE_TITLE= + ## These are just for debugging LAST_RUN= THIS_RUN= diff --git a/scripts/overview.php b/scripts/overview.php index 477ba53..d045fcb 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -23,6 +23,20 @@ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = trim($home); +if(isset($_GET['custom_image'])){ + if(isset($config["CUSTOM_IMAGE"])) { + ?> +
+

+ "; + echo $img_tag; + } + die(); +} + if(isset($_GET['fetch_chart_string']) && $_GET['fetch_chart_string'] == "true") { $myDate = date('Y-m-d'); $chart = "Combo-$myDate.png"; @@ -294,8 +308,11 @@ if (file_exists('./Charts/'.$chart)) { $refresh = $config['RECORDING_LENGTH']; $time = time(); echo ""; + ?> +
+ @@ -372,6 +389,24 @@ window.addEventListener("load", function(){ window.setInterval(function(){ document.getElementById("spectrogramimage").src = "/spectrogram.png?nocache="+Date.now(); }, *1000); + + +// every 1 second, this loop will run and refresh the custom image +window.setInterval(function(){ + // Find the customimage element + var customimage = document.getElementById("customimage"); + + function updateCustomImage() { + var xhr = new XMLHttpRequest(); + xhr.open("GET", "overview.php?custom_image=true", true); + xhr.onload = function() { + customimage.innerHTML = xhr.responseText; + } + xhr.send(); + } + updateCustomImage(); +}, 1000); +