Skip to content
Snippets Groups Projects
Select Git revision
  • 051036fe12857c3fee6491f2b405e2bcc4d553c2
  • master default protected
  • patch-2
  • patch-1
  • add_menu_vibration
  • close_sensor_on_keyboard_interrupt
  • schneider/standby
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
35 results

bootstrap.sh

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    main.py 2.41 KiB
    from hardware import *
    import utils
    import time
    import harmonic_demo
    import melodic_demo
    
    MODULES = [
        harmonic_demo,
        melodic_demo,
    ]
    
    CURRENT_APP_RUN = None
    VOLUME = 0
    
    SELECT_TEXT = [
        " ##  #### #    ####  ##  #####          ",
        "#  # #    #    #    #  #   #        ##" ,
        "#    #    #    #    #      #     #    #",
        " ##  #### #    #### #      #         #" ,
        "   # #    #    #    #      #     #    #",
        "#  # #    #    #    #  #   #        ## ",
        " ##  #### #### ####  ##    #            ",
    ]
    
    BACKGROUND_COLOR = 0
    
    def run_menu():
        global CURRENT_APP_RUN
        display_fill(BACKGROUND_COLOR)
        utils.draw_text_big(SELECT_TEXT, 0, 0)
        utils.draw_volume_slider(VOLUME)
        display_update()
    
        selected_petal = None
        selected_module = None
        for petal, module in enumerate(MODULES):
            if utils.long_bottom_petal_captouch_blocking(petal, 20):
                selected_petal = petal
                selected_module = module
                break
    
        if selected_petal is not None:
            utils.clear_all_leds()
            utils.highlight_bottom_petal(selected_petal, 55, 0, 0)
            display_fill(BACKGROUND_COLOR)
            display_update()
            CURRENT_APP_RUN = selected_module.run
            time.sleep_ms(100)
            utils.clear_all_leds()
            selected_module.foreground()
    
    def foreground_menu():
        utils.clear_all_leds()
        utils.highlight_bottom_petal(0,0,55,55);
        utils.highlight_bottom_petal(1,55,0,55);
        display_fill(BACKGROUND_COLOR)
        utils.draw_text_big(SELECT_TEXT, 0, 0)
        display_update()
    
    def set_rel_volume(vol):
        global VOLUME
        vol += VOLUME
        if vol > 20:
            vol = 20
        if vol < -40:
            vol = -40
        VOLUME = vol
        if vol == -40: #mute
            set_global_volume_dB(-90)
        else:
            set_global_volume_dB(VOLUME)
        time.sleep_ms(100)
    
    def main():
        global CURRENT_APP_RUN
        while not init_done():
            pass
    
        captouch_autocalib()
    
        for module in MODULES:
            module.init()
    
        CURRENT_APP_RUN = run_menu
        foreground_menu()
        set_global_volume_dB(VOLUME)
    
        while True:
            if(get_button(0) == 2):
                if CURRENT_APP_RUN == run_menu:
                    captouch_autocalib()
                else:
                    CURRENT_APP_RUN = run_menu
                    foreground_menu()
            if(get_button(0) == 1):
                set_rel_volume(+1)
            if(get_button(0) == -1):
                set_rel_volume(-1)
            CURRENT_APP_RUN()
    
    main()