This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Run tunable white (HCL)
#6
Like this:
Code:
function tomins(hour, min)   return hour * 60 + min end points = {   { hour = 0, min = 0, v1 = 25, v2 = 50 },   { hour = 7, min = 30, v1 = 25, v2 = 50 },   { hour = 8, min = 0, v1 = 30, v2 = 30 },   { hour = 9, min = 0, v1 = 50, v2 = 25 },   { hour = 16, min = 0, v1 = 40, v2 = 15 },   { hour = 17, min = 0, v1 = 30, v2 = 30 },   { hour = 18, min = 30, v1 = 25, v2 = 50  },   { hour = 24, min = 0, v1 = 25, v2 = 50 }, } now = os.date('*t') currmins = tomins(now.hour, now.min) for i, point in ipairs(points) do   nextmins = tomins(point.hour, point.min)   if nextmins >= currmins then     nextpoint = point     prevpoint = points[ i - 1 ] or nextpoint     prevmins = tomins(prevpoint.hour, prevpoint.min)     break   end end deltamins = nextmins - prevmins if deltamins > 0 then   d1 = (nextpoint.v1 - prevpoint.v1) * (currmins - prevmins) / deltamins   d2 = (nextpoint.v2 - prevpoint.v2) * (currmins - prevmins) / deltamins else   d1 = 0   d2 = 0 end v1 = math.floor(prevpoint.v1 + d1) v2 = math.floor(prevpoint.v2 + d2) log(now.hour, now.min, v1, v2)
Reply


Messages In This Thread
Run tunable white (HCL) - by FatMax - 11.08.2018, 14:21
RE: Run tunable white (HCL) - by admin - 12.08.2018, 10:15
RE: Run tunable white (HCL) - by admin - 13.08.2018, 11:24
RE: Run tunable white (HCL) - by tomnord - 09.10.2019, 19:40
RE: Run tunable white (HCL) - by FatMax - 14.08.2018, 09:44
RE: Run tunable white (HCL) - by admin - 10.10.2019, 07:03
RE: Run tunable white (HCL) - by tomnordstrom - 10.10.2019, 07:48
RE: Run tunable white (HCL) - by admin - 10.10.2019, 08:14
RE: Run tunable white (HCL) - by KoBra - 20.09.2023, 19:35
RE: Run tunable white (HCL) - by admin - 21.09.2023, 05:15
RE: Run tunable white (HCL) - by KoBra - 21.09.2023, 05:59
RE: Run tunable white (HCL) - by admin - 21.09.2023, 08:22
RE: Run tunable white (HCL) - by KoBra - 21.09.2023, 12:42
RE: Run tunable white (HCL) - by admin - 21.09.2023, 12:48
RE: Run tunable white (HCL) - by KoBra - 21.09.2023, 14:18
RE: Run tunable white (HCL) - by admin - 21.09.2023, 14:45
RE: Run tunable white (HCL) - by KoBra - 21.09.2023, 15:08

Forum Jump: