Alternating display values

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
jsclownfish
Posts: 375
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Alternating display values

Post by jsclownfish »

I had some time today and I was thinking about how to get more info out of the space on my main display. So, I thought I might be able to switch between temperature monitors or maybe have them scroll in the same area on the screen. I remember being advised against using the delay function and that seems to make sense as the temp monitors don't update when things are in a delay. I tried two things: one was scrolling the three temp values across the screen (that didn't work so well), and the second was to switch between temp probes. I am using the Modulo function and the second clock to determine when to switch (or move in the case of scrolling). Is there a better way to do this or is this a bad idea I am not foreseeing?

Here is the demo code I am using....

Code: Select all

// test of scrolling or alternating values onthe custom display

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <ReefAngel.h>
#include <IO.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>

int timescroll;
byte a;
byte b;

void ScrollTemp(byte x, byte y)
{
    ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,x,y,"TANK");
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], COLOR_BLACK, x+25, y, 10);
    ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor,x+50,y,"SUMP");
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], COLOR_BLACK, x+75, y, 10);
    ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,x+105,y,"ROOM");
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_BLACK, x+135, y, 10);
   }
void DrawCustomMain()
{
   //Option 1. scrolling the temperature using time across the display
          ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,1,10,"TEMP:");
          if (second()<=13)
          {
          timescroll = (60-(3*second()))-59;
          ScrollTemp(timescroll, 20);
          }
          else if (second()<=26) 
          {
          timescroll = ((3*second())-77);
          ScrollTemp(timescroll, 20);
          }
          else if (second()<=39) 
          {
          timescroll = (60-(3*second()))+19;
          ScrollTemp(timescroll, 20);
          }
          else if (second()<=52) 
          {
          timescroll = ((3*second())-155);
          ScrollTemp(timescroll, 20);
          }
          else
          {
          ScrollTemp(1, 20);
          } 
   // Option 2: alternating the temp display using time
   a=second() % 3;
   ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,1,50,"TEMP:");
   if (a==0)
   {
     ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,30,50,"TANK");
     ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], COLOR_BLACK, 60, 50, 10);
   }
   else if (a==1)
   {
     ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor,30,50,"SUMP");
     ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], COLOR_BLACK, 60, 50, 10);
   }
   else if (a==2)
   {
     ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,30,50,"ROOM");
     ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_BLACK, 60, 50, 10);
   }
}
void DrawCustomGraph()
{
}
void setup()
{
  ReefAngel.Init();  //Initialize controller and start web banner timer
 }
void loop()
{
   ReefAngel.ShowInterface();
}
-Jon
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternating display values

Post by binder »

Modulo should work fine. I don't foresee there to be any problems with using it.
Post Reply