import badge
import math
from time import sleep

freq = 0.3
count = 1.0

def get_colours():
	red = math.sin(freq*count) * 127.0 + 128.0
	green = math.sin(freq*count + (2*math.pi/3)) * 127.0 + 128.0
	blue = math.sin(freq*count + (4*math.pi/3)) * 127.0 + 128.0
	return red, green, blue

def all_off():
	for led in range(0, 7):	
		badge.led(led, 0, 0, 0)
		print("LED: {} off".format(led))


while True:
	try:

		for led in range(0, 7):	
			r, g, b = get_colours()
			badge.led(led, int(r), int(g), int(b))
			print("Led: {} - RGB: {} {} {}".format(led, r, g, b))

		count = count + 1.0
		print("---")
		sleep(2)

	except KeyboardInterrupt:
		all_off()
		exit(1)