Exemplo n.º 1
0
 def show_data(self, screen, line):
     if not isinstance(screen, Display):
         raise TypeError(
             "The 'screen' parameter must be an instance of Display!")
     reading = TSL2561.read(self)
     msg = ">{0}: {1} lux".format(self.port, reading)
     screen.show_line(line, msg)
     return reading
def adjust_display_brightness(sensor: TSL2561):
    from display import instance as display
    global last_light_sensor_sample_ts
    global current_display_brightness
    now = time.ticks_ms()
    if now - last_light_sensor_sample_ts > LIGHT_SENSOR_SAMPLE_INTERVAL:
        lux = sensor.read()
        if lux >= 12:
            b = 255
        else:
            b = 0
        if abs(current_display_brightness - b) > 10:
            current_display_brightness = b
            display.set_brightness(b)
            print("[LIGHT] {} lux, set display brightness to {}".format(
                lux, b))
        last_light_sensor_sample_ts = now
Exemplo n.º 3
0
 def get_data(self):
     return TSL2561.read(self)
Exemplo n.º 4
0
 def get_lux(self):
     return TSL2561.read(self)