Transition from magic numbers in certain RA functions
Posted: Sun Apr 06, 2014 8:45 am
With the recent announcement that the RA basic is being end-of-life'd, I'd like to recommend that some of the standard RA functionality be refactored to be more robust with the assumptions that the user will want to remote-control from a phone or the portal and will have enough memory to support the additional code.
For instance, the wizard uses static "magic numbers" when dimming parabolas etc are created and puts them in the "loop" section, which means (unless I'm mistaken) that you can't really override these values. I have started going through and writing a small library that makes the entire dimming module easier to both remote control, and to understand in the loop() section, so that my init() has items like this:
And my loop() looks like this:
It would also then allow the portal and various phone client devs to easily allow more fine-tuned control of dimming and variable-speed devices, instead of going into advanced menus and setting memory values manually.
Does this already exist and I'm reinventing the wheel? Or might it be a nice way to transition into demonstrating even more of the RA's awesome potential out of the box without having to have the user set memory values manually?
For instance, the wizard uses static "magic numbers" when dimming parabolas etc are created and puts them in the "loop" section, which means (unless I'm mistaken) that you can't really override these values. I have started going through and writing a small library that makes the entire dimming module easier to both remote control, and to understand in the loop() section, so that my init() has items like this:
Code: Select all
SetActinicLEDMax(90);
SetActinicLEDMin(10);
SetRedLEDMax(90);
SetRedLEDMin(10);
SetWhiteLEDMax(90);
SetWhiteLEDMin(10);
SetActinicLEDStartHour(09);
SetActinicLEDStartMinute(30);
SetRedLEDStartHour(10);
SetRedLEDStartMinute(00);
SetWhiteLEDStartHour(10);
SetWhiteLEDStartMinute(00);
SetActinicLEDEndHour(21);
SetActinicLEDEndMinute(00);
SetRedLEDEndHour(20);
SetRedLEDEndMinute(00);
SetWhiteLEDEndHour(20);
SetWhiteLEDEndMinute(00);
SetWhiteLEDDimmingParabolaRate(80);
SetRedLEDDimmingParabolaRate(80);
SetActinicLEDDimmingParabolaRate(60);
//Pretty sure the RA inits with garbage in these, so we'll set the initial state to false (no override, operate in parabola mode) just to be certain
OverrideNormalActinicLEDSettings(false);
OverrideNormalRedLEDSettings(false);
OverrideNormalWhiteLEDSettings(false);
And my loop() looks like this:
Code: Select all
ReefAngel.PWM.SetChannel( 0, PWMSlope(GetActinicLEDStartHour(),GetActinicLEDStartMinute(),GetActinicLEDEndHour(),GetActinicLEDEndMinute(),GetActinicLEDMin(),GetActinicLEDMax(),GetActinicLEDDimmingParabolaRate(),GetActinicLEDMin()) );
ReefAngel.PWM.SetChannel( 3, PWMSlope(GetActinicLEDStartHour(),GetActinicLEDStartMinute(),GetActinicLEDEndHour(),GetActinicLEDEndMinute(),GetActinicLEDMin(),GetActinicLEDMax(),GetActinicLEDDimmingParabolaRate(),GetActinicLEDMin()) );
Does this already exist and I'm reinventing the wheel? Or might it be a nice way to transition into demonstrating even more of the RA's awesome potential out of the box without having to have the user set memory values manually?