PDE w/Custom Main and Menus

Share you PDE file with our community
Post Reply
dpitalo
Posts: 39
Joined: Mon Dec 12, 2011 6:45 pm

PDE w/Custom Main and Menus

Post by dpitalo »

I've robbed a lot of code from all the posters here. Thanks for making my life easier, guys!

I just got the controller today and I've managed to modify one of the custom main screens here, get the moonlight working right, and it appears all the timers working correctly.

The one issue I'm having is that when I start feeding mode, it enters the mode then immediately exits. Don't know what's going on there.

Code: Select all

#define SIMPLE_MENU
#define DisplayLEDPWM

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

#define AutoTopOff        1
#define Daylight          2
#define Relay3            3
#define Heater            4
#define Skimmer           5
#define MetalHalide       6
#define Actinic           7
#define Return            8


#include <avr/pgmspace.h>
//Create the menu entries
prog_char menu1_label[] PROGMEM= "Chow Time";
prog_char menu2_label[] PROGMEM= "h2o Change";
prog_char menu3_label[] PROGMEM= "ph Calibration";
prog_char menu4_label[] PROGMEM= "Set Date Time";
//Group menu entries together
PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label,
menu4_label
};

void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry4()
{
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

void DrawCustomMain()
{
byte x = 6;
byte y = 2;
byte t;
ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 6, 2, "Dave's 40g Reef");
ReefAngel.LCD.DrawDate(6, 118);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 17, 132, 17);
//pingSerial();
x = 12;
y += MENU_START_ROW+1;
ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Temp:       ph");
char text[7];
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.Clear(DefaultBGColor, x+16, y+65, x+65, y+16);
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text);
//pingSerial();

ConvertNumToString(text, ReefAngel.Params.Temp1, 10);
y += MENU_START_ROW*2;
x = 10;
ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+(16*4),y+16);
//pingSerial();
ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
//pingSerial(); 
x += (16*4) + 8;


byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

void DrawCustomGraph()
{
}

void setup()
{
  ReefAngel.Init();   //Initialize controller
  ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
  ReefAngel.Relay.On(Return);  //Turn Return on at startup
  ReefAngel.Relay.On(Skimmer); //Turn Skimmer on at startup
}
void loop()
{

  ReefAngel.StandardATO(AutoTopOff,30);       //Setup AutoTopOff as Auto Top-Off function with 30s timeout
  ReefAngel.MHLights(Daylight,10,0,22,30,15); //Daylight schedule 10:00am - 10:30pm with 15min cool down
  ReefAngel.StandardHeater(Heater,788,792);   // Setup Heater to turn on at 78.8F and off at 79.2F
  
    if (hour()>=22 || hour()<=9)
  {
    ReefAngel.PWM.SetActinic(MoonPhase());
  }
  else
  {
    ReefAngel.PWM.SetActinic(0);
  }

  ReefAngel.ShowInterface(); //Draw the Standard Interface
}

rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PDE w/Custom Main and Menus

Post by rimai »

There is nothing wrong with the code.
Make sure to upload a internal memory code at least once.
You can generate it with RAGen by going to menu Controller->Internal Memory.
Or you can just use a generic one here:

Code: Select all

// Autogenerated file by RAGen (v1.0.4.92), (10/02/2011 13:42)
// Memory_100211_1342.pde
//
// This file sets the default values to the Internal Memory
//


#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <Phillips6610LCDInv.h>
#include <avr/pgmspace.h>
#include <ReefAngel_EEPROM.h>


Phillips6610LCDInv e;

void setup()
{
    e.lcd_init();
    e.lcd_clear(COLOR_WHITE,0,0,132,132);
    e.lcd_BacklightOn();

    InternalMemory.MHOnHour_write(15);
    InternalMemory.MHOnMinute_write(30);
    InternalMemory.MHOffHour_write(21);
    InternalMemory.MHOffMinute_write(0);
    InternalMemory.MHDelay_write(7);
    InternalMemory.StdLightsOnHour_write(15);
    InternalMemory.StdLightsOnMinute_write(0);
    InternalMemory.StdLightsOffHour_write(21);
    InternalMemory.StdLightsOffMinute_write(30);
    InternalMemory.DP1OnHour_write(20);
    InternalMemory.DP1OnMinute_write(0);
    InternalMemory.DP2OnHour_write(22);
    InternalMemory.DP2OnMinute_write(30);
    InternalMemory.DP1Timer_write(10);
    InternalMemory.DP2Timer_write(10);
    InternalMemory.DP1RepeatInterval_write(60);
    InternalMemory.DP2RepeatInterval_write(60);
    InternalMemory.ATOTimeout_write(60);
    InternalMemory.ATOHighTimeout_write(60);
    InternalMemory.ATOHourInterval_write(0);
    InternalMemory.ATOHighHourInterval_write(0);
    InternalMemory.FeedingTimer_write(900);
    InternalMemory.LCDTimer_write(600);
    InternalMemory.LEDPWMActinic_write(20);
    InternalMemory.LEDPWMDaylight_write(20);
    InternalMemory.WM1Timer_write(0);
    InternalMemory.WM2Timer_write(0);
    InternalMemory.HeaterTempOn_write(766);
    InternalMemory.HeaterTempOff_write(770);
    InternalMemory.ChillerTempOn_write(774);
    InternalMemory.ChillerTempOff_write(770);
    InternalMemory.OverheatTemp_write(1500);
    InternalMemory.PHMax_write(830);
    InternalMemory.PHMin_write(540);
    InternalMemory.SalMax_write(2550);
    InternalMemory.RFMode_write(Constant);
    InternalMemory.RFSpeed_write(140);
    InternalMemory.RFDuration_write(8);
}

void loop()
{
    // display the values
    char buf[128];
    sprintf(buf, "MH %2d:%02d-%2d:%02d,%d", InternalMemory.MHOnHour_read(), InternalMemory.MHOnMinute_read(),
                                         InternalMemory.MHOffHour_read(), InternalMemory.MHOffMinute_read(),
                                         InternalMemory.MHDelay_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW, buf);
    sprintf(buf, "Std %2d:%02d-%2d:%02d", InternalMemory.StdLightsOnHour_read(), InternalMemory.StdLightsOnMinute_read(),
                                          InternalMemory.StdLightsOffHour_read(), InternalMemory.StdLightsOffMinute_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, buf);
    sprintf(buf, "LED A: %d%% D: %d%%", InternalMemory.LEDPWMActinic_read(), InternalMemory.LEDPWMDaylight_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*3, buf);
    sprintf(buf, "WM1: %ds", InternalMemory.WM1Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, buf);
    sprintf(buf, "WM2: %ds", InternalMemory.WM2Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, buf);
    sprintf(buf, "F: %ds", InternalMemory.FeedingTimer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*6, buf);
    sprintf(buf, "S: %ds", InternalMemory.LCDTimer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*7, buf);
    sprintf(buf, "H On: %d -> %d", InternalMemory.HeaterTempOn_read(), InternalMemory.HeaterTempOff_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*9, buf);
    sprintf(buf, "C On: %d -> %d", InternalMemory.ChillerTempOn_read(), InternalMemory.ChillerTempOff_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*10, buf);
    sprintf(buf, "PH %d - %d", InternalMemory.PHMax_read(), InternalMemory.PHMin_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*11, buf);

    delay(10000);
    e.lcd_clear(COLOR_WHITE,0,0,132,132);

    sprintf(buf, "OH: %dF", InternalMemory.OverheatTemp_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW, buf);
    sprintf(buf, "ATO L: %ds (%dh)", InternalMemory.ATOTimeout_read(), InternalMemory.ATOHourInterval_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, buf);
    sprintf(buf, "ATO H: %ds (%dh)", InternalMemory.ATOHighTimeout_read(), InternalMemory.ATOHighHourInterval_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*3, buf);

    sprintf(buf, "DP1: %2d:%02d", InternalMemory.DP1OnHour_read(), InternalMemory.DP1OnMinute_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, buf);
    sprintf(buf, "     %ds", InternalMemory.DP1Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*6, buf);
    sprintf(buf, "DP2: %2d:%02d", InternalMemory.DP2OnHour_read(), InternalMemory.DP2OnMinute_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*7, buf);
    sprintf(buf, "     %ds", InternalMemory.DP2Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*8, buf);

    delay(10000);
    e.lcd_clear(COLOR_WHITE,0,0,132,132);
}
Roberto.
dpitalo
Posts: 39
Joined: Mon Dec 12, 2011 6:45 pm

Re: PDE w/Custom Main and Menus

Post by dpitalo »

Thanks Roberto, that did the trick!

Now off to make a bracket for the float switches.
Post Reply