Esempio n. 1
0
machine.nvs_setint('system', 'factory_checked', CURR_TGT)
machine.nvs_setint('system', 'force_sponsors', 1)

# 7) Show message
easydraw.messageCentered("PASSED", True)
display.flush()

# 8) Blink LEDs and make noise

mpr121.set(10, 1)  # Calibration resets MPR121, here we re-enable LED power

buzzer_pin = machine.Pin(12, machine.Pin.OUT)
time.sleep(0.01)
buzzer_pwm = machine.PWM(buzzer_pin, duty=50)

sndmixer.begin(2)
synth = sndmixer.synth()
sndmixer.volume(synth, 50)
sndmixer.waveform(synth, 1)

while True:
    buzzer_pwm.duty(50)
    buzzer_pwm.freq(500)
    sndmixer.freq(synth, 500)
    neopixel.send(bytes([0xFF, 0, 0] * 12))
    time.sleep(0.25)
    buzzer_pwm.freq(600)
    sndmixer.freq(synth, 600)
    neopixel.send(bytes([0, 0xFF, 0] * 12))
    time.sleep(0.25)
    buzzer_pwm.freq(800)
def _start_audio_if_needed():
    global _started
    if not _started:
        sndmixer.begin(_no_channels)
        _started = True
Esempio n. 3
0
                if counter % 2 == 0:
                    color = settings['color_off']
                else:
                    color = settings['color_on']

            elif pattern[x + y * 4] == 3:
                if counter % 2 == 0:
                    color = settings['color_on']
                else:
                    color = settings['color_off']

            display.drawPixel(x, y, color)
    display.flush()

    return interval


sndmixer.begin(1)
synth = sndmixer.synth()
sndmixer.waveform(synth, 0)
sndmixer.volume(synth, 0)

# Adding callbacks
virtualtimers.begin(50)
virtualtimers.new(0, draw, False)
keypad.add_handler(on_key)
touchpads.on(touchpads.RIGHT, interval_up)
touchpads.on(touchpads.LEFT, interval_down)
touchpads.on(touchpads.CANCEL, stop_blinking)
touchpads.on(touchpads.OK, continue_blinking)
Esempio n. 4
0
#	Conversion via FFMPEG:
#		ffmpeg -i original.mp3 -ar 22050 -ac 1  -b:a 128k soundboardfile.mp3
#
#	Demo samples:
#		https://github.com/jillesdotcom/CZ20_soundboardfiles
#
import os, time, machine, appconfig, display, keypad, touchpads, sndmixer

settings = appconfig.get("soundboard", {"SampleFolder": "/sd/soundboard","BootAnimation": True})
print("Samplefolder:",settings['SampleFolder'])
print("BootAnimation:",settings['BootAnimation'])

MAX_FILES	= 4
MAX_PAGES	= 16

sndmixer.begin(MAX_FILES, False)

global_playing		= [False]*MAX_FILES
global_file			= [None]*MAX_FILES
global_channels		= [None]*MAX_FILES
global_filenames	= [""]*MAX_FILES
global_page_empty   = [False]*MAX_PAGES
global_page			= 0

def load_file(filename):
	global global_playing, global_file, global_channels, global_filenames, MAX_FILES

	settings = appconfig.get("soundboard", {"SampleFolder": "/sd/soundboard","BootAnimation": True})
	filepath = settings["SampleFolder"]+"/page"+str(global_page)+"/"+filename

	try: