コード例 #1
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:
		if filename in os.listdir(settings["SampleFolder"]+"/page"+str(global_page)):
			for i in range(MAX_FILES):
				if global_filenames[i] == filepath:
					print("File already open",filepath,"in slot",i)
					return i
			for i in range(MAX_FILES):
				if not global_playing[i]:
					if global_file[i]:
						global_file[i].close()
					global_file[i] = open(filepath, "rb")
					global_filenames[i] = filepath
					print("Opened file",filepath,"in slot",i)
					return i
		else:
			print(filepath,"does not exist")
			return None
	except:
		print("Failed to open",filepath)
		return None
		
	return None
コード例 #2
0
 def load_settings():
     global settings
     settings = appconfig.get("tcp_client", {
         "server_ip": "192.168.1.4",
         "server_port": 1234
     })
     print("Server IP: " + settings["server_ip"] + " port: " +
           str(settings["server_port"]))
コード例 #3
0
import display, time, keypad, virtualtimers, appconfig, sndmixer

settings = appconfig.get(
    'blink', {
        'pattern': [0, 1, 1, 0, 1, 2, 2, 1, 1, 2, 2, 1, 0, 1, 1, 0],
        'interval': 1000,
        'color_on': 0x808080,
        'color_off': 0x000000
    })
pattern = settings['pattern']
interval = settings['interval']
counter = 0
blinking = True


def interval_down(is_pressed):
    global interval

    if is_pressed:
        interval = interval // 2 if interval >= 100 else 50
        print("Interval is now {}".format(interval))


def interval_up(is_pressed):
    global interval

    if is_pressed:
        interval = interval * 2 if interval <= 5000 else 10000
        print("Interval is now {}".format(interval))

コード例 #4
0
import system, display, time, keypad, touchpads, virtualtimers, appconfig, sndmixer, wifi, ugTTS

settings = appconfig.get('blink', {'pattern': [2,0,0,2, 0,2,2,0, 0,2,2,0, 2,0,0,2], 'interval': 1000, 'color_on': 0xFF0000, 'color_off': 0x004000, 'speech': True})
pattern  = settings['pattern']
interval = settings['interval']
counter  = 0
blinking = True
connected = False

def msg(text):
    func = ugTTS.speak if connected else print
    func(text)
    
def interval_down(is_pressed):
    global interval

    if is_pressed:
        interval = interval // 2 if interval >= 100 else 50
        msg("Interval is now {}".format(interval))
        

def interval_up(is_pressed):
    global interval

    if is_pressed:
        interval = interval * 2 if interval <= 5000 else 10000
        msg("Interval is now {}".format(interval))
        

def stop_blinking(is_pressed):
    global blinking
コード例 #5
0
#		Cancel - Go to Page 1
#		Left   - Previous page
#		Right  - Next page
#
#	Sample files:
#		/soundboard/page<page nr>/sound0.mp3 -  sound15.mp3
#
#	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
コード例 #6
0
# it appears the writer does not understand Python
# the writer should learn the basics
# before stealing other people's code

print ("Configure what each button does")
# for inspiration, check:
# https://gist.github.com/MightyPork/6da26e382a7ad91b5496ee55fdc73db2
settings = appconfig.get("hotkeys", {
 "0" : {"vkey" : "F13", "modifier": "", "colour" : "#000011"},
 "1" : {"vkey" : "F14", "modifier": "", "colour" : "#000011"},
 "2" : {"vkey" : "F15", "modifier": "", "colour" : "#000011"},
 "3" : {"vkey" : "F16", "modifier": "", "colour" : "#000011"},
 "4" : {"vkey" : "F17", "modifier": "", "colour" : "#000011"},
 "5" : {"vkey" : "F18", "modifier": "", "colour" : "#000011"},
 "6" : {"vkey" : "F19", "modifier": "", "colour" : "#000011"},
 "7" : {"vkey" : "F20", "modifier": "", "colour" : "#000011"},
 "8" : {"vkey" : "F21", "modifier": "", "colour" : "#000011"},
 "9" : {"vkey" : "F22", "modifier": "", "colour" : "#000011"},
 "10" : {"vkey" : "F23", "modifier": "", "colour" : "#000011"},
 "11" : {"vkey" : "F24", "modifier": "", "colour" : "#000011"},
 "12" : {"vkey" : "V", "modifier": "MOD_LEFT_CONTROL", "colour" : "#000011"},
 "13" : {"vkey" : "Q", "modifier": "", "colour" : "#9A0011"},
 "14" : {"vkey" : "Y", "modifier": "", "colour" : "#009A11"},
 "15" : {"vkey" : "F1", "modifier": "", "colour" : "#0000BB"},
})

print ("initialise screen")
for z in range(0,16):
if settings[str(z)]["vkey"] != "":
	x, y = z % 4, int(z / 4)
	colour = int(settings[str(z)]["colour"].replace("#","0x"),16)
	display.drawPixel(x, y, colour)