From 547c1fe5b93ce4937826e8a0ccc7b45898bbaefd Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Thu, 13 May 2021 22:06:00 +0200 Subject: [PATCH] fix issue #24 Signed-off-by: Michel-FK --- .../rootfs-overlay/usr/local/sbin/audio_amp | 15 +++++++++++---- .../rootfs-overlay/usr/local/sbin/instant_play | 1 - .../funkey/rootfs-overlay/usr/local/sbin/volume | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp index aeefdbf..25752dd 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp @@ -28,12 +28,12 @@ case "${1}" in else exit 0 fi - enable=1 + new_state=1 ;; 0|off|OFF|Off) echo "Turning audio amplifier OFF" - enable=0 + new_state=0 ;; *) @@ -46,7 +46,14 @@ if [ ! -d "${SYSTEM_GPIO}/gpio${GPIO_PF6}" ]; then echo ${GPIO_PF6} > "${SYSTEM_GPIO}/export" fi -# Enable/disable the pwoer audio amplifier +# Set the power audio amplifier GPIO as output echo "out" > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/direction" -echo ${enable} > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value" + +# Read the current power audio amplifier state +current_state=$(cat "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value") + +# Enable/disable the power audio amplifier if necessary +if [ ${current_state} -ne ${new_state} ]; then + echo ${new_state} > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value" +fi exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play index b3b06d4..157c8b7 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play @@ -26,7 +26,6 @@ case ${1} in # Launch Previous Game if any if [ -f "${INSTANT_PLAY_FILE}" ]; then - audio_amp on keymap resume echo -n "Found Instant Play file, restarting previous game with command: " echo $(head -n 1 "${INSTANT_PLAY_FILE}") diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume index 1ba457b..f458ceb 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume @@ -81,10 +81,10 @@ set_volume() { fi # Turn on/off audio amplifier if necessary - if [ ${current_volume} -eq 0 -a ${new_volume} -ne 0 ]; then - audio_amp on - elif [ ${current_volume} -ne 0 -a ${new_volume} -eq 0 ]; then + if [ ${new_volume} -eq 0 ]; then audio_amp off + else + audio_amp on fi }