desktop-environment/scripts/send_temps_to_lcd.sh

31 lines
1.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# Temperature printing function
print_temp(){
temp="CPU: $(sensors | grep 'Tccd1' | awk '{print substr($2, 2)}')?GPU: $(sensors | grep "edge" | awk '{print substr($2, 2)}')"
echo "$temp"
}
# The device should be set with the LCD_SERIAL_DEVICE environment variable
# Sets the baud to 115200 which is what the arduino is set to communicate on
#stty -F $LCD_SERIAL_DEVICE 115200
# make reset to set up all the options for serial correctly
cd $LCD_PROGRAM_LOCATION && make reset && cd ~
# Leave a process running in the background that keeps the serial connection alive
tail -f $LCD_SERIAL_DEVICE > /dev/null &
sleep 1
# Update the temps once per second
while true
do
# Every 30 minutes, reset the arduino and start again
# This hopefully fixes the issue of the LCD not updating after a while (usually over an hour)
for i in {1..1800}; do
echo "CPU: $(sensors | grep 'Tccd1' | awk '{print substr($2, 2)}')?GPU: $(sensors | grep "edge" | awk '{print substr($2, 2)}')" | awk '{ gsub("\xc2\xb0", "\xdf", $0); print }' > $LCD_SERIAL_DEVICE
sleep 1
done
cd $LCD_PROGRAM_LOCATION && make reset && cd ~
done