Page 1 of 1

Parameter out of range warning flasher

Posted: Wed Sep 12, 2012 12:56 pm
by jsclownfish
I'm adding a little function on my display to flash the numbers red when they are above or below where I expect them to be so they are easy to see. I thought it might be useful if others want to use it as well and maybe we could add it to future libraries. There might be easier ways to do this as well. Here is my attempt....

Code: Select all

//function to flash warning (parameter, high limt, low limit, x, y, decimal)
void Warningflash(int param, int high, int low, byte x, byte y, byte z)
{
  int mod=second()%2;
  if (param > high || param < low) 
 {
     if (mod==0) ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+40,y+10);
     else ReefAngel.LCD.DrawSingleMonitor(param, COLOR_RED, x, y, z);
 }
 else ReefAngel.LCD.DrawSingleMonitor(param, DefaultFGColor, x, y, z);
} 
...
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(0, 1, 11, 132, 11);
  // Display the PH with color sensors
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor, 5, 13,"PH:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, 0, 23, 13, 100);
Warningflash(ReefAngel.Params.PH, 840, 790, 23, 13, 100);
.....
I'll try this tonight to see how it goes.
-Jon

Re: Parameter out of range warning flasher

Posted: Wed Sep 12, 2012 1:26 pm
by lnevo
Awesome idea! Should definitely be in the libraries as a standard function..

DrawSingleMonitorFlash()
DrawSingleMonitorAlarm()

or even just override the existing DrawSingleMonitor();

Code: Select all

void DrawSingleMonitor(param, color, x, y, z, high, low, warning_color?); ?
I think I like the override personally, not sure if that will be more confusing to some...

Re: Parameter out of range warning flasher

Posted: Wed Sep 12, 2012 1:31 pm
by rimai
Wanna try to create a pull request :)

Re: Parameter out of range warning flasher

Posted: Wed Sep 12, 2012 2:32 pm
by lnevo
rimai wrote:Wanna try to create a pull request :)
Sure. which method did you prefer though?

I do need to get back to the git stuff so I can clone off your dev branch and start the commenting process again...

I'm in montreal for the week for business so next week I can setup the function. Any feedback on the function declaration I put? I can rearrange the params, etc on feedback...

Lee

Re: Parameter out of range warning flasher

Posted: Wed Sep 12, 2012 2:39 pm
by rimai
yes, fork the latest dev branch and work on it. When you are done, send a pull request.
I personally like DrawSingleMonitorAlarm() :)

Re: Parameter out of range warning flasher

Posted: Wed Sep 12, 2012 2:52 pm
by lnevo
Cool, I'm not partial, and long term that will be less confusing for people who may not understand overridden functions...

Re: Parameter out of range warning flasher

Posted: Wed Sep 26, 2012 11:12 am
by lnevo
Ok, I've cloned the repo again... merged with dev and added the DOxygen title page and the function DrawSingleMonitorAlarm function... here's the declaration

Code: Select all

void DrawSingleMonitorAlarm(int Temp, byte fcolor, byte x, byte y, byte decimal, byte high, byte low, byte wcolor);
So the params are the same as DrawSingleMonitor with the addition of high, low and warning color to the args.

Hopefully my pull request is good, but it seems two seperate commits happened, and the second was after the pull request, so I'm not 100% sure what I'm doing git wise...

Lee

Re: Parameter out of range warning flasher

Posted: Fri May 03, 2013 2:03 pm
by lnevo
Ok, I think I finally made a clean pull request for this function :)

Re: Parameter out of range warning flasher

Posted: Fri May 03, 2013 2:09 pm
by rimai
Yeap :)
It will be in the next lib release.

Re: Parameter out of range warning flasher

Posted: Fri May 03, 2013 2:25 pm
by enigma32
haha- I was reading this thinking, "oh, I should +1 this"... then I looked at the dates :-)

This is great. I have a question re: the method prototype though.

Code: Select all

void DrawSingleMonitorAlarm(int Temp, byte fcolor, byte x, byte y, byte decimal, byte high, byte low, byte wcolor);
Isn't it a problem that "Temp" is an int and "high" and "low" are bytes?

Re: Parameter out of range warning flasher

Posted: Fri May 03, 2013 2:31 pm
by lnevo
Yes.

Re: Parameter out of range warning flasher

Posted: Fri May 03, 2013 2:35 pm
by lnevo
Pushed the fix :)

Re: Parameter out of range warning flasher

Posted: Fri May 03, 2013 2:38 pm
by enigma32
haha excellent