Exemple #1
0
    def __init__(self,
                 pin_fancontrol=18,
                 pin_button=17,
                 button_poll_delay=0.05):
        """FAN Shim.

        :param pin_fancontrol: BCM pin for fan on/off
        :param pin_button: BCM pin for button

        """
        self._pin_fancontrol = pin_fancontrol
        self._pin_button = pin_button
        self._poll_delay = button_poll_delay
        self._button_press_handler = None
        self._button_release_handler = None
        self._button_hold_handler = None
        self._button_hold_time = 2.0
        self._t_poll = None

        atexit.register(self._cleanup)

        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self._pin_fancontrol, GPIO.OUT)
        GPIO.setup(self._pin_button, GPIO.IN, pull_up_down=GPIO.PUD_UP)

        plasma.set_clear_on_exit(True)
        plasma.set_light_count(1)
        plasma.set_light(0, 0, 0, 0)
    def __init__(self,
                 pin_fancontrol=18,
                 pin_button=17,
                 button_poll_delay=0.05):
        """FAN Shim.

        :param pin_fancontrol: BCM pin for fan on/off
        :param pin_button: BCM pin for button

        """
        self._pin_fancontrol = pin_fancontrol
        self._pin_button = pin_button
        self._poll_delay = button_poll_delay
        self._button_press_handler = None
        self._button_release_handler = None
        self._button_hold_handler = None
        self._button_hold_time = 2.0
        self._t_poll = None

        atexit.register(self._cleanup)

        #Original Versiom
        #GPIO.setwarnings(False)
        #GPIO.setmode(GPIO.BCM)
        #GPIO.setup(self._pin_fancontrol, GPIO.OUT)
        #GPIO.setup(self._pin_button, GPIO.IN, pull_up_down=GPIO.PUD_UP)

        #PWM Version
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)

        # PWM Version added parameters
        self.pwm_freq = 8
        self.pwm_speed = 80
        self.fan_state = True

        GPIO.setup(self._pin_button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(self._pin_fancontrol, GPIO.OUT)
        self.pwm_out = GPIO.PWM(self._pin_fancontrol, 1)
        self.pwm_out.start(0)
        self.pwm_out.ChangeFrequency(self.pwm_freq)
        self.pwm_out.ChangeDutyCycle(self.pwm_speed)

        plasma.set_clear_on_exit(True)
        plasma.set_light_count(1)
        plasma.set_light(0, 0, 0, 0)