Bug on v0.9.6

Related to the development libraries, released by Curt Binder
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Bug on v0.9.6

Post by rimai »

I was just pointed out today by jpalmer of a bug on the XML data being sent by the controller with the v0.9.6 libs.
I think this may have been what is causing problems with the Portal and wifi connectivity.
It was an experimental approach that Curt and Dave were testing for the Client that should have not been included on the released version.
Please be patient. I'm currently working on the bug and it should be fixed on next update.
I'm sorry for the inconvenience.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Bug on v0.9.6

Post by binder »

I thought I had everything removed and only had the insignificant stuff left. Apparently I was wrong. :?
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

Is this why the expansion relays are no longer showing for me in the portal or on the web banner? They do show in the Android app and are working properly on the timers

Sent from my Galaxy Nexus using Tapatalk 2
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Bug on v0.9.6

Post by rimai »

Could be.
Can you download the new installer and try with the new libraries?
Roberto.
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

I did use the new installer and version 0.9.6 lib
or has a new version been pushed in the last few days?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Bug on v0.9.6

Post by rimai »

Did one yesterday 0.9.8 with a custom Arduino compilation :)
No more fiddling around with features file no more!!!
The Arduino will auto-set your features based on code :mrgreen:
Roberto.
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

oh cool, I just downloaded it, ill get it pushed here in a bit and let you know what the result is
Image
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

Getting timeouts again with the avrdude is there a new version of the arduino tool out?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Bug on v0.9.6

Post by rimai »

My bad. It was my mistake :(
I realized it a couple hours ago that the installer was packaged with the old avrdude and just finished uploading a new installer package.
Can you try the new one?
Roberto.
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

Sure, ill go and download it now and repush
Image
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

Redid the push to the controller and it went through, but now it looks like my wifi isnt working properly
when i go to the website ip address:2000\wifi i get this
<script language="javascript" src="http://www.reefangel.com/wifi/ra1.js"/>
Image
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

Ok looks like that did it, I had to reprogram the wi-fi unit and I can see the expansion relay now in the portal and the banner. I did lose the ability to see the RF module and the PWM module in the portal
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Bug on v0.9.6

Post by rimai »

projectx wrote:Redid the push to the controller and it went through, but now it looks like my wifi isnt working properly
when i go to the website ip address:2000\wifi i get this
<script language="javascript" src="http://www.reefangel.com/wifi/ra1.js"/>
https://github.com/reefangel/Libraries/issues/11
This issue has been logged.
Thanks.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Bug on v0.9.6

Post by rimai »

projectx wrote:Ok looks like that did it, I had to reprogram the wi-fi unit and I can see the expansion relay now in the portal and the banner. I did lose the ability to see the RF module and the PWM module in the portal
Can you open a new thread for this?
Roberto.
projectx
Posts: 120
Joined: Sat Apr 23, 2011 6:53 pm

Re: Bug on v0.9.6

Post by projectx »

By all means

Sent from my Galaxy Nexus using Tapatalk 2
Image
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

projectx wrote:Redid the push to the controller and it went through, but now it looks like my wifi isnt working properly
when i go to the website ip address:2000\wifi i get this
<script language="javascript" src="http://www.reefangel.com/wifi/ra1.js"/>
rimai wrote:
projectx wrote:Redid the push to the controller and it went through, but now it looks like my wifi isnt working properly
when i go to the website ip address:2000\wifi i get this
<script language="javascript" src="http://www.reefangel.com/wifi/ra1.js"/>
https://github.com/reefangel/Libraries/issues/11
This issue has been logged.
Thanks.
I believe I am having this issue with the 1.0.0 Libraries.

Both my private and public IP addresses give me this result.

HTTP/1.1 200 OK
Server: ReefAngel
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Connection: close
Content-Type: text/html
Content-Length: 82

<script language='javascript' src='http://www.reefangel.com/wifi/ra1.js'></script>

Portal says my wifi address is invalid but it's not. Portal Dashboard says it needs a valid address to my controller to allow me to toggle relays etc.

Also getting 'Error 23: XML SAX Parser" when trying to refresh from controller in Android app 0.6.1

Nick
180G FOWLR
20GH QT#1
29G QT#2

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

Re: Bug on v0.9.6

Post by rimai »

That was fixed a while ago. Let me look at it again.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Bug on v0.9.6

Post by rimai »

I'm testing on v1.0.0 and I get correct results.
Which browser are you using?
Can you wireshark and post the tcp stream?
Roberto.
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

Browser related...

IE 9 Gives me "Reef Angel Controller Web Server"

Firefox 13.0.1 Gives me

HTTP/1.1 200 OK
Server: ReefAngel
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Connection: close
Content-Type: text/html
Content-Length: 82

<script language='javascript' src='http://www.reefangel.com/wifi/ra1.js'></script>


The Portal is still telling me my wifi address is not valid so I have no remote control.

Also still getting the "Error 23: XML SAX Parser" error in the Android app

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

00Warpig00 wrote:Browser related...

The Portal is still telling me my wifi address is not valid so I have no remote control.

Also still getting the "Error 23: XML SAX Parser" error in the Android app

Nick
Started tracking my issue down.

my problem is directly related to one variable. The line of my code that causes this issue is...

ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,1,100,1) );

to highlight the variable that causes my issue I have changed it to an x in the following line

ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,x,100,1) );

it appears as if this variable is set to "1" I get all of the symptoms listed below

Portal cannot connect to my wifi "Unreachable Address"
Android app shows me "Error 23: XML SAX Parser"

I have tested with that variable set at 0 1 2 3 and the ONLY one that results in these symptoms is "1"

So I have tried

ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,0,100,1) );
ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,2,100,1) );
ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,3,100,1) );

all those seem to work for me, but not

ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,1,100,1) );


Here is my PWM code lines as they sit with the issue. The middle line is the offending line.

ReefAngel.PWM.SetChannel( 0, PWMParabola(9,0,20,0,3,100,3) );
ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,1,100,1) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(0,0,10,0,15,100,2,15) );


Nick
180G FOWLR
20GH QT#1
29G QT#2

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

Re: Bug on v0.9.6

Post by rimai »

Wow. Nice troubleshooting.
Let me look into what happens within the parabola function when you use the 1 parameter.


Sent from my SPH-D700 using Tapatalk 2
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Bug on v0.9.6

Post by rimai »

I can't seem to be able to replicate the issue.
Is there any particular window frame that this happens or is it all the time?
Roberto.
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

Here is my complete code with the problem. Maybe it matters.

Code: Select all

#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 <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

// Initialize Buzzer variables
byte buzzer=0;

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port3Bit | Port4Bit | Port5Bit;
    ReefAngel.FeedingModePortsE[0] = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port3Bit | Port4Bit;
    ReefAngel.WaterChangePortsE[0] = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port4Bit | Port5Bit | Port6Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit | Port8Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 850 );


    // Ports that are always on
    ReefAngel.Relay.On( Port3 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardFan( Port1,790,820 );
    ReefAngel.StandardATO( Port2,60 );
    ReefAngel.Relay.DelayedOn( Port4,5 );
    ReefAngel.WavemakerRandom( Port5,30,100 );
    ReefAngel.StandardHeater( Port6,751,761 );
    ReefAngel.StandardLights( Box1_Port1,14,0,23,0 );
    ReefAngel.StandardLights( Box1_Port2,14,0,23,0 );
    ReefAngel.StandardHeater( Box1_Port3,751,761 );
    ReefAngel.StandardHeater( Box1_Port4,751,761 );
    ReefAngel.PWM.SetChannel( 0, PWMParabola(9,0,20,0,3,100,3) );
    ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,1,100,1) );
    ReefAngel.PWM.SetChannel( 2, PWMSlope(0,0,10,0,15,100,2,15) );

    ////// Place your custom code below here
    

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "00Warpig00" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Dimming Expansion
    x = 15;
    y = 2;
    for ( int a=0;a<6;a++ )
    {
      if ( a>2 ) x = 75;
      if ( a==3 ) y = 2;
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
      y += 10;
    }
    pingSerial();

    // I/O Expansion
    byte bkcolor;
    x = 14;
    y = 34;
    for ( int a=0;a<6;a++ )
    {
      ReefAngel.LCD.DrawCircleOutline( x+(a*20),y,4,COLOR_MEDIUMORCHID );
      if ( ReefAngel.IO.GetChannel(a) ) bkcolor=COLOR_WHITE; else bkcolor=COLOR_GRAY;
      ReefAngel.LCD.FillCircle( x+(a*20),y,2,bkcolor );
    }
    pingSerial();

    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 44, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 44, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // Salinity
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,76, "SAL:" );
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,76, ReefAngel.Params.Salinity );
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 90, TempRelay );
    pingSerial();

    // Relay Expansion
    TempRelay = ReefAngel.Relay.RelayDataE[0];
    TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
    TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
    ReefAngel.LCD.DrawOutletBox( 12, 104, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}
code generated by install wizard.

Im using 1.0.0 libs.

all the hardware I bought from you is plugged in on the bench except any probes or float switches or LED drivers. IE all modules are plugged in however no input devices are... except temp probes. They are pluged in.

I miss spoke earlier. I still seem to get the XML Parser error on My Android most of the time but at least now my android controls the relay boxes and the Portal can connect to my controller. I have made NO changes to anything except that one line of code. to get this far. right now I am using the line to match the one above it except addressing it to PWM port 1

ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,3,100,3) );

using this line I dont get the Parser error. but changing the two 3.'s on that line and experimenting with different values causes the parser error to sometimes appear. particularly if i use a line like..

ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,0,100,1) );

this gives me a parser error most all the time on my droid app but I can still control relay boxes.
and the portal can still find my controller



Nick
180G FOWLR
20GH QT#1
29G QT#2

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

Re: Bug on v0.9.6

Post by rimai »

Ok, so just to confirm that it is indeed the parabola that is causing it, can you set the channels to:

Code: Select all

ReefAngel.PWM.SetChannel( 0, 10 );
ReefAngel.PWM.SetChannel( 1, 10 );
ReefAngel.PWM.SetChannel( 2, 10 );
By doing so, do you still get xml parser errors?
Roberto.
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

I will try your code in a minute. While I was out to dinner I played with the Android app a bit. I'm not exactly sure whats going on with the "Error 23: XML SAX Parser" issue. I have not identified a pattern yet but with the following code...

ReefAngel.PWM.SetChannel( 0, PWMParabola(9,0,20,0,3,100,3) );
ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,3,100,3) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(0,0,10,0,15,100,2,15) );

The Portal seems to be fine connecting with my controller at this point.
I am still having the Parser error show up in the android app. Seems as if the android app is having trouble and cannot update UI of the app or is not reading data correctly from the controller. IE I can still turn outlets on and off but If I exit the App and go back in it may not show the correct state of the outlet. I can still flip the outlet on/off but I see the parser error every time I touch anything in the app.
It has worked a couple times without error... but it seems to be immediately after I upload to and boot the controller that it may work with no parser error.

Going to try your code now. Back in a few with results.

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

rimai wrote:Ok, so just to confirm that it is indeed the parabola that is causing it, can you set the channels to:

Code: Select all

ReefAngel.PWM.SetChannel( 0, 10 );
ReefAngel.PWM.SetChannel( 1, 10 );
ReefAngel.PWM.SetChannel( 2, 10 );
By doing so, do you still get xml parser errors?

This seems to take care of the Parser issue. I touched the update button about 25 times while holding one or two termp probes and was watching the temp climb. I would hit refresh about every 5 seconds. 90% of the time no parser errors. I did see one or two out of about 25 touches but the app said connecting... for about 5 seconds before the error (seemed more like a timeout) a subsequent touch of refresh would go through and update the screen with no errors. Before I was lucky to get one without an error then all subsequent would error.

However now the Portal says my controller is unreachable again... lol

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

I am SO CONFUSED at this point! The parser error has got to be related to something else... I have completely removed all the PWM lines and uploaded to the controller. was working fine with no parser errors for about 10 refreshes... then BAM! Parser error. now it wont work again and all I get is parser errors. This is crazy!

Rebooted controller and wifi mod... nothing but parser errors now.

time to dumb everything down... unplugging EVERYTHING except main relay box wifi mod and temp sensors and going back to default load...

Nick
180G FOWLR
20GH QT#1
29G QT#2

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

Re: Bug on v0.9.6

Post by rimai »

Let's try resetting the wifi attchment.
But this time, I want you to use a different route to set it up.
First, use the wifi utility to factory reset it.
Please download TeraTerm: http://www.rovingnetworks.com/resources ... 6/Teraterm
Then decompress and edit the wifi attachment.ttl file with your ssid and passphrase.
Start Tera Term and connect to your wifi attachment at 9600 baud using the correct serial com port.
Execute the macro with menu Control->Macro
Let me know if this changes anything.
Attachments
wifi attachment.zip
(711 Bytes) Downloaded 454 times
Roberto.
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

Here is a paste of my tera term results. i have changed a few characters in my WIFI key to keep it protected for now until I change it later. but I wanted everyone with this issue to see the results as it may be helpful to others

CMD
factory RESET
Set Factory Defaults
<2.32> reboot
*Reboot*WiFly Ver 2.32, 02-13-2012 on RN-131
MAC Addr=00:06:66:30:07:6a
Auto-Assoc roving1 chan=6 mode=NONE FAILED
*READY*
CMD
set ftp address 208.109.14.133
AOK
<2.32> save
Storing in config
<2.32> set wlan ssid 2WIRE993
AOK
<2.32> set wlan pass -dx?(X-Ksc%<&jk51l>vn^Bq8D6yB%^yOTlT7P6E/MvR_,#baV.Jt7-pksCh#=z
AOK
<2.32> set option deviceid ReefAngelWifi
AOK
<2.32> set c c 0
AOK
<2.32> set c r 0
AOK
<2.32> set c o 0
AOK
<2.32> set c i 3
AOK
<2.32> set c s 2048
AOK
<2.32> set dns name www.reefangel.com
AOK
<2.32> set i h 198.171.134.6
AOK
<2.32> set i r 80
AOK
<2.32> set i f 0x6
AOK
<2.32> set s t 0x10
AOK
<2.32> set u m 2
AOK
<2.32> set i p 2
AOK
<2.32> save
Storing in config
<2.32> reboot
*Reboot*WiFly Ver 2.32, 02-13-2012 on RN-131
MAC Addr=00:06:66:30:07:6a
Auto-Assoc 2WIRE993 chan=1 mode=WPA2 SCAN OK
Joining 2WIRE993 now..
*READY*
Associated!
DHCP: Start
DHCP in 2024ms, lease=-1s
IF=UP
DHCP=ON
IP=192.168.128.200:2000
NM=255.255.255.0
GW=192.168.128.254
Listen on 2000
CMD
ftp u wifly-235.img
<2.32> FTP connecting to 208.109.14.133
FTP file=34
.........................................................
FTP OK.
UPDATE OK
ftp r wps.img
<2.32> FTP connecting to 208.109.14.133
FTP file=66
.................................
FTP OK.
set u b 57600
AOK
<2.32> set s p 0
AOK
<2.32> save
Storing in config
<2.32> save user
Storing in user
<2.32> reboot


It appears to be working as of now with the base RA load and only the temp probes and main relay box connected. i am headed to lunch now and will try remotely.

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Bug on v0.9.6

Post by 00Warpig00 »

MUST be something somewhere in the code generated by the RA Install wiz or libs. After it was working all afternoon on the base RA load I decided to plug in ONLY the expansion hub and the Expansion relay module/box.

loaded the following code as it sits here... I commented some stuff in/out (commented //wp)
to try to make at least the setup portion more like the RA base load setup to see if I could find the issue.
Uploaded the following to the RA+ and the XML Parser error instantly came back on my android app and the Portal is having intermittent issues connecting to my RA+ (earlier Tera Term Wifi config still in place).

Code: Select all

#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>
//wp #include <InternalEEPROM.h> //duplicate line - see above
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

// Initialize Buzzer variables
//wp byte buzzer=0;

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.AddStandardMenu(); //wp added
    ReefAngel.AddDateTimeMenu(); //wp added    
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port3Bit | Port4Bit | Port5Bit;
    ReefAngel.FeedingModePortsE[0] = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
 //wp   ReefAngel.WaterChangePorts = Port3Bit | Port4Bit;
 //wp   ReefAngel.WaterChangePortsE[0] = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port4Bit | Port5Bit | Port6Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit | Port8Bit;
    // Use T1 probe as temperature and overheat functions
//wp    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
//wp    InternalMemory.OverheatTemp_write( 850 );


    // Ports that are always on
    ReefAngel.Relay.On( Port3 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardFan( Port1,790,820 );
    ReefAngel.StandardATO( Port2,60 );
    ReefAngel.Relay.DelayedOn( Port4,5 );
    ReefAngel.WavemakerRandom( Port5,30,100 );
    ReefAngel.StandardHeater( Port6,751,761 );
    ReefAngel.StandardLights( Box1_Port1,14,0,23,0 );
    ReefAngel.StandardLights( Box1_Port2,14,0,23,0 );
    ReefAngel.StandardHeater( Box1_Port3,751,761 );
    ReefAngel.StandardHeater( Box1_Port4,751,761 );
//wp    ReefAngel.PWM.SetChannel( 0, PWMParabola(9,0,20,0,3,100,3) );
//wp    ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,1,100,1) );
//wp    ReefAngel.PWM.SetChannel( 2, PWMSlope(0,0,10,0,15,100,2,15) );
//wp    ReefAngel.PWM.SetChannel( 0, 10 );
//wp    ReefAngel.PWM.SetChannel( 1, 10 );
//wp    ReefAngel.PWM.SetChannel( 2, 10 );

    ////// Place your custom code below here
    

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "00Warpig00" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Dimming Expansion
    x = 15;
    y = 2;
    for ( int a=0;a<6;a++ )
    {
      if ( a>2 ) x = 75;
      if ( a==3 ) y = 2;
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
      y += 10;
    }
    pingSerial();

    // I/O Expansion
    byte bkcolor;
    x = 14;
    y = 34;
    for ( int a=0;a<6;a++ )
    {
      ReefAngel.LCD.DrawCircleOutline( x+(a*20),y,4,COLOR_MEDIUMORCHID );
      if ( ReefAngel.IO.GetChannel(a) ) bkcolor=COLOR_WHITE; else bkcolor=COLOR_GRAY;
      ReefAngel.LCD.FillCircle( x+(a*20),y,2,bkcolor );
    }
    pingSerial();

    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 44, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 44, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // Salinity
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,76, "SAL:" );
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,76, ReefAngel.Params.Salinity );
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 90, TempRelay );
    pingSerial();

    // Relay Expansion
    TempRelay = ReefAngel.Relay.RelayDataE[0];
    TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
    TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
    ReefAngel.LCD.DrawOutletBox( 12, 104, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}
I am very rusty in programming. I have a feeling that is gonna have to change. lol So I have not gone into the libraries at all at this time. Is there a way to launch the wizard that built this code for me so I can re-do it and start basic and add one piece back at a time? May help troubleshoot and I'm a bit rusty at this point to do it by hand without breaking the code.

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
Post Reply