Closed mgrouch closed 4 months ago
On m5stack tough (esp32) I was able to control backlight like this:
#define MAX_LCD_V 3300
#define MIN_LCD_V 2500
static void set_lcd_backlight_voltage(int pct) {
if (pct >= 0 && pct <= 100) {
int lcdVoltage = MIN_LCD_V + (MAX_LCD_V - MIN_LCD_V) * pct / 100;
M5.Axp.SetLDOVoltage(3, lcdVoltage); // MIN_LCD_V to MAX_LCD_V
}
}
How can I do same on Linux?
Thanks
Currently, you can adjust the LCD backlight through sys
, with the relevant command being echo 0 > /sys/class/backlight/axp2101_m5stack_bl/brightness
. A simple Python 3 call would be: python3 -c 'f=open("/sys/class/backlight/axp2101_m5stack_bl/brightness", "w");f.write("100");f.close()'
.
core-config is a great tool that allows you to adjust the screen backlight directly in the terminal or command line interface. Simply execute code-config --set-lcd-backlight 0
to turn off the backlight, and code-config --set-lcd-backlight 100
to turn it on.
When it comes to reading the touchscreen input, you need to pay attention to the events in Linux input, with the interface located at /dev/input/event0
. The C code will be uploaded later.
It doesn't look like
echo 0 > /sys/class/backlight/axp2101_m5stack_bl/brightness
turns off backlight. I can still see previous picture just very very dark.
Don't worry, this might be caused by light reflecting from elsewhere onto the screen. If you mind it a lot, you can erase the framebuffer buffer using a program, for example, cat /dev/zero > /dev/fb1
.
This is an example of reading touch using CoreMP135. Hope it helps you. https://github.com/m5stack/M5Stack_Linux_Libs/tree/master/examples/lcd_hello_world
Thanks a lot!
There are examples for displaying things on ILI9342C using framebuffer and LVGL. I do not see how to turn off backlight on ILI9342C. Is there some code example? Or command line utility with the code to control brightness? I was able to code that on m5stack tough on esp32 which has same ILI9342C.
Also how to wake up screen by touch? I guess with brightness off touch functions are still there. So I need example of code listening for touch event and controlling backlight (voltage of it?) on ILI9342C.
Thanks