99import sys
1010
1111
12- T_MIN = 35
13- T_MAX = 95
14-
15-
1612parser = argparse .ArgumentParser ()
1713parser .add_argument ('--threshold' , type = float , default = - 1 , help = 'Temperature threshold in degrees C to enable fan' )
1814parser .add_argument ('--hysteresis' , type = float , default = - 1 , help = 'Distance from threshold before fan is disabled' )
2420parser .add_argument ('--verbose' , action = 'store_true' , default = False , help = 'Output temp and fan status messages' )
2521parser .add_argument ('--nobutton' , action = 'store_true' , default = False , help = 'Disable button input' )
2622parser .add_argument ('--noled' , action = 'store_true' , default = False , help = 'Disable LED control' )
23+ parser .add_argument ('--brightness' , type = float , default = 255.0 , help = 'LED brightness, from 0 to 255' )
2724
2825args = parser .parse_args ()
2926
@@ -44,20 +41,11 @@ def update_led_temperature(temp):
4441 temp = 1.0 - temp
4542 temp *= 120.0
4643 temp /= 360.0
47- r , g , b = [int (c * 255.0 ) for c in colorsys .hsv_to_rgb (temp , 1.0 , 1 .0 )]
44+ r , g , b = [int (c * 255.0 ) for c in colorsys .hsv_to_rgb (temp , 1.0 , args . brightness / 255 .0 )]
4845 fanshim .set_light (r , g , b )
4946 led_busy .release ()
5047
5148
52- def update_led (state ):
53- if args .noled :
54- return
55- if state :
56- fanshim .set_light (0 , 255 , 0 )
57- else :
58- fanshim .set_light (255 , 0 , 0 )
59-
60-
6149def get_cpu_temp ():
6250 t = psutil .sensors_temperatures ()
6351 for x in ['cpu-thermal' , 'cpu_thermal' ]:
@@ -77,7 +65,6 @@ def set_fan(status):
7765 changed = False
7866 if status != enabled :
7967 changed = True
80- # update_led(status)
8168 fanshim .set_fan (status )
8269 enabled = status
8370 return changed
0 commit comments