def __init__(self, pin_fancontrol=18, pin_button=17): """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._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) self.start_polling()
def set_light(self, r, g, b): """Set LED. :param r: Red (0-255) :param g: Green (0-255) :param b: Blue (0-255) """ plasma.set_light(0, r, g, b) plasma.show()
def update_led_temperature(self,temp,min_temp,max_temp,brightness): temp = float(temp) temp -= max_temp temp /= float(min_temp - max_temp) temp = max(0, min(1, temp)) temp = 1.0 - temp temp *= 120.0 temp /= 360.0 r, g, b = [int(c * 255.0) for c in colorsys.hsv_to_rgb(temp, 1.0, brightness / 255.0)] plasma.set_light(0, r, g, b) plasma.show()
config.dbug = False config.dbug_ftp = False config.exit_flag = False config.new_config_wanted = False config.scan_count = 0 headings = [ "Count", "Cpu Load", "Temp", "Throttle", "Fan Speed", "Fan Freq", "Cpu Freq", "Cpu Mem", "Cpu Disk", "Loop Times", "Message" ] cpu_buffer = class_text_buffer(headings, config) #Fan shim related plasma.set_clear_on_exit(True) plasma.set_light_count(1) plasma.set_light(0, 0, 0, 0) control = class_control(config) # Set The Initial Conditions sub_count = 0.001 the_end_time = datetime.now() last_total = 0 loop_time = 0 correction = 4.02 # Ensure start right by inc buffer last_fan_state = True buffer_increment_flag = False refresh_time = 4.2 * config.scan_delay went_off = datetime.now()