Sample Header Ad - 728x90

How to periodically switch on and switch off flashlight with 1kHz rate on rooted Redmi Note 5 Oro?

0 votes
1 answer
654 views
My objective is to write a shell script to periodically turn off and on my phone's flashlight (about 1 kHz or 500Hz). My phone is rooted. So I gained superuser shell access (#) These are the files under my sys/class/leds/flashlight
whyred:/sys/class/leds/flashlight # ls
brightness device max_brightness power subsystem trigger uevent
(Original screenshot of the terminal) I was able to modify the content of the brightness file and was able to manually switch off and on my flashlight. However, I want to periodically switch on and off with a delay and for that, I need a timer trigger. But within the trigger file above, there is no delay section indicated. There was just some contents within the file (no numbers)
whyred:/sys/class/leds/flashlight # cat trigger
[none] bkl-trigger switch0_trigger flash0_trigger flash1_trigger torch0_trigger torch1_trigger switch1_trigger flash2_trigger torch2_trigger dc-online usb-online main-online pc_port-online battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid rfkill0 mmc0 mmc1 bms-online parallel-online rfkill1
(Original screenshot of the terminal) I was able to clock into a period of about 1-3ms by writing a bash script, that echoes brightness 100 followed by sleep and then echoes 0 brightness Script:
while [ 1 le 100]
do
echo "100" > ~/sys/class/leds/brightness  
sleep(0.001)  
echo "100" > ~/sys/class/leds/brightness)
sleep(0.001)
done  # end
But I want at least a 1 kHz frequency, so a timer is the one, sleep function is not advisable. How can I about attaining my objective?
Asked by Edmund Kemper (1 rep)
Apr 12, 2022, 01:48 PM
Last activity: May 4, 2022, 05:22 AM