fbtft resends data transfer command only when necessary

This commit is contained in:
Vincent Buso 2022-12-12 07:34:14 +01:00
parent d50676f1ca
commit c8607a71f1
1 changed files with 17 additions and 17 deletions

View File

@ -37,25 +37,25 @@ trap toggle_perform SIGUSR1
while true; do while true; do
if [ ${perform} -eq 1 ]; then if [ ${perform} -eq 1 ]; then
# Compute stats # Compute stats
cpu=$(printf "%.0f\n" $(mpstat -P ALL $UPDATE_PERIOD 1 | tail -1 | awk '{print 100-$12}')) cpu=$(printf "%.0f\n" $(mpstat -P ALL $UPDATE_PERIOD 1 | tail -1 | awk '{print 100-$12}'))
ram_mem=$(printf "%.0f\n" $(free | grep Mem | awk '{print $3/$2 * 100.0}')) ram_mem=$(printf "%.0f\n" $(free | grep Mem | awk '{print $3/$2 * 100.0}'))
ram_swap=$(printf "%.0f\n" $(free | grep Swap | awk '{print $3/$2 * 100.0}')) ram_swap=$(printf "%.0f\n" $(free | grep Swap | awk '{print $3/$2 * 100.0}'))
ip_addr=$(ifconfig usb0 | grep "inet " | awk -F'[: ]+' '{ print $4 }') ip_addr=$(ifconfig usb0 | grep "inet " | awk -F'[: ]+' '{ print $4 }')
# Notif # Notif
if [ ${notif_dirty} -eq 1 ]; then if [ ${notif_dirty} -eq 1 ]; then
notif clear notif clear
notif_dirty=0 notif_dirty=0
else else
if [ "x${ip_addr}" != "x" ]; then if [ "x${ip_addr}" != "x" ]; then
notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}" notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}"
else else
notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%"
fi fi
fi fi
else else
sleep ${UPDATE_PERIOD} sleep ${UPDATE_PERIOD}
fi fi
done done
exit 0 exit 0