Skip to content
Snippets Groups Projects
Select Git revision
  • 177f5c2a6e6a7a309bd4cb47ca399fb302fa1604
  • main default protected
  • phhw
  • captouch-threshold
  • t
  • dos
  • test2
  • test
  • slewtest
  • simtest
  • view-think
  • vm-pending
  • media-buf
  • scope
  • passthrough
  • wave
  • vsync
  • dos-main-patch-50543
  • json-error
  • rahix/big-flow3r
  • pippin/media_framework
  • v1.3.0
  • v1.2.0
  • v1.2.0+rc1
  • v1.1.1
  • v1.1.0
  • v1.1.0+rc1
  • v1.0.0
  • v1.0.0+rc6
  • v1.0.0+rc5
  • v1.0.0+rc4
  • v1.0.0+rc3
  • v1.0.0+rc2
  • v1.0.0+rc1
34 results

main.py

Blame
  • Forked from flow3r / flow3r firmware
    Source project has a limited visibility.
    • moon2's avatar
      177f5c2a
      display: bring back optional scope mode · 177f5c2a
      moon2 authored
      this is somewhat hacky and definitely a temporary solution before we have a proper compositor.
      implemented this mostly for making demos, but if people are down we wouldn't mind merging it
      into main until we have a better system to manage this.
      177f5c2a
      History
      display: bring back optional scope mode
      moon2 authored
      this is somewhat hacky and definitely a temporary solution before we have a proper compositor.
      implemented this mostly for making demos, but if people are down we wouldn't mind merging it
      into main until we have a better system to manage this.
    main.py 2.44 KiB
    from hardware import *
    import utils
    import time
    import harmonic_demo
    import melodic_demo
    import demo_worms
    
    MODULES = [
        harmonic_demo,
        melodic_demo,
        demo_worms,
    ]
    
    CURRENT_APP_RUN = None
    VOLUME = 0
    ctx = None
    
    BACKGROUND_COLOR = 0
    
    
    
    def run_menu():
        global CURRENT_APP_RUN
        global ctx
        display_fill(BACKGROUND_COLOR)
        utils.draw_volume_slider(ctx, VOLUME)
        ctx.move_to(0,0).rgb(255,0,255).text("select :3")
        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);
        utils.highlight_bottom_petal(2,55,55,0);
        display_fill(BACKGROUND_COLOR)
        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
        global ctx
        while not init_done():
            pass
    
        captouch_autocalib()
    
        ctx = get_ctx()
        ctx.text_align = ctx.CENTER
        ctx.text_baseline = ctx.MIDDLE
    
        for module in MODULES:
            module.init()
    
        CURRENT_APP_RUN = run_menu
        foreground_menu()
        set_global_volume_dB(VOLUME)
    
        while True:
            if((get_button(1) == 2) and (CURRENT_APP_RUN == run_menu)):
                captouch_autocalib()
                foreground_menu()
            else:
                if(get_button(0) == 2):
                    if CURRENT_APP_RUN != run_menu:
                        CURRENT_APP_RUN = run_menu
                        display_scope_stop()
                        foreground_menu()
                else:
                    if(get_button(0) == 1):
                        set_rel_volume(+1)
                    if(get_button(0) == -1):
                        set_rel_volume(-1)
                    CURRENT_APP_RUN()
    
    main()