88
99
1010class FanShim ():
11- def __init__ (self , pin_fancontrol = 18 , pin_button = 17 , button_poll_delay = 0.05 ):
11+ def __init__ (self , pin_fancontrol = 18 , pin_button = 17 , button_poll_delay = 0.05 , disable_button = False , disable_led = False ):
1212 """FAN Shim.
1313
1414 :param pin_fancontrol: BCM pin for fan on/off
@@ -24,24 +24,36 @@ def __init__(self, pin_fancontrol=18, pin_button=17, button_poll_delay=0.05):
2424 self ._button_hold_time = 2.0
2525 self ._t_poll = None
2626
27+ self ._disable_button = disable_button
28+ self ._disable_led = disable_led
29+
2730 GPIO .setwarnings (False )
2831 GPIO .setmode (GPIO .BCM )
2932 GPIO .setup (self ._pin_fancontrol , GPIO .OUT )
30- GPIO .setup (self ._pin_button , GPIO .IN , pull_up_down = GPIO .PUD_UP )
3133
32- self ._led = apa102 .APA102 (1 , 15 , 14 , None , brightness = 0.05 )
34+ if not self ._disable_button :
35+ GPIO .setup (self ._pin_button , GPIO .IN , pull_up_down = GPIO .PUD_UP )
36+
37+ if not self ._disable_led :
38+ self ._led = apa102 .APA102 (1 , 15 , 14 , None , brightness = 0.05 )
3339
3440 atexit .register (self ._cleanup )
3541
3642 def start_polling (self ):
3743 """Start button polling."""
44+ if self ._disable_button :
45+ return
46+
3847 if self ._t_poll is None :
3948 self ._t_poll = Thread (target = self ._run )
4049 self ._t_poll .daemon = True
4150 self ._t_poll .start ()
4251
4352 def stop_polling (self ):
4453 """Stop button polling."""
54+ if self ._disable_button :
55+ return
56+
4557 if self ._t_poll is not None :
4658 self ._running = False
4759 self ._t_poll .join ()
@@ -112,6 +124,9 @@ def set_light(self, r, g, b, brightness=None):
112124 :param b: Blue (0-255)
113125
114126 """
127+ if self ._disable_led :
128+ return
129+
115130 self ._led .set_pixel (0 , r , g , b )
116131 if brightness is not None :
117132 self ._led .set_brightness (0 , brightness )
0 commit comments