To begin with, this is a copy of my current ino file: (It's a bit unorganized because I borrowed bits and pieces from others on the forum to get the functions I wanted, but everything seems to work fine except I can't change the PWM value of the slope via Android app.)
Code: Select all
// Autogenerated file by RAGen (v1.2.1.158), (02/21/2012 22:03)
// RA_022112_2203.ino
//
// This version designed for v0.9.0 or later
/* The following features are enabled for this File:
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 3
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
*/
#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 <RF.h>
#include <ReefAngel.h>
//**************************************************************************************************************
// These are the mode numbers for the RF Expansion Module
//#define Constant 0
//#define Random1 1 // Lagoonal
//#define Random2 2 // Reef Crest
//#define ShortWave 3
//#define LongWave 4
//#define Smart_NTM 5 // Nutrient Transport Mode
//#define Smart_TSM 6 // Tidal Swell Mode
//#define Feeding_Start 7
//#define Feeding_Stop 8
//#define Night 9
//#define Slave_Start 97
//#define Slave_Stop 98
//#define None 99
//**************************************************************************************************************
//Start of PWM Expansion Code Header
// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5
// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
//End of PWM Expansion Code Header
//*************************************************************************************************************
//boolean ForceCloud=false;
prog_char menu1_label[] PROGMEM = "Feeding Mode";
prog_char menu2_label[] PROGMEM = "Water Change Mode";
prog_char menu3_label[] PROGMEM = "Clear ATO Timeout";
PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label};
void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}
#include <avr/pgmspace.h>
//***********************************************************************************************************************
//-------------------------------------Custom Main for PWM Expansion Module----------------------------------------------
byte x,y;
char text[10];
void DrawCustomMain()
{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.Clear(BtnActiveColor,5,0,127,11);
ReefAngel.LCD.DrawText(DefaultBGColor,BtnActiveColor,15,3,"George's 75G Reef");
ReefAngel.LCD.DrawDate(6, 123);
pingSerial();
ReefAngel.LCD.DrawMonitor(15, 20, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
pingSerial();
ReefAngel.LCD.Clear(DefaultFGColor,5,52,127,52);
ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,30,55,"PWM Expansion");
x=15;
y=68;
for (int a=0;a<6;a++)
{
if (a>2) x=75;
if (a==3) y=68;
ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :");
ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a);
ConvertNumToString(text, ReefAngel.PWM.GetChannelValue(a), 1);
strcat(text," ");
ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,text);
y+=10;
}
pingSerial();
// Display Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(13, 97, TempRelay);
pingSerial();
// Display Expansion Relay Box 1
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(13, 109, TempRelay);
pingSerial();
}
void DrawCustomGraph()
{
}
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
ReefAngel.FeedingModePorts = B10000001;
ReefAngel.WaterChangePorts = B11100001;
ReefAngel.OverheatShutoffPortsE[0] = B00001111;
ReefAngel.LightsOnPortsE[0] = B00001111;
// Ports that are always on
ReefAngel.Relay.On(Port1);
ReefAngel.Relay.On(Port3);
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Port7);
ReefAngel.Relay.On(Port8);
ReefAngel.Relay.On(Box1_Port7);
ReefAngel.Relay.On(Box1_Port8);
//********************************************************************************************************************
//RF Module Setup
ReefAngel.RF.SetMode(Slave_Start,0,0);
/*
If you get a compile error similar to this:
'class ReefAngelClass' has no member named 'RF'
Please make sure that you enabled RF Expansion on your features file.
Open RAGen and make sure you have RF Expansion checked under the Features tab.
Or, you can manually edit the file.
The file is located at "Documents\Arduino\libraries\ReefAngel_Features.h" file and has to include this line in it:
#define RFEXPANSION
*/
InternalMemory.RFMode_write(0);
InternalMemory.RFSpeed_write(128);
InternalMemory.RFDuration_write(10);
//********************************************************************************************************************
}
void loop()
{
// Specific functions
ReefAngel.StandardLights(Box1_Port1); //Left Blue LEDs
ReefAngel.StandardLights(Box1_Port2); //Right Blue LEDs
ReefAngel.MHLights(Box1_Port3); //Left White LEDs
ReefAngel.MHLights(Box1_Port4); //Right White LEDs
ReefAngel.StandardHeater(Port2);
ReefAngel.MoonLights(Box1_Port5); //Left Moonlight
ReefAngel.MoonLights(Box1_Port6); //Right Moonlight
ReefAngel.MoonLights(Port4); //Fuge light on when main lights are out
ReefAngel.Portal("tanksnstuff");
// ReefAngel.Relay.Set(Port4, (ReefAngel.StandardLights!=true)); //Need to find way to make fuge light come one when Actinics are off.
//*********************************************************************************************************************************
//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(8,0,22,0,10,50,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(8,0,22,0,10,50,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(10,0,20,30,10,50,75,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(10,0,20,30,10,50,75,PWMChannel[LEDPWM3]);
// The lines above are what calculates the slope.
// You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
// The are as follow:
// 1st parameter: hour to start slope
// 2nd parameter: minute to start slope
// 3rd parameter: hour to end slope
// 4th parameter: minute to end slope
// 5th parameter: % of the PWM signal to start slope
// 6th parameter: % of the PWM signal to end slope
// 7th parameter: duration of slope in minutes
// 8th parameter: always the same as the variable before the PWMSlope() call
//PWMChannel[LEDPWM1]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM1]);
// In the example above, we are starting the slope at 3:00pm with 15% and going up to 45% within 90 minutes, which would be 4:30pm.
// Then it would stay at 45% from 4:30 to 90 minutes prior to 9:30pm, which would be 8:00pm.
// Then from 8:00pm, it would start sloping down from 45% all the way back to 15% within 90 minutes, which would be 9:30pm.
//CheckCloud();
ReefAngel.PWM.Expansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
ReefAngel.PWM.Expansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
ReefAngel.PWM.Expansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
ReefAngel.PWM.Expansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
//End of PWM Expansion Code for Slope
//*********************************************************************************************************************************
ReefAngel.ShowInterface();
}
Code: Select all
// Autogenerated file by RAGen (v1.2.1.158), (02/19/2012 15:48)
// Memory_021912_1548.ino
//
// This file sets the default values to the Internal Memory
//
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.MHOnHour_write(10);
InternalMemory.MHOnMinute_write(0);
InternalMemory.MHOffHour_write(20);
InternalMemory.MHOffMinute_write(30);
InternalMemory.MHDelay_write(5);
InternalMemory.StdLightsOnHour_write(8);
InternalMemory.StdLightsOnMinute_write(0);
InternalMemory.StdLightsOffHour_write(22);
InternalMemory.StdLightsOffMinute_write(0);
InternalMemory.DP1OnHour_write(20);
InternalMemory.DP1OnMinute_write(0);
InternalMemory.DP2OnHour_write(22);
InternalMemory.DP2OnMinute_write(30);
InternalMemory.DP1Timer_write(0);
InternalMemory.DP2Timer_write(0);
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(0);
InternalMemory.LEDPWMDaylight_write(0);
InternalMemory.WM1Timer_write(0);
InternalMemory.WM2Timer_write(354);
InternalMemory.HeaterTempOn_write(780);
InternalMemory.HeaterTempOff_write(791);
InternalMemory.ChillerTempOn_write(810);
InternalMemory.ChillerTempOff_write(785);
InternalMemory.OverheatTemp_write(1500);
InternalMemory.PHMax_write(840);
InternalMemory.PHMin_write(550);
InternalMemory.SalMax_write(2550);
InternalMemory.RFMode_write(Constant);
InternalMemory.RFSpeed_write(140);
InternalMemory.RFDuration_write(8);
InternalMemory.RFDuration_write(8);
InternalMemory.PWMSlopeStartD_write(10);
InternalMemory.PWMSlopeEndD_write(128);
InternalMemory.PWMSlopeDurationD_write(60);
InternalMemory.PWMSlopeStartA_write(10);
InternalMemory.PWMSlopeEndA_write(128);
InternalMemory.PWMSlopeDurationA_write(60);
InternalMemory.IMCheck_write(0x5241494D);
}
void loop()
{
// display success screen
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, "Internal Memory Set");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, "Now load your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, " RA code file");
delay(5000);
}
Code: Select all
// AutoGenerated file by RAGen (v1.2.1.158), (02/22/2012 01:14)
/*
* Copyright 2010-12 Curt Binder
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 3
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
#endif // __REEFANGEL_FEATURES_H__
Code: Select all
PWMChannel[LEDPWM0]=PWMSlope(8,0,22,0,10,50,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(8,0,22,0,10,50,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(10,0,20,30,10,50,75,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(10,0,20,30,10,50,75,PWMChannel[LEDPWM3]);
I'm really looking to temporarily adjust the "current" PWM % for each channel I'm using (override the slope's current %)... so I can find a color combination I'm happy with for the "MAX %" to be used during the slope. Once I find a combination of whites/blues that I'm happy with, I can just set the 4 PMWChannel slopes as I am already doing, and then leave it alone. Would be nice to manually change the "current" value of any of them via the android app though... just as people using the 2 standard PWM channels can.
So, any ideas on what I need to do to have this feature?
I just ordered the RA+ board by the way, so my .ino code length shouldn't be an issue in the very near future. Any help would be greatly appreciated.