pimoroni / fanshim-python

Python library for the Fan SHIM for Raspberry Pi
https://shop.pimoroni.com/products/fan-shim
MIT License
295 stars 85 forks source link

Using gpiozero to read temperature #88

Open kconkas opened 4 years ago

kconkas commented 4 years ago

Fixes #13 (which is still present)

Gadgetoid commented 4 years ago

Thanks for making this a PR.

However! It looks like the CPUTemperature class does nothing but read /sys/class/thermal/thermal_zone0/temp, which we'd be better positioned to do directly without the additional dependency.

This is ruminated about in #73 - I think just adding the code in the linked issue modified to match the CPUTemperature class from gpiozero would suffice:

def get_cpu_temp():
    with open("/sys/class/thermal/thermal_zone0/temp", "r") as f:
        return float(f.readline().strip()) / 1000

I know it's been a while since you raised this- but would you prefer to make this change so I can merge this PR? I like the Git history to reflect credit where credit is due.