import time, system, appconfig, display

font={"A" : 0b0110100111111001,"B" : 0b1100101011011110,"C" : 0b0111100010000111,"D" : 0b1110100110011110,"E" : 0b1111111010001111,"F" : 0b1111100011101000,"G" : 0b1111100010011111,"H" : 0b1001100111111001,"I" : 0b1110010001001110,"J" : 0b1111000110011111,"K" : 0b1011110010101001,"L" : 0b1000100010001111,"M" : 0b1111101110011001,"N" : 0b1101101110011001,"O" : 0b0110100110010110,"P" : 0b1110100111101000,"Q" : 0b1111100110111111,"R" : 0b1110100111101011,"S" : 0b1111110000111111,"T" : 0b1110010001000100,"U" : 0b1001100110011111,"V" : 0b1001100110010110,"W" : 0b1001100110111111,"X" : 0b1001011001101001,"Y" : 0b1010101011100100,"Z" : 0b1111001001001111," " : 0b0000000000000000,"1" : 0b1100010001000100,"2" : 0b1111001001001111,"3" : 0b1111011100011111,"4" : 0b1001100111110001,"5" : 0b1111110000111111,"6" : 0b1000111110011111,"7" : 0b1111000100010001,"8" : 0b1110101111010111,"9" : 0b1111100111110001,"0" : 0b1111101111011111,"!" : 0b0100010000000100,"?" : 0b1111000101110100,"\"" : 0b1010000000000000,"." : 0b0000000000000100,"," : 0b0000000001001000,": " : 0b0100000001000000,"=" : 0b0000111000001110,"+" : 0b0000010011100100,"-" : 0b0000000011100000,";" : 0b0100000001001000,"@" : 0b1111000111011111,"#" : 0b0110111111110110,"(" : 0b0100100010000100,")" : 0b1000010001001000}


while True:
	settings = appconfig.get("textbanner", {"text": "welcome to campzone 2020    ", "delay": 0.7, "loop": True, "color_on": "000022", "color_off": "000000"})
	banner=settings['text']
	for c in banner.upper():
		if(c in font):
			settings = appconfig.get("textbanner", {"text": "welcome to campzone 2020    ", "delay": 0.7, "loop": True, "color_on": "000022", "color_off": "000000"})
			for y in range(0,4):
				for x in range(0,4):
					if font[c] & pow(2,(((3-y)*4)+(3-x))):
						display.drawPixel(x, y, int(settings['color_on'],16))
					else:
						display.drawPixel(x, y, int(settings['color_off'],16))
			display.flush()
			time.sleep(settings['delay'])
			[display.drawPixel(x,y,0) for x in range(0, 4) for y in range(0, 4)] # clears the board
			display.flush()
			time.sleep(0.01);
	if not settings['loop']:
		system.launcher()