Skip to content

Instantly share code, notes, and snippets.

@Lessica
Created March 25, 2022 17:07
Show Gist options
  • Save Lessica/30240b63ac0e47d80a919209ea006c60 to your computer and use it in GitHub Desktop.
Save Lessica/30240b63ac0e47d80a919209ea006c60 to your computer and use it in GitHub Desktop.
Configure Raspberry Pi + Argon One Case for Lineage OS
#!/system/bin/sh
sleeptime=120
while true
do
cputemp=$(cat /sys/class/thermal/thermal_zone0/temp)
if [[ $cputemp -lt 55000 ]]; then
fanspeed="0x00"
elif [ $cputemp -ge 55000 -a $cputemp -lt 60000 ]; then
fanspeed="0x10"
elif [ $cputemp -ge 60000 -a $cputemp -lt 65000 ]; then
fanspeed="0x32"
elif [ $cputemp -ge 65000 ]; then
fanspeed="0x64"
fi
i2cget -y 1 0x01a $fanspeed
sleep $sleeptime
done
@diabolicdesigns
Copy link

This script worked for me:

#!/system/bin/sh

sleeptime=120

while true; do
# read temp in millidegrees
temp=$(cat /sys/class/thermal/thermal_zone0/temp)

# pick a duty-cycle byte (0x00–0x64)
if   [ "$temp" -lt 55000 ]; then  speed=0x19   # 25%
elif [ "$temp" -lt 60000 ]; then  speed=0x32   # 50%
elif [ "$temp" -lt 65000 ]; then  speed=0x4B   # 75%
else                             speed=0x64   # 100%
fi

# write it to PWM register 0x80, byte mode
i2cset -y 1 0x1a 0x80 "$speed" b

sleep $sleeptime

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment