diff --git a/html/changeconf.php b/html/changeconf.php index 9ccd246..227b82b 100755 --- a/html/changeconf.php +++ b/html/changeconf.php @@ -57,10 +57,21 @@ if (isset($msg)) { // Set default mixer and device names for internal audio $mixer = "PCM"; $device = "Internal audio device"; + // Set default volume limits for internal audio (HQ) + $volume_min = 35; + $volume_max = 95; // Prepare pwm parameter $pwm = ( $hda == 'hdaudio') ? "2" : "1"; + if ( $pwm == '1') { + // Default volume limits for internal audio (SQ) + $volume_min = 40; + $volume_max = 100; + } // If external USB audio selected if ( $selected == 'usb' ) { + // Default volume limit for USB device + $volume_min = 0; + $volume_max = 100; // Check number of USB card preg_match('/bcm2835/', $lines[0], $matches); $usbline = (isset($matches[0])) ? 2 : 0; @@ -79,7 +90,20 @@ if (isset($msg)) { } else { echo "No"; } - echo "

"; + echo "
"; + $piradio = file_get_contents( "/etc/radiod.conf" ); + $piradio_new = preg_replace("/\nvolume_min *= *.*/", "\nvolume_min=".$volume_min, $piradio); + $piradio_new = preg_replace("/\nvolume_max *= *.*/", "\nvolume_max=".$volume_max, $piradio_new); + $piradio_array = parse_ini_string($piradio_new); + $volume_min = ($piradio_array['volume_min']); + $volume_max = ($piradio_array['volume_max']); + echo "Volume limits:
"; + echo ""; + echo "min: ".$volume_min."
"; + echo "max: ".$volume_max."

"; + file_put_contents('/etc/radiod.conf', $piradio_new); + chmod("/etc/radiod.conf", 0755); + echo "
"; $end = shell_exec('sudo ./scripts/set_audio.sh '.$selected.' '.$mixer.' '.$pwm ); echo "Reboot in progress.
\r\n"; echo "Wait!
\r\n"; diff --git a/html/config.php b/html/config.php index 2c502e4..11820eb 100755 --- a/html/config.php +++ b/html/config.php @@ -32,6 +32,14 @@ if (!isset($piradio_array['pandora_available'])) { $piradio = $piradio."\r\n# Is Pandora account available (Pecus)\r\npandora_available=no\r\n"; $write_conf = true; } +if (!isset($piradio_array['volume_min'])) { + $piradio = $piradio."\r\nvolume_min=0\r\n"; + $write_conf = true; +} +if (!isset($piradio_array['volume_max'])) { + $piradio = $piradio."\r\nvolume_max=100\r\n"; + $write_conf = true; +} if ($write_conf) { file_put_contents('/etc/radiod.conf', $piradio); }