diff --git a/packages/hardware/quirks/devices/ayn Loki Zero/010-led_control b/packages/hardware/quirks/devices/ayn Loki Zero/010-led_control index 5a2f70e67..f49d91971 100755 --- a/packages/hardware/quirks/devices/ayn Loki Zero/010-led_control +++ b/packages/hardware/quirks/devices/ayn Loki Zero/010-led_control @@ -4,4 +4,5 @@ cat </storage/.config/profile.d/010-led_control DEVICE_LED_CONTROL="true" +DEVICE_LED_BRIGHTNESS="true" EOF diff --git a/packages/hardware/quirks/devices/ayn Loki Zero/bin/ledcontrol b/packages/hardware/quirks/devices/ayn Loki Zero/bin/ledcontrol index 5116d3406..6c2ddedd3 100755 --- a/packages/hardware/quirks/devices/ayn Loki Zero/bin/ledcontrol +++ b/packages/hardware/quirks/devices/ayn Loki Zero/bin/ledcontrol @@ -48,10 +48,45 @@ function off() { ec_save } +function intensity() { + printf "0x%X\n" $((${1} / ${2})) +} + +GETBRIGHTNESS=$(get_setting led.brightness) +if [ ! -z "${2}" ] +then + LEDBRIGHTNESS=${2} + debug_out "Arg[2]: ${2}" +elif [ ! -z "${GETBRIGHTNESS}" ] +then + LEDBRIGHTNESS=${GETBRIGHTNESS} + debug_out "GETBRIGHTESS: ${GETBRIGHTNESS}" +else + debug_out "NO SETTING: max" + LEDBRIGHTNESS=mid + set_setting led.brightness max +fi + +case ${LEDBRIGHTNESS} in + max) + LEDBRIGHTNESS=1 + set_setting led.brightness max + ;; + mid) + LEDBRIGHTNESS=2 + set_setting led.brightness mid + ;; + min) + LEDBRIGHTNESS=4 + set_setting led.brightness min + ;; +esac + case $1 in red) off - ec_set ${RGB_RED} 0xFF + COLOR=$(intensity 0xFF ${LEDBRIGHTNESS}) + ec_set ${RGB_RED} ${COLOR} ec_set ${RGB_GREEN} 0x00 ec_set ${RGB_BLUE} 0x00 ec_save @@ -59,33 +94,37 @@ case $1 in ;; green) off + COLOR=$(intensity 0xFF ${LEDBRIGHTNESS}) ec_set ${RGB_RED} 0x00 - ec_set ${RGB_GREEN} 0xFF + ec_set ${RGB_GREEN} ${COLOR} ec_set ${RGB_BLUE} 0x00 ec_save set_setting led.color green ;; blue) off + COLOR=$(intensity 0xFF ${LEDBRIGHTNESS}) ec_set ${RGB_RED} 0x00 ec_set ${RGB_GREEN} 0x00 - ec_set ${RGB_BLUE} 0xFF + ec_set ${RGB_BLUE} ${COLOR} ec_save set_setting led.color blue ;; teal) off + COLOR=$(intensity 0x80 ${LEDBRIGHTNESS}) ec_set ${RGB_RED} 0x00 - ec_set ${RGB_GREEN} 0x80 - ec_set ${RGB_BLUE} 0x80 + ec_set ${RGB_GREEN} ${COLOR} + ec_set ${RGB_BLUE} ${COLOR} ec_save set_setting led.color teal ;; purple) off - ec_set ${RGB_RED} 0x80 + COLOR=$(intensity 0x80 ${LEDBRIGHTNESS}) + ec_set ${RGB_RED} ${COLOR} ec_set ${RGB_GREEN} 0x00 - ec_set ${RGB_BLUE} 0x80 + ec_set ${RGB_BLUE} ${COLOR} ec_save set_setting led.color purple ;; @@ -96,6 +135,9 @@ case $1 in default) del_setting led.color ;; + brightness) + set_setting led.brightness ${2} + ;; *) COLOR=$(get_setting led.color) if [ ! -z "${COLOR}" ]