def graph_CPUTemp(lednumber): CPUTemp = getCPUtemperature() if float(CPUTemp) > 60.0: #print CPUTemp backlight.graph_set_led_duty(0, 1) backlight.graph_set_led_state(lednumber, 1) else: backlight.graph_set_led_state(lednumber, 0)
def init_display(): backlight.graph_set_led_duty(0, 1) if flipped: for i in range(len(SPECTRUM_CHARS_FLIP)): lcd.create_char(i, SPECTRUM_CHARS_FLIP[i]) else: for i in range(len(SPECTRUM_CHARS)): lcd.create_char(i, SPECTRUM_CHARS[i])
class GracefulKiller: kill_now = False def __init__(self): signal.signal(signal.SIGINT, self.exit_gracefully) signal.signal(signal.SIGTERM, self.exit_gracefully) def exit_gracefully(self, signum, frame): self.kill_now = True if __name__ == '__main__': killer = GracefulKiller() backlight.graph_off() backlight.graph_set_led_duty(0, 1) while True: cpu = psutil.cpu_percent() backlight.graph_off() backlight.set_graph(cpu / 100) if killer.kill_now: break sleep(0.3) print "End of the program. I was killed gracefully :)" backlight.graph_off()
def set_global_brightness(brightness): """Brightness 0 - 15""" backlight.graph_set_led_duty(0, brightness)
def set_state(led_number, bool_state): """Led 0-5, T or F""" backlight.graph_set_led_duty(led_number, bool_state)
import dothat.backlight as backlight import dothat.lcd as lcd import time ''' Each LED can be either on/off, and brightness is controlled globally using: * graph_set_led_duty(min, max) When you don't need a bar graph, these LEDs could display remaining lives in a game, the status of different processes, the hour of the day in binary or anything else you might need! ''' lcd.set_cursor_position(0, 1) lcd.write(" So Graph! ") # Reset the LED states and polarity backlight.graph_off() # Dim the LEDs by setting the max duty to 1 backlight.graph_set_led_duty(0, 1) # Now run a binary counter on the LEDs while True: for x in range(64): for led in range(6): backlight.graph_set_led_state(led, x & (1 << led)) time.sleep(0.1)
def blink_led(self,led,time_on=0.005): backlight.graph_set_led_duty(0,1) backlight.graph_set_led_state(led,1) # time.sleep(time_on) # LED visible even without delay backlight.graph_set_led_state(led,0)
elif command == 'setZoneToRGB': backlight.single_rgb(parameters['zoneIndex'], parameters['red'], parameters['green'], parameters['blue']) elif command == 'setLeftToRGB': backlight.left_rgb(parameters['red'], parameters['green'], parameters['blue']) elif command == 'setMiddleToRGB': backlight.mid_rgb(parameters['red'], parameters['green'], parameters['blue']) elif command == 'setRightToRGB': backlight.right_rgb(parameters['red'], parameters['green'], parameters['blue']) elif component == 'BarGraph': if command == 'turnOff': backlight.graph_off() elif command == 'setByPercentage': backlight.set_graph(float(parameters['percentage']) / 100) elif command == 'setBrightness': backlight.graph_set_led_duty(parameters['minimumBrightness'], parameters['maximumBrightness']) elif command == 'setEnabledStateOfLed': backlight.graph_set_led_polarity(parameters['ledIndex'], 0b00000000) backlight.graph_set_led_state( parameters['ledIndex'], 1 if parameters['enabledState'] else 0) elif component == 'Touch': if command == 'enableHighSensitivityMode': touch.high_sensitivity() elif command == 'enableEventRepeating': touch.enable_repeat(True)
backlight.left_hue(parameters['hue']) elif command == 'setMiddleToHue': backlight.mid_hue(parameters['hue']) elif command == 'setRightToHue': backlight.right_hue(parameters['hue']) elif command == 'setToRGB': backlight.rgb(parameters['red'], parameters['green'], parameters['blue']) elif command == 'setZoneToRGB': backlight.single_rgb(parameters['zoneIndex'], parameters['red'], parameters['green'], parameters['blue']) elif command == 'setLeftToRGB': backlight.left_rgb(parameters['red'], parameters['green'], parameters['blue']) elif command == 'setMiddleToRGB': backlight.mid_rgb(parameters['red'], parameters['green'], parameters['blue']) elif command == 'setRightToRGB': backlight.right_rgb(parameters['red'], parameters['green'], parameters['blue']) elif component == 'BarGraph': if command == 'turnOff': backlight.graph_off() elif command == 'setByPercentage': backlight.set_graph(float(parameters['percentage']) / 100) elif command == 'setBrightness': backlight.graph_set_led_duty(parameters['minimumBrightness'], parameters['maximumBrightness']) elif command == 'setEnabledStateOfLed': backlight.graph_set_led_polarity(parameters['ledIndex'], 0b00000000) backlight.graph_set_led_state(parameters['ledIndex'], 1 if parameters['enabledState'] else 0) elif component == 'Touch': if command == 'enableHighSensitivityMode': touch.high_sensitivity() elif command == 'enableEventRepeating': touch.enable_repeat(True)