Skip to content
Snippets Groups Projects
Select Git revision
  • b64e91b8f1746dfaf422b026b744824861e28cf9
  • 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

api.h

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    harmonic_demo.py 1.11 KiB
    from synth import tinysynth
    from hardware import *
    
    chords = [\
    [-4,0,3,8,10],\
    [-3,0,5,7,12],\
    [-1,2,5,7,11],\
    [0,3,7,12,14],\
    [3,7,10,14,15]\
    ]
    
    chord_index = 3
    chord = chords[3]
    synths = []
    
    def set_chord(i):
        global chord_index
        global chord
        if(i != chord_index):
            chord_index = i
            for j in range(40):
                hue = int(72*(i+0.5)) % 360
                set_led_hsv(j, hue, 1, 0.2)
            chord = chords[i]
            update_leds()
    
    
    def run():
        global chord_index
        global chord
        global synths
        for i in range(10):
            if(get_captouch(i)):
                if(i%2):
                    k = int((i-1)/2)
                    set_chord(k)
                else:
                    k = int(i/2)
                    synths[k].tone(chord[k])
                    synths[k].start()
    
    def init():
        global chord_index
        global chord
        global synths
    
        for i in range(5):
            synths += [tinysynth(440,1)]
    
        for synth in synths:
            synth.decay(100)
            synth.waveform(1)
    
    def foreground():
        global chord_index
        global chord
        global synths
        tmp = chord_index
        chord_index = -1
        set_chord(tmp)