Disco Lights: Difference between revisions

From kJams Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 11: Line 11:
set kMaxValue to 255 # constant: don't change this number
set kMaxValue to 255 # constant: don't change this number
set barnList to {"Barn Desk Right", "Barn Desk Left", "Barn Wall", "Barn Stairs", "Barn Beam Uplight"}
set groupNameList to {"Barn"} #, "Pool"} #, "Music Room"}
set poolList to {"Pool Left", "Pool Middle", "Pool Right "}
set musicRoomList to {"Tall Lamp"}
set lampNameList to barnList & poolList & musicRoomList
set lampList to my get_all_lamps_in_group_list(groupNameList)
set lampList to {}
repeat with curLamp in lampNameList
set lampList to lampList & {a reference to (first lamp whose title is curLamp)}
end repeat
repeat with curLamp in lampList
repeat with curLamp in lampList
Line 47: Line 40:
end repeat
end repeat
end tell
end tell
on get_all_lamps_in_group_list(groupNameList)
set lampList to {}
repeat with curGroup in groupNameList
set lampList to lampList & my get_group_lamp_list(curGroup)
end repeat
return lampList
end get_all_lamps_in_group_list
on get_group_lamp_list(groupName)
set lampList to {}
tell application "LIFXStyle"
set lampGroup to a reference to lamps of (first group whose title is groupName)
repeat with lampNo from 1 to (count of lampGroup)
set lampList to lampList & {a reference to (item lampNo of lampGroup)}
end repeat
end tell
return lampList
end get_group_lamp_list
</pre>
</pre>

Latest revision as of 01:02, 13 December 2014

I set up a few lights around the room, with LIFX bulbs, but you could as easily use Phillips Hue bulbs.

Then i run LIFXstyle or Hue-topia.

Then i run my color-changing-lights script:

tell application "LIFXStyle"
	set hueScaleFactor to 3 # larger number: cycle faster, smaller number: cylce slower
	set intraLampHueOffset to 45 # number of hue steps to take per bulb (so they're offset from each other)
	set kMaxValue to 255 # constant: don't change this number
	
	set groupNameList to {"Barn"} #, "Pool"} #, "Music Room"}
	
	set lampList to my get_all_lamps_in_group_list(groupNameList)
	
	repeat with curLamp in lampList
		set (whiteness of curLamp) to 25
		set (brightness of curLamp) to kMaxValue
	end repeat
	
	set hueStart to hue of item 1 of lampList
	set hueStartScaled to (hueStart / hueScaleFactor) as integer
	set hueEndScaled to (kMaxValue / hueScaleFactor) as integer
	
	repeat
		repeat with hueValue from hueStartScaled to hueEndScaled
			set curScaledHue to (hueValue * hueScaleFactor)
			
			repeat with itemNo from 1 to count of lampList
				set curLamp to item itemNo of lampList
				set curLampHue to ((curScaledHue + (itemNo * intraLampHueOffset)) mod kMaxValue) as integer
				set (hue of curLamp) to curLampHue
			end repeat
			
			delay 0.25
		end repeat
		
		set hueStartScaled to 0
	end repeat
end tell

on get_all_lamps_in_group_list(groupNameList)
	set lampList to {}
	
	repeat with curGroup in groupNameList
		set lampList to lampList & my get_group_lamp_list(curGroup)
	end repeat
	
	return lampList
end get_all_lamps_in_group_list

on get_group_lamp_list(groupName)
	set lampList to {}
	
	tell application "LIFXStyle"
		set lampGroup to a reference to lamps of (first group whose title is groupName)
		
		repeat with lampNo from 1 to (count of lampGroup)
			set lampList to lampList & {a reference to (item lampNo of lampGroup)}
		end repeat
		
	end tell
	
	return lampList
end get_group_lamp_list