Page 1 of 1
I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 10:18 am
by bigHUN
I assume I have the new libraries installed by the latest installer, also the Arduino1 and RaGen.
I've tried to load from RaGen, but getting errors maybe for a reason that I got my new-partial custom menu a week ago. The new main screen looks OK to me now,
The info here is a bit fragmented, please point me to a good starting point, where I could learn the thing. The initial tutorials would still be OK to practice beside the new libraries are out? At this moment Im not recognising the differences. thanks
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 10:42 am
by rimai
The best way would be to take a look at the example codes that are being installed with the new installer.
File->Sketchbook->Examples
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 10:47 am
by binder
There is not much differences in the programming with the new libraries (0.9.0) vs the old libraries (0.8.5.X). The same functions exist. There are only slight modifications to some of the functions. The major difference is with the include files (ie, behind the scenes stuff). There has been more functionality added into the new libraries to make things a little simpler.
I would suggest starting with the Custom Main Screen and Custom Menu guides (which it sounds like you have started with them already).
http://forum.reefangel.com/viewtopic.php?f=14&t=109
http://forum.reefangel.com/viewtopic.php?f=14&t=311
After looking at that, I would suggest that you start looking through the libraries and trying to figure out how the functions work. This will give you an idea how we toggle ports on and off based on temperatures, ph, etc. When you get a good understanding of that, then you can understand how to customize your code even better.
My public sketchbook has some decent examples in it for reference:
https://github.com/curtbinder/SketchBook
Hopefully this helps point you to a good starting point.
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 11:45 am
by rufessor
Unsure if this was missed in first post.... but indication is that they are using Arduino 1.0
I thought that was non-functional for us until next library update....
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 11:46 am
by rimai
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 11:50 am
by rufessor
Most excellent... I had not (obviously) been on for a day or two!
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 7:53 pm
by bigHUN
1. I don't have at this moment LED, may come as a DIY in the near future, can I expect I don't need a power plug for it? but controlled by RA? how to define this?
2. also, have 3 vawemakers, but they are not controllable (110V), how that code shall look like only ON/OFF timing/each, only to steer the water a bit?
I am expecting to buy from the next budget a WiFi adapter and don't use smartphones at all, so this shall be in the program and selectable from menu....
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 8:21 pm
by rimai
There are several example codes with the new installed.
Check it out.
There are several for PWM to control LED and a couple for wavemakers too.
RAGen is also able to generate the code for you.
There is no option for changing settings from menu though.
The menu system became very heavy for the amount of space we could fit, so there are only a few things you could change using the menu system, but the LED is not one of them.
You could do wavemaker time though.
Best option to change settings if you don't want to use smartphone is one of the other apps: Client or Status.
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 9:22 pm
by bigHUN
Roberto,
1. I never had a closer look at the LEDs ($$$), I just saw somewhere that they have a sort of cellphone charger type plugs ?!? at my fish store, but never saw the plug or the cable by itself how it looks. assume, the controllable having instead of potmeter a 2 or 3 wire connector ?!? so that plugs into RA controller and can do 0-up volts?
Re: I would like to start coding - manualy ?
Posted: Wed Feb 15, 2012 9:24 pm
by rimai
Analog and PWM signal are the most common dimmable drivers.
Re: I would like to start coding - manualy ?
Posted: Fri Feb 17, 2012 8:12 pm
by bigHUN
where are the files defining --->what I currently have in the controller?
I want to change the default what I have on the main screen to what Roberto gave me earlier
Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 6:31 am
by binder
bigHUN wrote:where are the files defining --->what I currently have in the controller?
I want to change the default what I have on the main screen to what Roberto gave me earlier
The location for the libraries is:
Documents\Arduino\libraries
The Sketch folder is:
Documents\Arduino
This folder is where your code files that control what is on the controller.
Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 9:16 am
by bigHUN
last days trying to upload the code, Verify sad all OK, but upload error "Serial port COM4 already in use. Try quitting any program that may be using it"
I reboot the PC several times, keeps coming the same. Testing the ports in RaGen "Microsoft Visual C++ Runtime error" with RaGen.exe
Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 9:56 am
by rimai
I'm pretty sure it is your Client Suite running.
Check the post someone else replied to your problem:
http://forum.reefangel.com/viewtopic.php?p=6129#p6129
Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 12:55 pm
by bigHUN
OK, I've killed the client, question"
1. how to combine the two codes, I would like Roberto's main screen (but I don't have PWM, but have I/O):
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 <ReefAngel.h>
//Main Box
#define Reactor 8
#define Skimmer 7
#define Circulation 6
#define Return 5
#define WM2 4
#define WM1 3
#define Heater 2
#define AutoTopOff 1
byte x,y;
byte bkcolor;
void DrawCustomMain()
{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 112);
pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
y=10;
x=15;
for (int a=0;a<6;a++)
{
if(bitRead(ReefAngel.IO.IOPorts,a)) bkcolor=COLOR_RED;
else bkcolor=COLOR_GREEN;
if (a>2) x=75;
if (a==3) y=10;
ReefAngel.LCD.Clear(bkcolor, x, y-3, x+40,y-1);
ReefAngel.LCD.Clear(bkcolor, x, y+8, x+40,y+10);
ReefAngel.LCD.Clear(bkcolor, x, y, x+3,y+8);
ReefAngel.LCD.Clear(bkcolor, x+37, y, x+40,y+8);
ReefAngel.LCD.DrawText(COLOR_WHITE, bkcolor, x+3, y, "Input");
ReefAngel.LCD.DrawText(COLOR_WHITE, bkcolor, x+32, y, a+1);
y+=15;
}
}
void DrawCustomGraph()
{
}
// setup function runs only once at start-up
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.Relay.On(Return);
ReefAngel.Relay.On(Reactor);
ReefAngel.Relay.On(Circulation);
ReefAngel.Timer[1].SetInterval(30);
}
// loop function keeps running forever after start-up
void loop()
{
ReefAngel.StandardHeater(Heater);
ReefAngel.Wavemaker1(WM1);
ReefAngel.Wavemaker2(WM2);
ReefAngel.Relay.DelayedOn(Skimmer,60);
//Float #1
if (ReefAngel.IO.GetChannel(1)) // if float 1 is triggered
{
ReefAngel.Relay.Off(Return); // Turn Return off
ReefAngel.Relay.Off(Reactor); // Turn Reactor off
BuzzerOn(); // Turn Buzzer on
}
//Float #2
if (ReefAngel.IO.GetChannel(2)) // if float 2 is triggered
{
ReefAngel.Relay.On(AutoTopOff); // Turn AutoTopOff on
ReefAngel.Timer[1].Start(); // Start/Trigger timer
}
// Float #3
if (ReefAngel.IO.GetChannel(3)) // if float 3 is triggered
BuzzerOn(); // Turn Buzzer on
// Float #4
if (ReefAngel.IO.GetChannel(4)) // if float 4 is triggered
ReefAngel.Relay.On(Skimmer); // Turn Skimmer off
// Float #5
if (ReefAngel.IO.GetChannel(5)) // if float 5 is triggered
{
ReefAngel.Relay.Off(Return); // Turn Return off
BuzzerOn(); // Turn Buzzer on
}
// Timer 1
if (ReefAngel.Timer[1].IsTriggered())
ReefAngel.Relay.Off(AutoTopOff); // Turn AutoTopOff off
ReefAngel.ShowInterface();
}
void BuzzerOn()
{
ReefAngel.PWM.SetActinic((now()%2)*100);
}
with the RaGen menu items:
Code: Select all
// Autogenerated file by RAGen (v1.2.1.158), (02/17/2012 22:56)
// RA_021712_2256.ino
//
// This version designed for v0.9.0 or later
/* The following features are enabled for this File:
#define VersionMenu
#define wifi
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 1
#define CUSTOM_MAIN
#define IOEXPANSION
*/
#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 <IO.h>
#include <ReefAngel.h>
#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Item 1";
PROGMEM const char *menu_items[] = {
menu0_label };
void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Item 1");
}
void DrawCustomMain()
{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 112);
pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph(5, 5);
}
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
// Ports that are always on
ReefAngel.Relay.On(Port8);
}
void loop()
{
// Specific functions
ReefAngel.StandardATO(Port1);
ReefAngel.StandardHeater(Port2);
ReefAngel.MHLights(Port3);
ReefAngel.StandardLights(Port4);
ReefAngel.Wavemaker1(Port5);
ReefAngel.Wavemaker2(Port6);
ReefAngel.StandardFan(Port7);
ReefAngel.ShowInterface();
}
Feed Mode; water change mode; vawemakers adjustment (untill I find a right water motion); and maybe PH setup
I would like to compare the 3 files, so this may be a good learning curve
Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 3:19 pm
by rimai
Simply change what is inside the DrawCustomMain() function

Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 3:37 pm
by bigHUN
rimai wrote:Simply change what is inside the DrawCustomMain() function

what is a beginning and where is the end of the "DrawCustomMain" ??I mean, where to start cut and where is the end of the cut?"
this means everything inside { ....} in between the two ?
Roberto, the file you sent me the "DisplayLEDPWM gives me error
Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 3:51 pm
by rimai
Yes, everything in between {...}.
On the code I sent you, you need to have DisplayLEDPWM enabled on the features file.
Your buzzer uses the PWM port.
Re: I would like to start coding - manualy ?
Posted: Sat Feb 18, 2012 7:33 pm
by bigHUN
but I don't have the buzzer yet

so shall the DisplayLEDPWM disabled ? where?
if I remove the complete lines containing "buzzer" , error compiling