I can fix all that stuff, the numerator is the maximum intensity. So if I want my max intensity to go to 50% I just do 0.5/(e^(x^2.5)) and I can round the ends off at some cutoff point.
To shift it I just take my total length of time I want and scale it from -1.8 t0 1.8. Here is how I can apply it with a gooseberry pi
I use a seconds-since-midnight variable to control the timed functions of the tank.
Sunrise = 8:00 am or 28,800 seconds since midnight
Sunset = 5:00 pm or 61,200 seconds since midnight
Every second the pi will check if the current time is between 28800 and 61200 seconds. If it is, I can calculate the percentage to set the lighting intensity like this:
In this example the current time is 40000 seconds since midnight or 11:06am and 36 seconds
Total cycle time (61200-28800): = 32400
Seconds into cycle (40000-28800): 11200
Current portion of cycle (11200/32400): 0.3456790123
So we are 0.3456790123 into our curve that is 3.6 units long (-1.8 to 1.8) so we are at 0.3456790123*3.6 = 1.244444444
So to get the input value just add 1.244444444 to -1.8 that is -0.555556 and I take the absolute value since my graph starts at 0, which is 0.555556
Then I plug that into the equation
0.5/(e^(0.555556^2.5)) = 0.39724749219 and that is my lighting percent
I can stretch out the max intensity by increasing the power of x and reducing the curve length, I will make those configurable. Here is the pi code:
Code:
import sys
import math
startTime = 28800
endtime = 61200
curveLength = -1.8
maxDutyCycle = 0.5
xExponent = 2.5
currentTime = 40000.0 #this will be updated every second
percentOfCycle = (currentTime-startTime)/(endtime-startTime)
positionInCycle = percentOfCycle*abs(curveLength)*2
xValue = abs(positionInCycle + curveLength)
dutyCycle = maxDutyCycle/(pow(math.e,(pow(xValue,xExponent))))
print dutyCycle #output is 0.397247674971
#now I just use raspberry pi PWM functions to set my light dimmer to dutyCycle
Also yes I went snowboarding yesterday and I tried putting my gopro on my helmet it was fun!!!!