-
Posts: 2849 Joined: Fri Mar 18, 2011 6:20 pm Location: Illinois
|
 Posted: Sat Jun 24, 2017 7:56 pm
Since I am redoing my 75g saltwater tank and making upgrades, I decided my controller's main screen needed an "update". So, I worked out a new custom screen and figured I would share with everybody. I have a maxspect gyre xf230 that is controlled via the Daylight port. I have a specific mode that I run it at during the "night" hours. I have created a specific set of internal memory locations just for the night modes.

- curt custom main screen
- curt_custom_main.jpg (49.89 KiB) Viewed 4259 times
___TEST CODE___ at the top is changed to the current date and time when it's running normally. I have T2 and T3 set to only display when the probes are connected. I have the Water Level Expansion and Salinity Expansion on my tank, so those values are included. Water is the water level attachment that I have for my reservoir tank. The screenshot is a test screen. I have hard coded values when I enabled the test mode that way I can get a better idea of how the screen layout is. I took the bar graph code from the "2014 home screen" in the libraries and shrunk it down to half the size, so I can squeeze it in smaller spaces. The word "Constant" is the current mode the DC Pump is running in and the bar with number is the speed of the pump on the Daylight channel. I'm using the standard outlet box but have thought about switching over to the horizontal circle outlet box. I haven't looked at the circle outlets for a long time, so I'm not sure if I will do it or not. Anyways, here's the FULL code that I'm running. I'm including my FULL code since I had to create extra functions to get what I wanted done. - Code: Select all
// RA+ for 75 Gallon tank // // Updated: 6/18/2017 // // Expansion Modules Added: // Expansion Hub // Salinity // Water Level // // Features: // T1 - Tank Temperature probe // T2 - Room Temperature probe // AP - N/A // DP - Gyre XF230 // Water Level - Water Level of reservoir // PH - probe in sump // Salinity - probe in sump // // // Ports: // 1 - Skimmer // 2 - WM Left // 3 - Heater // 4 - Return // 5 - Maxspect Gyre XF230 // 6 - PhosBan 150 Reactor // 7 - Hydra 26 HD Power Supply // 8 - Hydra 26 HD Power Supply // //
#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 <Salinity.h> #include <WaterLevel.h> #include <DCPump.h> #include <ReefAngel.h>
// Global variables // used for test controller //#define __TEST__ // starting point for left edge of screen #define LEFT_EDGE 8 // DC Pump mode text strings String PUMP_MODES[] = {"Constant","Lagoon","ReefCrest","Short Pulse","Long Pulse","Nutrient", "Tidal Swell","Feeding","","Night","","Custom","Else","Sine","Gyre"}; // graphics for the water level bar const unsigned PROGMEM char BAR_CENTER[] = {0x92, 0x92, 0xFF, 0xFF, 0xFF, 0xFF, 0xDB, 0xDB, 0xB6, 0xB6, 0xB6, 0xB6}; const unsigned PROGMEM char BAR_WL_LEFT[] = {0x29, 0x29, 0x2A, 0x72, 0x72, 0x96}; const unsigned PROGMEM char BAR_WL_RIGHT[] = {0x6E, 0x92, 0x96, 0xDB, 0xDB, 0xDB}; const unsigned PROGMEM char BAR_DP_LEFT[] = {0xAB, 0xAB, 0xAF, 0xD3, 0xD7, 0xFB}; const unsigned PROGMEM char BAR_DP_RIGHT[] = {0xB7, 0xB7, 0xB7, 0xDB, 0xDB, 0xDB};
// Memory Locaitons #define CURT_MEMORY 50 #define DCPUMP_NIGHT_MODE CURT_MEMORY #define DCPUMP_NIGHT_SPEED DCPUMP_NIGHT_MODE + 1 #define DCPUMP_NIGHT_DURATION DCPUMP_NIGHT_MODE + 2 #define DCPUMP_NIGHT_THRESHOLD DCPUMP_NIGHT_MODE + 3
// Custom functions boolean isNightTime(); void checkCustomMemoryValues(); uint8_t DCPumpNightMode_read(); uint8_t DCPumpNightSpeed_read(); uint8_t DCPumpNightDuration_read(); uint8_t DCPumpNightThreshold_read(); uint8_t CustomRead(int address); void CustomWrite(int address, const uint8_t value);
void setup() { ReefAngel.Init(); //Initialize controller checkCustomMemoryValues(); ReefAngel.AddWifi(); ReefAngel.AddStandardMenu(); ReefAngel.AddSalinityExpansion();
// Default Salinity compensation ReefAngel.Salinity.SetCompensation(0);
ReefAngel.WaterChangePorts = Port4Bit; ReefAngel.OverheatShutoffPorts = Port3Bit | Port7Bit | Port8Bit; ReefAngel.OverheatProbe = T1_PROBE;
// Feeding and water change mode speeds ReefAngel.DCPump.FeedingSpeed = 0; ReefAngel.DCPump.WaterChangeSpeed = 0;
// Ports that are always on ReefAngel.Relay.On(Port1); // Skimmer ReefAngel.Relay.On(Port4); // Return ReefAngel.Relay.On(Port5); // Gyre XF230 ReefAngel.Relay.On(Port6); // PhosBan Reactor ReefAngel.Relay.On(Port7); // Hydra 26 HD ReefAngel.Relay.On(Port8); // Hydra 26 HD
// Ports that are not in use ReefAngel.Relay.Off(Port2); }
void loop() { ReefAngel.StandardHeater(Port3);
ReefAngel.DCPump.DaylightChannel = Sync;
/* Night mode - use alternate memory locations Day mode - default memory locations */ if ( isNightTime() ) { // force in either Constant mode or Long Pulse mode // use the nighttime memory locations ReefAngel.DCPump.UseMemory = false; ReefAngel.DCPump.Mode = DCPumpNightMode_read(); ReefAngel.DCPump.Speed = DCPumpNightSpeed_read(); ReefAngel.DCPump.Duration = DCPumpNightDuration_read(); ReefAngel.DCPump.Threshold = DCPumpNightThreshold_read(); } else { // use default memory values for the modes ReefAngel.DCPump.UseMemory = true; }
ReefAngel.ShowInterface(); }
#define LINE1 19 #define LINE2 47 #define LINE3 70 #define WL_BAR_OFFSET 41 #define DC_BAR_OFFSET 4 void DrawCustomMain() { // Fonts in use: NUMBERS_16x16, FONT_8x16 byte x = 6; byte y = 3; byte t; char text[11]; boolean fNight = isNightTime();
#ifdef __TEST__ ReefAngel.LCD.DrawText(COLOR_RED, DefaultBGColor, x, y, "_____TEST CODE_____"); #else // Date & time ReefAngel.LCD.DrawDate(x, y); #endif // __TEST__
// Divider line ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 128, 11);
// Draw T1 ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10); x = 8; y = LINE1; // 19 // NOTE huge numbers are 16x16 (width x height) ReefAngel.LCD.Clear(DefaultBGColor, x, y, x+64, y+16); ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
// Draw T2 // NOTE 4 digits for T1 (16 width, 16*4 pixels) x = 80; #ifdef __TEST__ ReefAngel.Params.Temp[T2_PROBE] = 810; #endif // __TEST__ if(ReefAngel.Params.Temp[T2_PROBE] > 0) { ReefAngel.LCD.DrawText(T2TempColor, DefaultBGColor, x, y, "T2:"); // NOTE "T2:" is 3 chars of 5 pixels each (15 pixels), plus 2 pixels space after, start on 3rd pixel ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, x+18, y, 10); } else { // No, T2, clear the entire space for it ReefAngel.LCD.Clear(DefaultBGColor, x, y, x+38, y+8); }
// Draw T3 if present y = 29; #ifdef __TEST__ ReefAngel.Params.Temp[T3_PROBE] = 796; #endif // __TEST__ if(ReefAngel.Params.Temp[T3_PROBE] > 0) { ReefAngel.LCD.DrawText(T3TempColor, DefaultBGColor, x, y, "T3:"); // NOTE "T3:" is 3 chars of 5 pixels each (15 pixels), plus 2 pixels space after, start on 3rd pixel ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], T3TempColor, x+18, y, 10); } else { // No, T3, clear the entire space for it ReefAngel.LCD.Clear(DefaultBGColor, x, y, x+38, y+8); }
// Draw PH y = LINE2; #ifdef __TEST__ strcpy(text, "8.20"); #else ConvertNumToString(text, ReefAngel.Params.PH, 100); #endif // __TEST__ // NOTE ph max is X.XX, 4 digits ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 3, y, "pH:", Font8x16); x = 29; // TODO confirm width to clear ReefAngel.LCD.Clear(DefaultBGColor, x, y, x+32, y+16); ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x, y, text, Font8x16);
// Draw Salinity #ifdef __TEST__ strcpy(text, "35.0"); #else ConvertNumToString(text, ReefAngel.Params.Salinity, 10); #endif // __TEST__ // NOTE Salinity max is XX.X, 4 digits x = 69; // TODO confirm width to clear ReefAngel.LCD.Clear(DefaultBGColor, x, y, x+32, y+16); ReefAngel.LCD.DrawLargeText(COLOR_CRIMSON, DefaultBGColor, x, y, text, Font8x16); ReefAngel.LCD.DrawLargeText(COLOR_CRIMSON, DefaultBGColor, 102, y, "ppt", Font8x16);
pingSerial();
// Draw Water Level Box (used code from libraries) y = LINE3; // TODO determine color to use for WATER level (COLOR_ROYALBLUE) ReefAngel.LCD.DrawText(COLOR_ROYALBLUE, DefaultBGColor, 8, y, "Water"); #ifdef __TEST__ t = 79; #else t = ReefAngel.WaterLevel.GetLevel(0); #endif // __TEST__ // sanity check, ensure level isn't greater than 100 if(t > 100) { t = 100; } x = 99; // draw value to the right of the bar ReefAngel.LCD.DrawText(COLOR_ROYALBLUE, DefaultBGColor, 99, y, " "); sprintf(text, "%d%%", t); ReefAngel.LCD.DrawText(COLOR_ROYALBLUE, DefaultBGColor, 99, y, text); // Water level is truncated to 50 pixels instead of 100 // Every 2% equals 1 pixel // divide water level by 2 t = t / 2; byte b; // draw the image to the left of the center line, filled bar background for(b = 0; b < t; b++) { // swidth,sheight, X, Y, img ReefAngel.LCD.DrawImage(1, 6, b + WL_BAR_OFFSET, y + 2, BAR_WL_LEFT); } // draw the center image, indicator ReefAngel.LCD.DrawImage(2, 6, t + WL_BAR_OFFSET, y + 2, BAR_CENTER); // draw the image to the right of the center line, unfilled bar background for(b = t; b < 50; b++) { ReefAngel.LCD.DrawImage(1, 6, b + WL_BAR_OFFSET + 2, y + 2, BAR_WL_RIGHT); }
// Draw DC Pump Mode (next line) y = 88; x = 4; if (fNight) { t = DCPumpNightMode_read(); } else { t = InternalMemory.DCPumpMode_read(); } // copy the string from the global array into a buffer of 11 chars for display on screen PUMP_MODES[t].toCharArray(text, 11); // NOTE text is max of 11 chars, 11*5=55 pixels ReefAngel.LCD.Clear(DefaultBGColor, x, y, x+55, y+8); ReefAngel.LCD.DrawText(COLOR_BLACK, DefaultBGColor, x, y, text);
// Draw Day/Night schedule (same line as pump mode) // NOTE Center text in available space between column 72 and 128 if (fNight) { strcpy(text, "Night"); b = COLOR_BLACK; t = COLOR_WHITE; x = 82; } else { strcpy(text, "Day"); b = DefaultBGColor; t = COLOR_BLACK; x = 90; } // clear entire space with the background color // clear bigger space than just for the text to line up // the bottom of the square with the dc pump speed bar ReefAngel.LCD.Clear(b, 74, y, 128, y+18); ReefAngel.LCD.DrawLargeText(t, b, x, y+1, text, Font8x16);
// Draw DC Pump Speed bar y = 98; x = 58; #ifdef __TEST__ t = 65; #else t = ReefAngel.PWM.GetDaylightValue(); #endif // __TEST__ ReefAngel.LCD.Clear(DefaultBGColor, x, y, x+15, y+8); ReefAngel.LCD.DrawText(COLOR_BLACK, DefaultBGColor, x, y, t); // scale bar to be half width, divide value by 2 t = t / 2; for(b = 0; b < t; b++) { ReefAngel.LCD.DrawImage(1, 6, b + DC_BAR_OFFSET, y + 2, BAR_DP_LEFT); } ReefAngel.LCD.DrawImage(2, 6, t + DC_BAR_OFFSET, y + 2, BAR_CENTER); for(b = t; b < 50; b++) { ReefAngel.LCD.DrawImage(1, 6, b + DC_BAR_OFFSET + 2, y + 2, BAR_DP_RIGHT); }
// Draw outlet bar t = ReefAngel.Relay.RelayData; t &= ReefAngel.Relay.RelayMaskOff; t |= ReefAngel.Relay.RelayMaskOn; ReefAngel.LCD.DrawOutletBox(12, 112, t);
pingSerial(); }
void DrawCustomGraph() { }
boolean isNightTime() { boolean fResult = false; byte bOffHour = InternalMemory.StdLightsOffHour_read(); byte bOffMinute = InternalMemory.StdLightsOffMinute_read(); byte bOnHour = InternalMemory.StdLightsOnHour_read(); byte bOnMinute = InternalMemory.StdLightsOnMinute_read();
/* If current hour is off hour and current minute is equal or after off minute, night time is true if current hour is after off hour, night time is true (beyond midnight, aka early hours in morning, overnight wrap) if current hour is before on hour, night time is true if current hour is on hour and current minute is before off minute, night time is true */ if ( ((hour() == bOffHour) && (minute() >= bOffMinute)) || (hour() > bOffHour) || (hour() < bOnHour) || ((hour() == bOnHour) && (minute() < bOnMinute)) ) { fResult = true; }
return fResult; }
void checkCustomMemoryValues() { if ( DCPumpNightMode_read() > 14 ) { // Default to Constant Mode CustomWrite(DCPUMP_NIGHT_MODE, 0); } if ( DCPumpNightSpeed_read() > 100 ) { // Default to 0 speed CustomWrite(DCPUMP_NIGHT_SPEED, 0); } if ( DCPumpNightDuration_read() > 100 ) { // Default to 0 duration CustomWrite(DCPUMP_NIGHT_DURATION, 0); } if ( DCPumpNightThreshold_read() > 100 ) { // Default to 30 threshold CustomWrite(DCPUMP_NIGHT_THRESHOLD, 30); } }
uint8_t DCPumpNightMode_read() { return CustomRead(DCPUMP_NIGHT_MODE); }
uint8_t DCPumpNightSpeed_read() { return CustomRead(DCPUMP_NIGHT_SPEED); }
uint8_t DCPumpNightDuration_read() { return CustomRead(DCPUMP_NIGHT_DURATION); }
uint8_t DCPumpNightThreshold_read() { return CustomRead(DCPUMP_NIGHT_THRESHOLD); }
uint8_t CustomRead(int address) { #if not defined __SAM3X8E__ return eeprom_read_byte((unsigned char *) address); #else return SPIEEPROM.Read(address); #endif }
void CustomWrite(int address, const uint8_t value) { if (CustomRead(address) != value ) { #if not defined __SAM3X8E__ eeprom_write_byte((unsigned char *) address, value); #else SPIEEPROM.Write(address, value); #endif } }
Enjoy! 
|