Page 1 of 3
Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 4:57 pm
by ReEfnWrX
Many thanks to Lee for assisting with the base code and essentially teaching me the fundamentals of the code structure needed for me to modify it to its end result.
Here it is, no more having to adjust your photo period to acclimate corals if you have dimmable LED drivers.
This code is setup currently for PWM signal. I am using 3 channels because I couldn't get both my Blue driver wires into the same channel.
This code can be easily edited to add additional channels for drivers running different colors White/Blue or if you have split your colors up into more drivers... Cool White/Warm White/Royal Blue/Cool Blue/UV/Red/Green etc...
To view and write the hard coded values for the locations defined in the global variables use the following wifi commands in your web browser
http://IPAddressOfYourWifiAttachment:2000/mbx
- read memory location (byte size) where
x=memory location
Example to read the value of Mem_B_AcclDuration:
http://192.168.0.60:2000/mb101
http://IPAddressOfYourWifiAttachment:2000/mbx,y
- write memory location (byte size) where
x=memory location
y=value to be written
Example to set the value for Mem_B_AcclDuration so you have a 30 day acclimation cycle:
http://192.168.0.60:2000/mb101,30
You will need to set
ALL OF the global variable values below to what ever you want by using the wifi commands above.
////// Place global variable code below here
Code: Select all
////// Memory Locations used by all formulas
#define Mem_B_AcclDay 100
// Note - 100 represents the hard coded Memory location used for this variable
// not the value for the variable.
// This variable represents the current day in Acclimation Cycle. Set this value to the same
// number of days as your AcclDuration to begin the acclimation cycle or set it to 0 to use
// your normal dimming end% values.
#define Mem_B_AcclDuration 101
// Set this value to how many days you want your acclimation cycle to take.
#define Mem_B_SlopeStart 102
// Set this to your desired starting acclimation end%.
/////// Memory Locations used by Blue Formula
#define Mem_B_AcclStartEndBlue 105 // Acclimation starting Slope end%
#define Mem_B_SlopeEndBlue 106 // slope End%
////// Memory Locations used by White Formula
#define Mem_B_AcclStartEndWhite 110 // Acclimation starting Slope end%
#define Mem_B_SlopeEndWhite 111 // Slope End%
////// Place global variable code above here
////// Place your custom code below here
Code: Select all
/////// LED Dimming Acclimation Cycle and your standard LED schedule
////////// Variables used for all channels
byte acclDay = InternalMemory.read(Mem_B_AcclDay);
// What day in the acclimation cycle it is
byte acclDuration = InternalMemory.read(Mem_B_AcclDuration);
// Acclimation Duration in days
byte startPercent = InternalMemory.read(Mem_B_SlopeStart);
// Normal start% being used by all 3 channels
////////// Blue Channel Variables
byte acclStartEndBlue = InternalMemory.read(Mem_B_AcclStartEndBlue);
// Starting End% for Acclimation cycle
float acclendPercentBlue = InternalMemory.read(Mem_B_SlopeEndBlue);
// Your target Blue end% once acclimation is complete
////////// Blue Channel Formula
float acclPercentPerDayBlue = (acclendPercentBlue - acclStartEndBlue) / acclDuration;
// How much your Blue end% rises per acclimation day
float acclFactorBlue = acclDay * acclPercentPerDayBlue;
// endPercentBlue will be offset by this much. If acclDay = 0 then this value will be 0
byte endPercentBlue = acclendPercentBlue - acclFactorBlue;
// Your final Blue end% for the day
////////// White Channel Variables
byte acclStartEndWhite = InternalMemory.read(Mem_B_AcclStartEndWhite);
// Starting End% for Acclimation cycle
float acclEndPercentWhite = InternalMemory.read(Mem_B_SlopeEndWhite);
// Your target White end% once acclimation is complete
////////// White Channel Formula
float acclPercentPerDayWhite= (acclEndPercentWhite - acclStartEndWhite) / acclDuration;
// How much your White end% rises per acclimation day
float acclFactorWhite = acclDay * acclPercentPerDayWhite;
// endPercentWhite will be offset by this much. If acclDay = 0 then this value will be 0
byte endPercentWhite = acclEndPercentWhite - acclFactorWhite;
// Your standard PWM Dimming code using the variables above to determine start% and end%
ReefAngel.PWM.SetChannel( 0, PWMSlope(13,0,21,0,startPercent,endPercentWhite,90,20) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(12,0,22,0,startPercent,endPercentBlue,90,20) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(12,0,22,0,startPercent,endPercentBlue,90,20) );
// At the end of the day, we need to decrement the acclimation counter.
static boolean acclCounterReady=false; // We need a boolean so we only do this once per day
if (now()%SECS_PER_DAY!=0) acclCounterReady=true; // If it's not midnight we'll get the boolean ready
if (now()%SECS_PER_DAY==0 && acclCounterReady && acclDay>0) { // It's midnight, our bool is true and acclDay is more than 0
acclDay--; // Reduce the counter
acclCounterReady=false; // Reset the boolean flag
InternalMemory.write(Mem_B_AcclDay,acclDay); // Update memory
}
////// Place your custom code above here
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 7:02 pm
by rimai
I think it can be done.
So, let's say your end% is 75% and you want to start the acclimation at 50% for 7 days, we would start the factor by .666 and increase by 0.0476 per day.
All we need is a way to trigger the start of acclimation.
I think the easiest is to use the CustomVar to trigger it using wifi command /cvar0,1 for example.
The code would check if CustomVar 0 has a value of 1 and if it does, it starts the acclimation.
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 7:40 pm
by ReEfnWrX
I am not following you.
Where are you getting .666 and 0.0476 and what are they representing?
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 7:42 pm
by lnevo
I use a memory location. If you change your code or your controller resets you lose where you are in acclimation.
I do a 30 day and each not i drop the counter by one.
You just have to take you 75%-50%=25%
25%/30=.833%
So on the first day 30x.833 =25% you can just subtract that from your peak.
On day 10 (20 days left) = 20x.833 = 17%
And so on. On the last day your at 0% subtracted from your peak setting.
All you need to store is the factor somewhere and the number of days your gonna acclimate (in memory or custom var)
This is how i do it but instead of % i'm subtracting minutes.
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 7:48 pm
by ReEfnWrX
Wait I think I see what you mean.
Factor of 1 represents 100% of what ever my End% target is?
So you are saying, End% = 75% So
Day 1 = 75%*(0.666)
Day 2 = 75%*(.666+0.0476)
Day 3 = 75%*(.666+(0.0476*2))
Day 4 = 75%*(.666+(0.0476*3))
etc?
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 8:13 pm
by ReEfnWrX
I am definitely on board with using a memory location... especially since I am new to the RA I will always be messing around trying different code out and power outages are out of our control without battery back up which I currently do not have.
I would probably go with around a 30 day acclimation which is what I have always done if not longer with MH's.
I went back to look at your INO and it is hard to interpret how the acclimation code works because you have the your custom Sunset and Sunrise offsets.
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 8:26 pm
by ReEfnWrX
So to use internal memory I would need to add the following to my code?
Code: Select all
#define Mem_B_AcclDay 100
void init_memory() {
InternalMemory.write(Mem_B_AcclDay,0);
InternalMemory.write(Mem_B_ResetMemory,false);
}
and then how would we get it to edit the internal memory for Acclday?
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 8:53 pm
by lnevo
Do you have the wifi...forget about the init_memory function..
You can modify the memory location with either the InternalMemory.write() function you saw there or through the wifi
http://ip.address:2000/mb100,30
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 8:56 pm
by ReEfnWrX
Yes I have the wifi exp.
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 8:56 pm
by lnevo
ReEfnWrX wrote:Wait I think I see what you mean.
Factor of 1 represents 100% of what ever my End% target is?
So you are saying, End% = 75% So
Day 1 = 75%*(0.666)
Day 2 = 75%*(.666+0.0476)
Day 3 = 75%*(.666+(0.0476*2))
Day 4 = 75%*(.666+(0.0476*3))
etc?
Yes I think so. I would just check the math.
The .666 is how much of the original % (so 75->50, ie 2/3rd original value)
The .0476 is how much %/day.
Re: Dimmable LED Acclimation for corals
Posted: Sun Dec 29, 2013 9:44 pm
by ReEfnWrX
So, If started acclimation end% at 25% and target% was 75% over 30 days
Y = .75 = Target End%
X = 0.01667 = End% change per day = 75%-25%=.5 | .5/30 days
Z = Days left in Acclimation Cycle
Y-(X*Z)= Current Days Dimming End%
.75-(0.01667*30) = .2499 or 25%
.75-(0.01667*15) = .49995 or 50%
Close enough for gov't work...
So how would we incorporate this into an acclimation code that can be activated that will use the internal memory for Z?
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 12:19 pm
by ReEfnWrX
Anyone able to help with this?
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 1:56 pm
by lnevo
I'll write something up tonight or tomorrow, but i sounds like you got it...
You need to do that calculation and figure out what the X is then multiply it by your peak percentages.
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 4:49 pm
by lnevo
Here's a high level of how you could do this. There's a lot that can be done to make this more generic, but I'm not tackling that now..
Code: Select all
// This part would go in your global declarations.
#define Mem_B_AcclDay 100
// The rest of this goes inside your loop() or custom function
// Let's make some variables to work with
byte startPercent=13; // Normal start %
byte endPercent=55; // Normal end %
byte acclDay = InternalMemory.read(Mem_B_AcclDay); // Let's get what's in memory
float acclPercentPerDay = .01667; // (Based on 50% less dimming over 30 days (.5/30)
// This is how much we're going to alter the dimming
// This number could also be used to adjust the duration
// of the slope... the startPercent, the photoperiod..whatever you want
float acclFactor=acclDay*acclPercentPerDay;
// Adjust the endPercent based on the acclFactor
endPercent=endPercent-(endPercent*acclFactor);
// Here's what some samples look like
// Day 30 = 28% (55 - 27)
// Day 15 = 41% (55 - 14)
// Day 5 = 50% (55 - 5)
// Day 0+ = 55% (55 - 0)
ReefAngel.PWM.SetChannel( 0, PWMSlope(13,0,20,30,startPercent,endPercent,40,20) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(12,0,21,30,startPercent,endPercent,40,20) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(12,0,21,30,startPercent,endPercent,40,20) );
// At the end of the day, we need to decrement the acclimation counter.
static boolean acclCounterReady=false; // We need a boolean so we only do this once per day
if (now()%SECS_PER_DAY!=0) acclCounterReady=true; // If it's not midnight we'll get the boolean ready
if (now()%SECS_PER_DAY==0 && acclCounterReady && acclDay>0) { // It's midnight, our bool is true and acclDay is more than 0
acclDay--; // Reduce the counter
acclCounterReady=false; // Reset the boolean flag
InternalMemory.write(Mem_B_AcclDay,acclDay); // Update memory
}
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 5:23 pm
by ReEfnWrX
You did that quick...
So does this represent how many days are in the acclimation cycle?
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 6:25 pm
by ReEfnWrX
Unless I am overlooking something in the code, or the RA works with the code in a way I do not understand yet. Please Correct me if I am wrong. Since we define dimming % as full numbers and not decimals
I believe these two formulas
Code: Select all
float acclFactor=acclDay*acclPercentPerDay;
endPercent=endPercent-(endPercent*acclFactor);
should be changed to
Code: Select all
float acclFactor=((acclDay*acclPercentPerDay)*100);
endPercent=endPercent-acclFactor);
This will result with an acclFactor that is not a decimal
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 6:32 pm
by ReEfnWrX
With the Code Before, Day 1(30 in internal memory) and acclpercentperday change = .01667 based on a 30 day acclimation and a 50% difference from Acclimation End% at start(25) to Target End%(75)
acclFactor= 30*.01667 = .5001
endPercent=75-(75*.5001) = 37.4925
with the other code
acclFactor=((30*.01667)*100) = 50.01
endPercent=75-50.01 = 24.99
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 6:39 pm
by lnevo
ReEfnWrX wrote:You did that quick...
So does this represent how many days are in the acclimation cycle?
No it represents the memory location we will store the number of days remaining.
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 7:01 pm
by lnevo
ReEfnWrX wrote:Unless I am overlooking something in the code, or the RA works with the code in a way I do not understand yet. Please Correct me if I am wrong. Since we define dimming % as full numbers and not decimals
I believe these two formulas
Code: Select all
float acclFactor=acclDay*acclPercentPerDay;
endPercent=endPercent-(endPercent*acclFactor);
should be changed to
Code: Select all
float acclFactor=((acclDay*acclPercentPerDay)*100);
endPercent=endPercent-acclFactor);
This will result with an acclFactor that is not a decimal
Either way results in a whole number as endPercent is declared as a byte.
I think though that your way is subtracting the inverse, but it could work also. Try your formula out for the same few calculations i did to verify. Always a few ways to skin a cat.
Also the reason for the difference between my endpercent and yours is that my number in the examples is on 55 which you sent me in your pm. Not the use case in the thread.
Hare is how mine works..
float acclFactor=acclDay*acclPercentPerDay;
acclFactor=30*.01667
acclFactor=.50
endPercent=endPercent-(endPercent*acclFactor);
endPercent=55-(55*.5);
endPercent=55-(27.5);
endPercent=55-27.5
endPercent=27.5
endPercent=28
Also i just realized my calculation is correct but the result is different because my 50% is 50% of 75% which is 37.5% so that was m starting point going up 1.25% a day.
For the thread use case we go back to roberto's numbers which was .667 and .667/30=.02222
endPercent=75-(75*.6667);
That should work out as expected now...
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 7:10 pm
by ReEfnWrX
Yeah, we were on two different pages. You were defining your starting end% by Target end%*.5
Where I was defining the start point as Target end% - 50%.
55 is only where my LEDs currently are, as I am currently acclimating manually. my target % is 75 to start and see how my corals react.
Your logic works for me though, acclimating beginning at 50% of target percent is probably more than safe enough.
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 7:44 pm
by ReEfnWrX
Okay so,
Code: Select all
// At the end of the day, we need to decrement the acclimation counter.
static boolean acclCounterReady=false; // We need a boolean so we only do this once per day
if (now()%SECS_PER_DAY!=0) acclCounterReady=true; // If it's not midnight we'll get the boolean ready
if (now()%SECS_PER_DAY==0 && acclCounterReady && acclDay>0) { // It's midnight, our bool is true and acclDay is more than 0
acclDay--; // Reduce the counter
acclCounterReady=false; // Reset the boolean flag
InternalMemory.write(Mem_B_AcclDay,acclDay); // Update memory
AcclDay--; Decreases the number stored in memory location 100 by 1?
So if memory location 100 = 0 this code will be inactive. But send wifi command to change that memory location value to 30 which represents number of days wanted for acclimation period.
Everynight this number will be be reduced by 1 until it hits 0 at which point this code will be inactive and the normal PWM code will take over again.
So if anyone wanted to edit how many days their acclimation cycle is or alter the starting end% they would need to calculate a new float acclPercentPerDay= based on how many days they want to acclimate for and the percent offset Example 60 Days starting at 20% of current End%... .2/60 = acclPercentPerDay
Am I catching all this so far?
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 8:33 pm
by lnevo
Yes and if we wanted to get advanced we could define the starting dimming percent, ending percent and how many days your normal cycle is and it could calculate the factor either in a variable or other mem locations. I think i store the minutes I offset in memory.
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 10:02 pm
by ReEfnWrX
So if I defined
Code: Select all
#define Mem_B_acclEndPercent 103
byte acclEndPercent = InternalMemory.read(Mem_B_acclEndPercent)
and I set this memory location to a decimal value of .75 and then I called the memory location as a byte it would read it as 75 instead of .75?
Re: Dimmable LED Acclimation for corals
Posted: Tue Dec 31, 2013 10:28 pm
by ReEfnWrX
So here is a shot in the dark at defining the values in memory to make it easier for others who would want to use this to be able to just state their
- Acclimation Duration
- Acclimation Start%
- Acclimation End%
I switched the float acclFactor= and endPercent= formulas to mine. It seemed easier to me to tweak the code using them since I was defining specific start% rather than defining the start% based on a % decrease of the end%.
All of this compiles with no errors... But I do not know if some of the code I made works as I think...
Refer to my previous post for the part I question
Code: Select all
// This part would go in your global declarations.
#define Mem_B_AcclDay 100 // Will Use 30 for formula examples
#define Mem_B_AcclDuration 101 // 30
#define Mem_B_AcclStartPercent 102 // .25
#define Mem_B_AcclEndPercent 103 // .75
// The rest of this goes inside your loop() or custom function
// Let's make some variables to work with
byte startPercent=InternalMemory.read(Mem_B_AcclStartPercent); // Normal start %
byte endPercent=InternalMemory.read(Mem_B_AcclEndPercent); // Normal end %
byte acclDuration=InternalMemory.read(Mem_B_AcclDuration); //Acclimation Duration
byte acclDay = InternalMemory.read(Mem_B_AcclDay); // Let's get what's in memory
float acclPercentPerDay= ((InternalMemory.read(Mem_B_AcclEndPercent)-InternalMemory.read(Mem_B_AcclStartPercent))/InternalMemory.read(Mem_B_AcclDuration));
// ((.75-.25)/30)=.016667
// This is how much we're going to alter the dimming
// This number could also be used to adjust the duration
// of the slope... the startPercent, the photoperiod..whatever you want
float acclFactor=(acclDay*acclPercentPerDay); // 30*.016667=.5
// Adjust the endPercent based on the acclFactor
endPercent=(endPercent-(acclFactor*100)); // (75 - (.5*100) = 25
// Here's what some samples look like
// Day 30 = 25% (75 - 50)
// Day 25 = 33% (75 - 42)
// Day 20 = 42% (75 - 33)
// Day 15 = 50% (75 - 25)
// Day 10 = 58% (75 - 17)
// Day 5 = 67% (75 - 8)
// Day 0+ = 75% (75 - 0)
ReefAngel.PWM.SetChannel( 0, PWMSlope(13,0,20,30,startPercent,endPercent,40,20) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(12,0,21,30,startPercent,endPercent,40,20) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(12,0,21,30,startPercent,endPercent,40,20) );
// At the end of the day, we need to decrement the acclimation counter.
static boolean acclCounterReady=false; // We need a boolean so we only do this once per day
if (now()%SECS_PER_DAY!=0) acclCounterReady=true; // If it's not midnight we'll get the boolean ready
if (now()%SECS_PER_DAY==0 && acclCounterReady && acclDay>0) { // It's midnight, our bool is true and acclDay is more than 0
acclDay--; // Reduce the counter
acclCounterReady=false; // Reset the boolean flag
InternalMemory.write(Mem_B_AcclDay,acclDay); // Update memory
}
Re: Dimmable LED Acclimation for corals
Posted: Wed Jan 01, 2014 6:38 am
by lnevo
You cant store fractions in a memory location. If you want a fraction store the % and the divide by 100.
Re: Dimmable LED Acclimation for corals
Posted: Wed Jan 01, 2014 6:48 am
by lnevo
Also once you've read memory into your variables you dont have to read again, you can just use the variable to calculate it.
Code: Select all
float acclPercentPerDay= ((InternalMemory.read(Mem_B_AcclEndPercent)-InternalMemory.read(Mem_B_AcclStartPercent))/InternalMemory.read(Mem_B_AcclDuration));
Also in all your calculations you dont need the outside ( ) around the whole equation.
Code: Select all
float acclPercentPerDay= (endPercent-startPercent)/(acclDuration*100);
Re: Dimmable LED Acclimation for corals
Posted: Wed Jan 01, 2014 6:49 am
by lnevo
I added the *100 in the last line to bring jt to a decimal rather than make each percentage a decimal.
Re: Dimmable LED Acclimation for corals
Posted: Wed Jan 01, 2014 10:03 am
by ReEfnWrX
I wasn't sure about it so I figured, when in doubt... wrap it... lol
I have added a acclStartingEndPercent so we can have different values for normal Start% and our desired acclimation starting End Percent. Before Day 1 of acclimation would have had a start% that was equal to its end%
I will test the coding either today or later this week.
So to configure the memory locations I would enter these.
AcclDay - Set this equal to your AcclDuration to begin the Acclimation cycle. Should be set to 0 if you want your normal LED schedule to run.
http://ip.address:2000/mb100,0
AcclDuration - Set this to how many days you want your acclimation cycle to take.
http://ip.address:2000/mb101,30
AcclStartingEndPercent - Set this to your desired acclimation Starting End%
http://ip.address:2000/mb102,25
StartPercent - Set this to your normal start%
http://ip.address:2000/mb103,11
EndPercent - Set this to your normal end%
http://ip.address:2000/mb104,75
And I am guessing for these to take affect we would need to reboot
http://ip.address:2000/boot
Code: Select all
// This part would go in your global declarations.
#define Mem_B_AcclDay 100 // 30
#define Mem_B_AcclDuration 101 // 30
#define Mem_B_AcclStartingEndPercent 102 // 25
#define Mem_B_StartPercent 103 // 11
#define Mem_B_EndPercent 104 // 75
// The rest of this goes inside your loop() or custom function
// Let's make some variables to work with
byte acclDay = InternalMemory.read(Mem_B_AcclDay); // Let's get what's in memory
byte acclDuration = InternalMemory.read(Mem_B_AcclDuration); //Acclimation Duration
byte acclStartingEndPercent = InternalMemory.read(Mem_B_AcclStartingEndPercent); // Starting End% for Acclimation
byte startPercent = InternalMemory.read(Mem_B_StartPercent); // Normal start%
byte endPercent = InternalMemory.read(Mem_B_EndPercent); // Normal end %
float acclPercentPerDay= (endPercent-acclStartingEndPercent)/(acclDuration*100); // (75-25)/(30*100)=.016667
// This is how much we're going to alter the dimming
// This number could also be used to adjust the duration
// of the slope... the startPercent, the photoperiod..whatever you want
float acclFactor=acclDay*acclPercentPerDay; // 30*.016667=.5
// Adjust the endPercent based on the acclFactor
endPercent=endPercent-(acclFactor*100); // (75 - (.5*100) = 25
// Here's what some samples look like
// Day 30 = 25% (75 - 50)
// Day 25 = 33% (75 - 42)
// Day 20 = 42% (75 - 33)
// Day 15 = 50% (75 - 25)
// Day 10 = 58% (75 - 17)
// Day 5 = 67% (75 - 8)
// Day 0+ = 75% (75 - 0)
ReefAngel.PWM.SetChannel( 0, PWMSlope(13,0,20,30,startPercent,endPercent,40,20) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(12,0,21,30,startPercent,endPercent,40,20) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(12,0,21,30,startPercent,endPercent,40,20) );
// At the end of the day, we need to decrement the acclimation counter.
static boolean acclCounterReady=false; // We need a boolean so we only do this once per day
if (now()%SECS_PER_DAY!=0) acclCounterReady=true; // If it's not midnight we'll get the boolean ready
if (now()%SECS_PER_DAY==0 && acclCounterReady && acclDay>0) { // It's midnight, our bool is true and acclDay is more than 0
acclDay--; // Reduce the counter
acclCounterReady=false; // Reset the boolean flag
InternalMemory.write(Mem_B_AcclDay,acclDay); // Update memory
}
Re: Dimmable LED Acclimation for corals
Posted: Wed Jan 01, 2014 10:50 am
by lnevo
You won't need to reboot
Also the last two memory settings the normal start% and normal end% are already allocated and can be set in the portal. So you can use those locations to store those and set them directly in the portal instead of direct wifi calls.
Look in Globals/Globals.h in the libraries folder to see what the variable names / locations are. Search for VarsStart
Re: Dimmable LED Acclimation for corals
Posted: Wed Jan 01, 2014 11:51 am
by ReEfnWrX
VarsStart is 200
VarsEnd is VarsStart+164
so does that mean the memory location is 364?