Android LED control from the shell

I saw several questions (and blog posts, elsewhere) with Java code for controlling the notification LED on an Android device. This is not what I am looking for.

I am wondering if there is a way to access the appropriate commands / controls / frameworks from the shell (Perl, ruby).

What I want, ultimately, is a very simple β€œheartbeat” impulse - when the device is turned on and the display is off, blink at me.

Alternatively, if someone wrote a really simple β€œtoy” application that flashes an LED, I would love to play with it.

+6
source share
1 answer

You can find all the LEDs of your device under

/sys/class/leds/ 

In my case, I have the following LEDs

 amber button-backlight flashlight green lcd-backlight 

If I have a look in green, I see

 > cd green > ls blink brightness currents device lut_coefficient max_brightness off_timer power pwm_coefficient subsystem trigger uevent 

These files are interfaces to the kernel module, which controls the LEDs. In this case, I consider them to be char devices. You can use the "echo" and "cat" commands to communicate with the kernel module. Here is an example ..

 echo 1 > brightness # Turn on led echo 0 > brightness # Turn off led 

To realize the pulse "heartbeat", as you mentioned, I would look at the "blinking". If you don't want to do reverse engineering, this might be a good entry point to check what happens in the leds-gpio.c kernel

+10
source

Source: https://habr.com/ru/post/947691/


All Articles