Skip to content
Snippets Groups Projects
Select Git revision
  • ca40b2dbf4f04de8a690a3534d4ab3048d9bcd4b
  • master default protected
  • card10_nickname_fix
  • genofire/ble-card10-timeread
  • schneider/fundamental-test
  • schneider/ble-buffers
  • ios-workarounds
  • schneider/maxim-sdk-update
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
30 results

__init__.py

Blame
  • Forked from card10 / firmware
    1087 commits behind the upstream repository.
    Rahix's avatar
    ca40b2db
    History
    __init__.py 624 B
    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()
    
        disp.print("%i" % value)
    
        for i in range(0, len(history)):
            # Rescale to range 0 <= value < HEIGHT-1
            y = math.floor(history[i] * (HEIGHT - 2) / max(history))
    
            disp.pixel(WIDTH - i, HEIGHT - y - 1)
    
        disp.update()
        utime.sleep(0.1)