I just installed Arduino, RAGen, libs and everything on a new comp. Everything works fine but I'm having issues with an updated .ino file. I installed the attached code (everything went fine) but my PWM Expansion doesn't work properly. This worked fine previously.
Issue:
- LED lights don't turn on.
- When I enter the sub menus, the LEDs flicker but turn off once I exit the menus.
I confirmed that the PWMExpansion is enabled in the Features.H file. Please help. Thanks.
-J
Code: Select all
// Autogenerated file by RAGen (v1.2.1.158), (02/18/2012 22:40)
// RA_021812_2240.ino
//
// This version designed for v0.9.0 or later
/* The following features are enabled for this File:
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
#define PWMEXPANSION
#define CUSTOM_MAIN
*/
#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>
boolean dosing=false;
// LEDPWM Channel defines for easy code reading
#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.
byte PWMChannel[]={0,0,0,0,0,0};
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(6, 120);
pingSerial();
ReefAngel.LCD.DrawText(T1TempColor, DefaultBGColor, 15, 10, "T1:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], T1TempColor, 15+18, 10, 10);
ReefAngel.LCD.DrawText(T2TempColor, DefaultBGColor, 15, 10+10, "T2:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 15+18, 10+10, 10);
ReefAngel.LCD.DrawText(T3TempColor, DefaultBGColor, 15, 10+20, "T3:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], T3TempColor, 15+18, 10+20, 10);
ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, 15+60, 10, "PH:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, PHColor, 15+78, 10, 100);
//ReefAngel.LCD.Clear(255,0,50,93,90);
//ReefAngel.LCD.DrawText(0,255,15+60,52,());
ReefAngel.LCD.DrawText(0,255,15+60,62,"MP:");
ReefAngel.LCD.DrawText(0,255,15+80,62,MoonPhase());
//ReefAngel.LCD.DrawText(0,255,24+80,62,"of");
//ReefAngel.LCD.DrawText(0,255,38+80,62,numclouds);
//ReefAngel.LCD.DrawText(0,255,15+60,72,"CS:");
//ReefAngel.LCD.DrawText(0,255,15+80,72,"00:00");
//ReefAngel.LCD.DrawText(0,255,15+60,82,"LS:");
//ReefAngel.LCD.DrawText(0,255,15+80,82,"00:00");
//ATO status
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 15+60, 10+20, "Pump:");
byte highcolor;
char highstatus[10];
if ( ReefAngel.HighATO.IsActive() )
{
ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, 15+90, 10+20, "ON ");
}
else
{
ReefAngel.LCD.DrawText(T1TempColor, DefaultBGColor, 15+90, 10+20, "OFF");
}
//End ATO status
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 95, TempRelay);
ReefAngel.LCD.DrawText(0,255,15,52,"RB:");
ReefAngel.LCD.DrawText(0,255,15,62,"BB:");
ReefAngel.LCD.DrawText(0,255,15,72,"CW:");
ReefAngel.LCD.DrawText(0,255,15,82,"WW:");
ReefAngel.LCD.DrawText(0,255,15+20,52,PWMChannel[LEDPWM0]);
ReefAngel.LCD.DrawText(0,255,15+20,62,PWMChannel[LEDPWM1]);
ReefAngel.LCD.DrawText(0,255,15+20,72,PWMChannel[LEDPWM2]);
ReefAngel.LCD.DrawText(0,255,15+20,82,PWMChannel[LEDPWM3]);
}
void DrawCustomGraph()
{
//ReefAngel.LCD.DrawGraph(5, 5);
}
void setup()
{
wdt_enable(WDTO_1S);
ReefAngel.Init(); //Initialize controller
ReefAngel.Timer[1].SetInterval(10);
ReefAngel.Timer[2].SetInterval(310);
// Ports that are always on
ReefAngel.Relay.On(Port1);
ReefAngel.Relay.On(Port2);
ReefAngel.WaterChangePorts = B11111111;
ReefAngel.FeedingModePorts = B00010001;
ReefAngel.OverheatShutoffPorts = B00001100;
ReefAngel.LightsOnPorts = B00101000;
}
void loop()
{
// Specific functions
ReefAngel.StandardHeater(Port3);
ReefAngel.StandardLights(Port4);
ReefAngel.Relay.DelayedOn(Port5, 2);
ReefAngel.MHLights(Port8);
// PWM Slope functions for PWM Channels on RA Head unit
//ReefAngel.PWM.ActinicPWMSlope();
//ReefAngel.PWM.DaylightPWMSlope();
if(ReefAngel.HighATO.IsActive())
{
ReefAngel.Relay.DelayedOn(Port1,1);
}
else
{
ReefAngel.Relay.Off(Port1);
}
//skimmer
if ((hour() >= 12) && (hour() <= 21)) ReefAngel.Relay.DelayedOn(Port5,1);
else ReefAngel.Relay.Off(Port5);
if ((hour() >= 12) && (hour() <= 21)) ReefAngel.Relay.On(Port7);
else ReefAngel.Relay.Off(Port7); //Moonlights
//Dosing
if (ReefAngel.Params.PH<820 && !dosing)
{
ReefAngel.Timer[1].Start();
ReefAngel.Timer[2].Start();
ReefAngel.Relay.On(Port6);
dosing=true;
}
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off(Port6);
}
if (ReefAngel.Timer[2].IsTriggered())
{
dosing=false;
}
// Calculate your regular sunrise/sunset PWM value
//PWMChannel[LEDPWM3]=MoonPhase();
if (now()>ScheduleTime(12,0,0) && now()<=ScheduleTime(22,0,0))
{
PWMChannel[LEDPWM0]=PWMSlope(12,30,22,00,15,80,240,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(12,00,22,15,15,70,240,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(12,00,22,15,15,50,240,PWMChannel[LEDPWM2]);
}
else
{
PWMChannel[LEDPWM0]=0;
PWMChannel[LEDPWM1]=0;
PWMChannel[LEDPWM2]=0;
}
//PWMChannel[LEDPWM3]=PWMSlope(12,30,22,00,0,60,240,PWMChannel[LEDPWM3]) ;
//if (hour() <= 4,00 || hour() >= 18,00) (PWMChannel[LEDPWM3]=MoonPhase());
//else (PWMChannel[LEDPWM3]=PWMSlope(12,30,22,00,0,60,240,PWMChannel[LEDPWM3]));
// if (hour() >= 4,00 || hour() <=11,30)
// {
// if (hour() <= 21,00 || hour() >= 11,30) (PWMChannel[LEDPWM3]=PWMSlope(12,30,22,00,15,60,240,PWMChannel[LEDPWM3]));
// else (PWMChannel[LEDPWM3]=MoonPhase());
// }
// else
// {
// PWMChannel[LEDPWM3]=0;
// }
if (now()>ScheduleTime(12,30,0) && now()<=ScheduleTime(18,0,0))
PWMChannel[LEDPWM3]=PWMSlope(12,30,19 ,00,15,60,180,PWMChannel[LEDPWM3]);
else if (now()>ScheduleTime(18,0,0) || now()<=ScheduleTime(4,0,0))
PWMChannel[LEDPWM3]=MoonPhase();
else
PWMChannel[LEDPWM3]=0;
//PWMChannel[LEDPWM0]=PWMSlope(16,30,23,30,0,80,60,PWMChannel[LEDPWM0]);
//PWMChannel[LEDPWM1]=PWMSlope(16,00,21,15,0,70,120,PWMChannel[LEDPWM1]);
//PWMChannel[LEDPWM2]=PWMSlope(17,30,20,30,0,30,60,PWMChannel[LEDPWM2]);
//PWMChannel[LEDPWM3]=PWMSlope(16,0,21,00,0,60,120,PWMChannel[LEDPWM3]);
//CheckCloud();
PWMExpansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
PWMExpansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
PWMExpansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
PWMExpansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
ReefAngel.Portal("aranax", "g0willy!");
ReefAngel.ShowInterface();
}
//*********************************************************************************************************************************
//Start of PWM slope function code designed for the PWM Expansion module
void PWMExpansion(byte cmd, byte data)
{
Wire.beginTransmission(8); // transmit to device #2
Wire.write('$'); // sends $
Wire.write('$'); // sends $
Wire.write('$'); // sends $
Wire.write(cmd); // sends a value
Wire.write(data); // sends 255
Wire.endTransmission(); // stop transmitting
}
//End of PWM slope function code designed for the PWM Expansion module
//*********************************************************************************************************************************