From 6e008cc539091055790ee56933541b2f3061c67e Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sun, 2 May 2021 22:39:29 +0200 Subject: [PATCH] unify brightness & volume scripts Signed-off-by: Michel-FK --- .../funkey/rootfs-overlay/etc/fkgpiod.conf | 10 +- .../board/funkey/rootfs-overlay/root/.profile | 17 +-- .../rootfs-overlay/usr/local/sbin/brightness | 122 ++++++++++++++++ .../usr/local/sbin/brightness_get | 18 --- .../usr/local/sbin/brightness_get_sysfs | 13 -- .../usr/local/sbin/brightness_set | 27 ---- .../usr/local/sbin/brightness_set_sysfs | 21 --- .../usr/local/sbin/quick_action_bright_down | 22 --- .../usr/local/sbin/quick_action_bright_up | 22 --- .../usr/local/sbin/quick_action_volume_down | 22 --- .../usr/local/sbin/quick_action_volume_up | 22 --- .../usr/local/sbin/{snap => snapshot} | 0 .../usr/local/sbin/start_audio_amp | 44 +++--- .../usr/local/sbin/start_gpio_manager | 12 -- .../rootfs-overlay/usr/local/sbin/volume | 130 ++++++++++++++++++ .../rootfs-overlay/usr/local/sbin/volume_get | 18 --- .../usr/local/sbin/volume_get_alsa | 4 - .../rootfs-overlay/usr/local/sbin/volume_set | 39 ------ .../usr/local/sbin/volume_set_alsa | 31 ----- FunKey/package/FCEUX/FCEUX.mk | 2 +- FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk | 2 +- FunKey/package/PocketSNES/PocketSNES.mk | 2 +- FunKey/package/commander/commander.mk | 2 +- FunKey/package/gmenu2x/gmenu2x.mk | 2 +- FunKey/package/gnuboy/gnuboy.mk | 2 +- FunKey/package/gpsp/gpsp.mk | 2 +- FunKey/package/mednafen/mednafen.mk | 2 +- FunKey/package/picodrive/picodrive.mk | 2 +- FunKey/package/retrofe/retrofe.mk | 2 +- .../funkey/rootfs-overlay/etc/fkgpiod.conf | 10 +- .../board/funkey/rootfs-overlay/root/.profile | 6 +- .../usr/local/sbin/brightness_get | 18 --- .../usr/local/sbin/brightness_get_sysfs | 13 -- .../usr/local/sbin/brightness_set | 27 ---- .../usr/local/sbin/brightness_set_sysfs | 21 --- .../usr/local/sbin/quick_action_bright_down | 22 --- .../usr/local/sbin/quick_action_bright_up | 22 --- .../usr/local/sbin/{snap => snapshot} | 0 .../usr/local/sbin/start_gpio_manager | 12 -- 39 files changed, 307 insertions(+), 458 deletions(-) create mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_down delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_up rename FunKey/board/funkey/rootfs-overlay/usr/local/sbin/{snap => snapshot} (100%) delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager create mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get_alsa delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set_alsa delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up rename Recovery/board/funkey/rootfs-overlay/usr/local/sbin/{snap => snapshot} (100%) delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager diff --git a/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf b/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf index 49ef00e..36fd39a 100644 --- a/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf +++ b/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf @@ -15,11 +15,11 @@ MAP B TO KEY KEY_B MAP X TO KEY KEY_X MAP Y TO KEY KEY_Y MAP MENU TO KEY KEY_Q -MAP FN+UP TO COMMAND snap -MAP FN+A TO COMMAND quick_action_volume_up -MAP FN+Y TO COMMAND quick_action_volume_down -MAP FN+X TO COMMAND quick_action_bright_up -MAP FN+B TO COMMAND quick_action_bright_down +MAP FN+UP TO COMMAND snapshot +MAP FN+A TO COMMAND volume up +MAP FN+Y TO COMMAND volume down +MAP FN+X TO COMMAND brightness up +MAP FN+B TO COMMAND brightness down MAP FN+L TO KEY KEY_V MAP FN+R TO KEY KEY_O MAP FN+L+R TO COMMAND display_notif_system_stats diff --git a/FunKey/board/funkey/rootfs-overlay/root/.profile b/FunKey/board/funkey/rootfs-overlay/root/.profile index cad4256..3be84a4 100755 --- a/FunKey/board/funkey/rootfs-overlay/root/.profile +++ b/FunKey/board/funkey/rootfs-overlay/root/.profile @@ -44,18 +44,13 @@ resize() { fi } +# Restore saved volume +echo "Restore saved volume" +volume set $(volume get) >/dev/null 2>&1 -# Start ampli -echo "Start audio amplifier" -start_audio_amp 1 >/dev/null 2>&1 - -# Force unmute sound card and reset volume -echo "Force unmute sound card and reset volume" -volume_set $(volume_get) >/dev/null 2>&1 - -# Reset saved brightness -echo "Reset saved brightness" -brightness_set $(brightness_get) >/dev/null 2>&1 +# Restore saved brightness +echo "Restore saved brightness" +brightness set $(brightness get) >/dev/null 2>&1 # Start Assembly tests (blocking process) assembly_tests >/dev/null 2>&1 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness new file mode 100755 index 0000000..5d8352c --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness @@ -0,0 +1,122 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +SYSTEM_BRIGHTNESS="/sys/class/backlight/backlight/brightness" +DEFAULT_BRIGHTNESS_VALUE=100 +BRIGHTNESS_STEP=10 +NOTIF_DURATION=2 + +usage() { + >&2 echo "Usage: ${SELF} get" + >&2 echo " ${SELF} set new_brightness_percentage" + exit 1 +} + +increase_brightness() { + + # Get current value + local current_brightness=$(get_brightness) + + # Compute new brightness value + local new_brightness=0 + let new_brightness=${current_brightness}+${BRIGHTNESS_STEP} + if [ ${new_brightness} -gt 100 ]; then + new_brightness=100 + fi + + # Change brightness + if [ ${new_brightness} -ne ${current_brightness} ]; then + set_brightness ${new_brightness} + fi + + # Notif + notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" +} + +decrease_brightness() { + + # Get current value + local current_brightness=$(get_brightness) + + # Compute new brightness value + local new_brightness=0 + if [ ${current_brightness} -gt ${BRIGHTNESS_STEP} ]; then + let new_brightness=${current_brightness}-${BRIGHTNESS_STEP} + fi + + # Change brightness + if [ ${new_brightness} -ne ${current_brightness} ]; then + set_brightness ${new_brightness} + fi + + # Notif + notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" +} + +get_brightness() { + local brightness=$(fw_printenv -n brightness 2>/dev/null) + if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then + brightness=${DEFAULT_BRIGHTNESS_VALUE} + fw_setenv brightness ${brightness} + fi + echo ${brightness} +} + +set_brightness() { + + # Set the new brightness percentage in the kernel driver + local brightness=${1} + local kernel_brightness + let kernel_brightness=${brightness}+10 + let kernel_brightness/=10 + echo ${kernel_brightness} > "${SYSTEM_BRIGHTNESS}" + + # Set the new brightness value in a bootloader variable + if [ ${?} -eq 0 -a $(get_brightness) -ne ${brightness} ]; then + fw_setenv brightness ${brightness} + fi +} + +# Check number of arguments +if [ ${#} -lt 1 -o ${#} -gt 2 ]; then + usage +fi + +case ${1} in + up) + increase_brightness + ;; + + down) + decrease_brightness + ;; + + get) + if [ ${#} -ne 1 ]; then + usage + fi + get_brightness + ;; + + set) + if [ ${#} -ne 2 ]; then + usage + fi + + # Make sure the argument is a positive number <= 100 + if [ -n "${2}" ] && [ "${2}" -eq "${2}" ] 2>/dev/null && \ + [ "${2}" -ge 0 ] && [ "${2}" -le 100 ]; then + set_brightness "${2}" + else + usage + fi + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get deleted file mode 100755 index 399bc37..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -BRIGHTNESS_DEFAULT_VALUE=100 - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -# Sanity check: Check if integer -brightness=$(fw_printenv -n brightness 2>/dev/null) -if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then - brightness=${BRIGHTNESS_DEFAULT_VALUE} - fw_setenv brightness ${brightness} -fi -echo ${brightness} -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs deleted file mode 100755 index a682958..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -let brightness=$(cat ${SYSTEM_BRIGHTNESS})*10-10 -echo ${brightness} -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set deleted file mode 100755 index 8d45575..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi -brightness_percentage=${1} - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} - -# Set new brightness value in brightness file -if [ ${?} -eq 0 -a $(brightness_get) -ne ${brightness_percentage} ]; then - fw_setenv brightness ${brightness_percentage} -fi -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs deleted file mode 100755 index 424a3d8..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down deleted file mode 100755 index efd8d53..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -new_brightness=0 -if [ ${current_brightness} -gt ${STEP_BRIGHTNESS} ]; then - let new_brightness=${current_brightness}-${STEP_BRIGHTNESS} -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up deleted file mode 100755 index 6241430..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -let new_brightness=${current_brightness}+${STEP_BRIGHTNESS} -if [ ${new_brightness} -gt 100 ]; then - new_brightness=100 -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_down b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_down deleted file mode 100755 index db87d23..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_down +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_VOLUME=10 -NOTIF_DURATION=2 - -# Get current value -current_volume=$(volume_get) - -# Compute new volume value -new_volume=0 -if [ ${current_volume} -gt ${STEP_VOLUME} ]; then - let new_volume=${current_volume}-${STEP_VOLUME} -fi - -# Change volume -if [ ${new_volume} -ne ${current_volume} ]; then - volume_set ${new_volume} -fi - -# Notif -notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_up b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_up deleted file mode 100755 index f33e96c..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_up +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_VOLUME=10 -NOTIF_DURATION=2 - -# Get current value -current_volume=$(volume_get) - -# Compute new volume value -let new_volume=${current_volume}+${STEP_VOLUME} -if [ ${new_volume} -gt 100 ]; then - new_volume=100 -fi - -# Change volume -if [ ${new_volume} -ne ${current_volume} ]; then - volume_set ${new_volume} -fi - -# Notif -notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snap b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot similarity index 100% rename from FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snap rename to FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_audio_amp b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_audio_amp index 50034e0..a658a16 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_audio_amp +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_audio_amp @@ -1,37 +1,45 @@ #!/bin/sh +SELF="$(basename ${0})" +SYSTEM_GPIO="/sys/class/gpio" + +# Power Audio Amplifier enable GPIO +GPIO_PF6=166 + +usage() { + >2& echo "Usage: ${SELF} [1 for on, 0 for off]" + exit 1 +} + # Check number of args if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) [1 for on, 0 for off]" - exit 1 + usage fi # Check enable arg enable=${1} -if [ ${enable} -eq 1 ]; then +if [ "${enable}" -eq 1 -o "${enable}" = "on" ]; then - # Turn ON only if volume is not null - if [ "$(volume_get)" -ne "0" ]; then + # Turn ON only if volume is not null + if [ "$(volume get)" -ne "0" ]; then echo "Turning audio amplifier ON" else exit 0 - fi -elif [ ${enable} -eq 0 ]; then + fi + enable=1 +elif [ "${enable}" -eq 0 -o "${enable}" = "off" ]; then echo "Turning audio amplifier OFF" + enable=0 else - echo "Usage: $(basename ${0}) [1 for on, 0 for off]" - exit 1 + usage fi -# PA enable GPIO -GPIO_PF6=166 - -# Export GPIO -if [ ! -d /sys/class/gpio/gpio${GPIO_PF6} ]; then - echo ${GPIO_PF6} > /sys/class/gpio/export +# Export the GPIO if necessary +if [ ! -d "${SYSTEM_GPIO}/gpio${GPIO_PF6}" ]; then + echo ${GPIO_PF6} > "${SYSTEM_GPIO}/export" fi -# Enable/disable cmd -echo "out" > /sys/class/gpio/gpio${GPIO_PF6}/direction -echo ${enable} > /sys/class/gpio/gpio${GPIO_PF6}/value +# Enable/disable the pwoer audio amplifier +echo "out" > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/direction" +echo ${enable} > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value" exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager deleted file mode 100755 index 635f18f..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -LOCK_FILE=/var/lock/gpio_manager.lock - -if [ -f ${LOCK_FILE} ]; then - echo "${LOCK_FILE} already exists" - exit 1 -fi -touch ${LOCK_FILE} -funkey_gpio_management -rm "${LOCK_FILE}" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume new file mode 100755 index 0000000..6b42d12 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume @@ -0,0 +1,130 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +DEFAULT_VOLUME_VALUE=50 +MINIMUM_VOLUME=16 +VOLUME_STEP=10 +NOTIF_DURATION=2 + +usage() { + >&2 echo "Usage: ${SELF} get" + >&2 echo " ${SELF} set new_volume_percentage" + exit 1 +} + +increase_volume() { + + # Get current value + local current_volume=$(get_volume) + + # Compute new volume value + local new_volume=0 + let new_volume=${current_volume}+${VOLUME_STEP} + if [ ${new_volume} -gt 100 ]; then + new_volume=100 + fi + + # Change volume + if [ ${new_volume} -ne ${current_volume} ]; then + set_volume ${new_volume} + fi + + # Notif + notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" +} + +decrease_volume() { + + # Get current value + local current_volume=$(get_volume) + + # Compute new volume value + local new_volume=0 + if [ ${current_volume} -gt ${VOLUME_STEP} ]; then + let new_volume=${current_volume}-${VOLUME_STEP} + fi + + # Change volume + if [ ${new_volume} -ne ${current_volume} ]; then + set_volume ${new_volume} + fi + + # Notif + notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" +} + +get_volume() { + local volume=$(fw_printenv -n volume 2>/dev/null) + if ! [ ! "${volume}" -ne "${volume}" ] 2> /dev/null; then + volume=${DEFAULT_VOLUME_VALUE} + fw_setenv volume ${volume} + fi + echo ${volume} +} + +set_volume() { + + local current_volume=$(get_volume) + + # Set the new volume value (from 0 to 63) into ALSA + local new_volume=${1} + local alsa_volume=$(echo "a = $new_volume * (63 - $MINIMUM_VOLUME) / 100 + \ + $MINIMUM_VOLUME + 0.5; scale = 0; a / 1" | bc -l) + amixer -q sset 'Headphone' ${alsa_volume} unmute + + # Set the new volume value in a bootloader variable + if [ ${?} -eq 0 -a ${current_volume} -ne ${new_volume} ]; then + fw_setenv volume ${new_volume} + fi + + # Turn on/off audio amplifier if necessary + if [ ${current_volume} -eq 0 -a ${new_volume} -ne 0 ]; then + start_audio_amp 1 + elif [ ${current_volume} -ne 0 -a ${new_volume} -eq 0 ]; then + start_audio_amp 0 + fi +} + +# Check number of arguments +if [ ${#} -lt 1 -o ${#} -gt 2 ]; then + usage +fi + +case ${1} in + up) + increase_volume + ;; + + down) + decrease_volume + ;; + + get) + if [ ${#} -ne 1 ]; then + usage + fi + get_volume + ;; + + set) + if [ ${#} -ne 2 ]; then + usage + fi + + # Make sure the argument is a positive number <= 100 + if [ -n "${2}" ] && [ "${2}" -eq "${2}" ] 2>/dev/null && \ + [ "${2}" -ge 0 ] && [ "${2}" -le 100 ]; then + set_volume "${2}" + else + usage + fi + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get deleted file mode 100755 index a387a4d..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -VOLUME_DEFAULT_VALUE=50 - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -# Sanity check: Check if integer -volume=$(fw_printenv -n volume 2>/dev/null) -if ! [ ! "${volume}" -ne "${volume}" ] 2> /dev/null; then - volume=${VOLUME_DEFAULT_VALUE} - fw_setenv volume ${volume} -fi -echo ${volume} -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get_alsa b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get_alsa deleted file mode 100755 index e30faff..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get_alsa +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -amixer sget 'Headphone' | tail -1 | cut -d' ' -f7 | sed 's/[^0-9]//g' -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set deleted file mode 100755 index 41c9619..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_volume_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong volume percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Scale new volume value between 0 and 63 -volume_percent=${1} -vol_mini=16; -volume_scaled=$(echo "a = $volume_percent * (63 - $vol_mini) / 100 + $vol_mini + 0.5; scale = 0; a / 1" | bc -l) -#echo $volume_scaled - -# Get current value -current_volume=$(volume_get) - -# Set new volume -amixer -q sset 'Headphone' ${volume_scaled} unmute - -# Change new volume value in volume file -if [ ${?} -eq 0 -a ${current_volume} -ne ${volume_percent} ]; then - fw_setenv volume ${volume_percent} -fi - -# Turn on/off audio amplifier if necessary -if [ ${current_volume} -eq 0 -a ${volume_percent} -ne 0 ]; then - start_audio_amp 1 -elif [ ${current_volume} -ne 0 -a ${volume_percent} -eq 0 ]; then - start_audio_amp 0 -fi - -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set_alsa b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set_alsa deleted file mode 100755 index 2153152..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set_alsa +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: ${0} new_volume_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong volume percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Scale new volume value between 0 and 63 -volume_percent=${1} -volume_scaled=$(echo "a = ${1} * 63 / 100 + 0.5; scale = 0; a / 1" | bc -l) - -# Get current value -current_volume=$(volume_get) - -# Turn on/off ampli if necessary -if [ ${current_volume} -eq 0 -a ${volume_scaled} -ne 0 ]; then - start_audio_amp 1 -elif [ ${current_volume} -ne 0 -a ${volume_scaled} -eq 0 ]; then - start_audio_amp 0 -fi - -# Set new volume -amixer -q sset 'Headphone' ${volume_scaled} unmute -exit 0 diff --git a/FunKey/package/FCEUX/FCEUX.mk b/FunKey/package/FCEUX/FCEUX.mk index e3a7235..c238a49 100644 --- a/FunKey/package/FCEUX/FCEUX.mk +++ b/FunKey/package/FCEUX/FCEUX.mk @@ -4,7 +4,7 @@ # ################################################################################ -FCEUX_VERSION = f492414 +FCEUX_VERSION = eacbc9b FCEUX_SITE_METHOD = git FCEUX_SITE = https://github.com/FunKey-Project/fceux.git FCEUX_LICENSE = GPL-2.0 diff --git a/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk b/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk index cce0e34..314dfba 100644 --- a/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk +++ b/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk @@ -4,7 +4,7 @@ # ################################################################################ -PCSX_REARMED_VERSION = 0f104cb +PCSX_REARMED_VERSION = e418c99 PCSX_REARMED_SITE_METHOD = git PCSX_REARMED_SITE = https://github.com/FunKey-Project/pcsx_rearmed.git PCSX_REARMED_LICENSE = GPL-2.0 diff --git a/FunKey/package/PocketSNES/PocketSNES.mk b/FunKey/package/PocketSNES/PocketSNES.mk index bfdd139..f76cef1 100644 --- a/FunKey/package/PocketSNES/PocketSNES.mk +++ b/FunKey/package/PocketSNES/PocketSNES.mk @@ -4,7 +4,7 @@ # ################################################################################ -POCKETSNES_VERSION = 1d50e6a +POCKETSNES_VERSION = 7ced860 POCKETSNES_SITE_METHOD = git POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git POCKETSNES_LICENSE = GPL-2.0 diff --git a/FunKey/package/commander/commander.mk b/FunKey/package/commander/commander.mk index 4b6af7a..6f4aa10 100644 --- a/FunKey/package/commander/commander.mk +++ b/FunKey/package/commander/commander.mk @@ -3,7 +3,7 @@ # commander # ############################################################# -COMMANDER_VERSION = 34b8d40 +COMMANDER_VERSION = 9ba64f0 COMMANDER_SITE_METHOD = git COMMANDER_SITE = https://github.com/FunKey-Project/commander.git COMMANDER_LICENSE = GPL-2.0 diff --git a/FunKey/package/gmenu2x/gmenu2x.mk b/FunKey/package/gmenu2x/gmenu2x.mk index 2208ae2..e1f02ba 100644 --- a/FunKey/package/gmenu2x/gmenu2x.mk +++ b/FunKey/package/gmenu2x/gmenu2x.mk @@ -3,7 +3,7 @@ # gmenu2x # ############################################################# -GMENU2X_VERSION = 1b1c251 +GMENU2X_VERSION = de79b3b GMENU2X_SITE_METHOD = git GMENU2X_SITE = https://github.com/FunKey-Project/gmenu2x.git GMENU2X_LICENSE = GPL-2.0 diff --git a/FunKey/package/gnuboy/gnuboy.mk b/FunKey/package/gnuboy/gnuboy.mk index 6172abb..00a080a 100644 --- a/FunKey/package/gnuboy/gnuboy.mk +++ b/FunKey/package/gnuboy/gnuboy.mk @@ -4,7 +4,7 @@ # ################################################################################ -GNUBOY_VERSION = 444d2c7 +GNUBOY_VERSION = dc763dc GNUBOY_SITE_METHOD = git GNUBOY_SITE = https://github.com/FunKey-Project/gnuboy.git GNUBOY_LICENSE = GPL-2.0 diff --git a/FunKey/package/gpsp/gpsp.mk b/FunKey/package/gpsp/gpsp.mk index 5ffa768..f4905ce 100644 --- a/FunKey/package/gpsp/gpsp.mk +++ b/FunKey/package/gpsp/gpsp.mk @@ -4,7 +4,7 @@ # ################################################################################ -GPSP_VERSION = a6d535d +GPSP_VERSION = 0c16af5 GPSP_SITE_METHOD = git GPSP_SITE = https://github.com/FunKey-Project/gpsp.git GPSP_LICENSE = GPL-2.0 diff --git a/FunKey/package/mednafen/mednafen.mk b/FunKey/package/mednafen/mednafen.mk index 6d4ff40..3e77542 100644 --- a/FunKey/package/mednafen/mednafen.mk +++ b/FunKey/package/mednafen/mednafen.mk @@ -4,7 +4,7 @@ # ################################################################################ -MEDNAFEN_VERSION = f85ec22 +MEDNAFEN_VERSION = 5064db7 MEDNAFEN_SITE_METHOD = git MEDNAFEN_SITE = https://github.com/FunKey-Project/mednafen-git.git MEDNAFEN_LICENSE = GPL-2.0+ diff --git a/FunKey/package/picodrive/picodrive.mk b/FunKey/package/picodrive/picodrive.mk index 51bbdd6..14eab0e 100644 --- a/FunKey/package/picodrive/picodrive.mk +++ b/FunKey/package/picodrive/picodrive.mk @@ -4,7 +4,7 @@ # ################################################################################ -PICODRIVE_VERSION = 49326b6 +PICODRIVE_VERSION = 8fe4e96 PICODRIVE_SITE_METHOD = git PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git PICODRIVE_LICENSE = MAME diff --git a/FunKey/package/retrofe/retrofe.mk b/FunKey/package/retrofe/retrofe.mk index 101676a..69404ed 100644 --- a/FunKey/package/retrofe/retrofe.mk +++ b/FunKey/package/retrofe/retrofe.mk @@ -4,7 +4,7 @@ # ################################################################################ -RETROFE_VERSION = 829e59b +RETROFE_VERSION = 625207d RETROFE_SITE_METHOD = git RETROFE_SITE = https://github.com/FunKey-Project/RetroFE.git RETROFE_DEPENDENCIES = gstreamer1 gst1-plugins-base sdl sdl_image sdl_mixer sdl_sound sdl_ttf libglib2 sqlite zlib diff --git a/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf b/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf index 49ef00e..c1aa354 100644 --- a/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf +++ b/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf @@ -15,11 +15,11 @@ MAP B TO KEY KEY_B MAP X TO KEY KEY_X MAP Y TO KEY KEY_Y MAP MENU TO KEY KEY_Q -MAP FN+UP TO COMMAND snap -MAP FN+A TO COMMAND quick_action_volume_up -MAP FN+Y TO COMMAND quick_action_volume_down -MAP FN+X TO COMMAND quick_action_bright_up -MAP FN+B TO COMMAND quick_action_bright_down +MAP FN+UP TO COMMAND snaphsot +MAP FN+A TO COMMAND volume up +MAP FN+Y TO COMMAND volume down +MAP FN+X TO COMMAND brightness up +MAP FN+B TO COMMAND brightness down MAP FN+L TO KEY KEY_V MAP FN+R TO KEY KEY_O MAP FN+L+R TO COMMAND display_notif_system_stats diff --git a/Recovery/board/funkey/rootfs-overlay/root/.profile b/Recovery/board/funkey/rootfs-overlay/root/.profile index 5e99a35..02dd032 100755 --- a/Recovery/board/funkey/rootfs-overlay/root/.profile +++ b/Recovery/board/funkey/rootfs-overlay/root/.profile @@ -36,6 +36,6 @@ resize() { fi } -# Reset saved brightness -echo "Reset saved brightness" -brightness_set $(brightness_get) >/dev/null 2>&1 +# Restore saved brightness +echo "Restore saved brightness" +brightness set $(brightness get) >/dev/null 2>&1 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get deleted file mode 100755 index d664293..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -BRIGHTNESS_DEFAULT_VALUE=100 - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -# Sanity check: Check if integer -brightness=$(fw_printenv -n brightness 2>/dev/null) -if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then - brightness=${BRIGHTNESS_DEFAULT_VALUE} - fw_setenv brightness ${brightness} -fi -echo ${brightness} -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs deleted file mode 100755 index a682958..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -let brightness=$(cat ${SYSTEM_BRIGHTNESS})*10-10 -echo ${brightness} -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set deleted file mode 100755 index 8d45575..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi -brightness_percentage=${1} - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} - -# Set new brightness value in brightness file -if [ ${?} -eq 0 -a $(brightness_get) -ne ${brightness_percentage} ]; then - fw_setenv brightness ${brightness_percentage} -fi -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs deleted file mode 100755 index 424a3d8..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down deleted file mode 100755 index b2170d5..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -new_brightness=0 -if [ ${current_brightness} -gt ${STEP_BRIGHTNESS} ]; then - let new_brightness=${current_brightness}-${STEP_BRIGHTNESS} -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -#notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up deleted file mode 100755 index 71235b5..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -let new_brightness=${current_brightness}+${STEP_BRIGHTNESS} -if [ ${new_brightness} -gt 100 ]; then - new_brightness=100 -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -#notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snap b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot similarity index 100% rename from Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snap rename to Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager deleted file mode 100755 index 635f18f..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -LOCK_FILE=/var/lock/gpio_manager.lock - -if [ -f ${LOCK_FILE} ]; then - echo "${LOCK_FILE} already exists" - exit 1 -fi -touch ${LOCK_FILE} -funkey_gpio_management -rm "${LOCK_FILE}" -exit 0