Disco Lights: Difference between revisions

From kJams Wiki
Jump to navigation Jump to search
Created page with "I set up a few lights around the room, [http://lifx.co/ with LIFX bulbs], but you could as easily use [http://www.meethue.com Phillips Hue bulbs]. Then i run [http://peacockm..."
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 7: Line 7:
<pre>
<pre>
tell application "LIFXStyle"
tell application "LIFXStyle"
set hueScaleFactor to 3
set hueScaleFactor to 3 # larger number: cycle faster, smaller number: cylce slower
set maxValue to 255
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 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
set (whiteness of curLamp) to 25
set (whiteness of curLamp) to 25
set (brightness of curLamp) to maxValue
set (brightness of curLamp) to kMaxValue
end repeat
end repeat
set hueStart to hue of item 1 of lampList
set hueStart to hue of item 1 of lampList
set hueStartScaled to (hueStart / hueScaleFactor) as integer
set hueStartScaled to (hueStart / hueScaleFactor) as integer
set hueEndScaled to (maxValue / hueScaleFactor) as integer
set hueEndScaled to (kMaxValue / hueScaleFactor) as integer
repeat
repeat
Line 36: Line 30:
repeat with itemNo from 1 to count of lampList
repeat with itemNo from 1 to count of lampList
set curLamp to item itemNo of lampList
set curLamp to item itemNo of lampList
set curLampHue to ((curScaledHue + (itemNo * 45)) mod 255) as integer
set curLampHue to ((curScaledHue + (itemNo * intraLampHueOffset)) mod kMaxValue) as integer
set (hue of curLamp) to curLampHue
set (hue of curLamp) to curLampHue
end repeat
end repeat
Line 46: 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