This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
comfilepi:controlling_the_lcd_backlight:index [2023/09/14 12:57] COMFILE Technology [Bash Script Implementation] |
comfilepi:controlling_the_lcd_backlight:index [2023/12/06 10:00] (current) COMFILE Technology [Controlling the LCD Backlight] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Controlling the LCD Backlight ====== | ====== Controlling the LCD Backlight ====== | ||
- | The ComfilePi's LCD backlight is connected to GPIO 34. The backlight can be turned on or off via the command line or via a programming language. | + | The ComfilePi's LCD backlight is connected to one of the panel PC's internal GPIO pins. The backlight can be turned on or off via the command line or via a programming language. |
Line 257: | Line 257: | ||
g++ backlight_service.cpp -lX11 -lXext -lpigpiod_if2 -o backlight_service | g++ backlight_service.cpp -lX11 -lXext -lpigpiod_if2 -o backlight_service | ||
</code> | </code> | ||
- | |||
- | Run ''journalctl -t backlight_service -r'' to view the log entries. | ||
==== Bash Script Implementation ==== | ==== Bash Script Implementation ==== | ||
Line 265: | Line 263: | ||
<code bash> | <code bash> | ||
#!/bin/bash | #!/bin/bash | ||
- | |||
- | export DISPLAY=":0.0" | ||
PWM_PIN=31 | PWM_PIN=31 | ||
Line 272: | Line 268: | ||
# Set pins as output | # Set pins as output | ||
- | gpio mode $PWM_PIN output | + | raspi-gpio set $PWM_PIN op |
- | gpio mode $PIN output | + | raspi-gpio set $PIN op |
# Start with both pins HIGH. If either of the | # Start with both pins HIGH. If either of the | ||
# pins go LOW, the backlight will turn off. | # pins go LOW, the backlight will turn off. | ||
- | gpio write $PWM_PIN 1 | + | raspi-gpio set $PWM_PIN dh |
- | gpio write $PIN 1 | + | raspi-gpio set $PIN dh |
# Get the current state | # Get the current state | ||
Line 299: | Line 295: | ||
if [ "$CURRENT_STATUS" = "On" ]; then | if [ "$CURRENT_STATUS" = "On" ]; then | ||
logger -p info -t "backlight_service" -s "Turning Backlight On" | logger -p info -t "backlight_service" -s "Turning Backlight On" | ||
- | gpio write $PIN 1 | + | raspi-gpio set $PIN dh |
else | else | ||
logger -p info -t "backlight_service" -s "Turning Backlight Off" | logger -p info -t "backlight_service" -s "Turning Backlight Off" | ||
- | gpio write $PIN 0 | + | raspi-gpio set $PIN dl |
fi | fi | ||
LAST_STATUS=$CURRENT_STATUS | LAST_STATUS=$CURRENT_STATUS | ||
Line 318: | Line 314: | ||
Add the line ''@xset dpms 0 0 {timeout_in_seconds}'' to the //autostart// file to set the timeout each time the desktop loads. | Add the line ''@xset dpms 0 0 {timeout_in_seconds}'' to the //autostart// file to set the timeout each time the desktop loads. | ||
+ | |||
+ | Run ''journalctl -t backlight_service -r'' to view the log entries. | ||