Esempio n. 1
0
def main():
    light_sensor.start()
    with display.open() as d:
        while True:
            bs = checkButtons()
            CTRL_FNS[MODE](bs)
            ctrl_backlight(d)
            render(d)
            utime.sleep_ms(200)
def main():
    light_sensor.start()
    with display.open() as d:
        while True:
            bs = check_buttons()
            CTRL_FNS[MODE](bs)
            if MODE == DISPLAY:
                render_every_second(d)
            else:
                render(d)
Esempio n. 3
0
def main():
    light_sensor.start()
    with display.open() as d:
        while True:
            bs = check_buttons()
            CTRL_FNS[MODE](bs)
            if MODE == DISPLAY:
                render(
                    d
                )  #update continously, TODO: check for current consumption increase
                #render_every_second(d)#update clock every second
            else:
                render(d)
Esempio n. 4
0
    def read_values(self, **kwargs):
        light_sensor.start()
        bright = light_sensor.get_reading()
        light_sensor.stop()

        if bright < 7:
            bright_desc = "Very very dark"
        elif bright < 15:
            bright_desc = "Very dark"
        elif bright < 50:
            bright_desc = "Hackerspace brightness"
        elif bright < 100:
            bright_desc = "Not so dark"
        else:
            bright_desc = "Sunlight"

        return [bright, bright_desc]
Esempio n. 5
0
import os
import display
import utime
import buttons
import light_sensor
import math

WIDTH = 160
HEIGHT = 80

disp = display.open()

light_sensor.start()

history = []

while True:
    disp.clear()

    value = light_sensor.get_reading()

    history.insert(0, value)
    if len(history) > WIDTH:
        history.pop()

    blueColor = (int)(255 * (value / max(history)))
    redColor = (int)(255 * (1 - value / max(history)))

    disp.print("%i" % value, fg=[redColor, 0, blueColor])

    isFirstMax = True
Esempio n. 6
0
def start_light_sensor():
    light_sensor.start()