Reverse flag for RA_ATOClass

Requests for new functions or software apps
Post Reply
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

Can we add a boolean to the RA_ATOClass that when set to true will return the opposite result with IsActive()?

This would have a few benefits for those troubleshooting who may have hooked up the switch upside down or for those that need the switch in that orientation.

For me this would help because I have two switches on one bracket and right now they are set perfectly. But for it to act properly in the SingleATO function I've current hacked the function to negate isActive.

Also, if I had to flip my low switch it may not reach where I need it to which would reduce my alert threshold which I don't want to do.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reverse flag for RA_ATOClass

Post by rimai »

Try this....
Remove C-clip from the float and flip the floating part.
Place the C-clip back.
Does that work for you?
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

That'll work... I didn't know our switches could do that. That'll be the route I go, I guess..

Would still be good for troubleshooting :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

How about an #define instead of changing code...

Code: Select all

class RA_ATOHighClass : public RA_ATOClass
{
public:
#ifdef REVERSE_HIGH_ATO
    inline bool IsActive() { return digitalRead(highATOPin); }
#else
    inline bool IsActive() { return !digitalRead(highATOPin); }
#endif
};
Why force a hardware change when we can do it in software :)
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reverse flag for RA_ATOClass

Post by rimai »

Send me a pull request :)
Don't forget to also add a function in ReefAngel.cpp for the auto feature selection to enable the define.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

What would a user do to enable the auto detection...

I'm thinking the user would just #define REVERSE_ATO_HIGH / LOW if they wanted it...it's not like there would be a new function to detect and add the feature. Kind of like the large fonts... If you want it you add the #define..

Also as far as the push request...I've already forgotten all the git commands...you can either refresh me in the commands, or the code is right above :) I'd be happy to write it out for ato low...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

class RA_ATOLowClass : public RA_ATOClass
{
public:
#ifdef REVERSE_ATO_LOW
inline bool IsActive() { return digitalRead(lowATOPin); }
#else
inline bool IsActive() { return !digitalRead(lowATOPin); }
#endif
};
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reverse flag for RA_ATOClass

Post by rimai »

There is no way to define it other than using the auto feature selection I created for the Arduino IDE.
This define needs to be inside ReefAngel_Features.h file to be seen and compiled.
That's why we have dummy functions that trigger the auto feature selection to add stuff to ReefAngel_Features.h file.
For example:
ReefAngel.AddDateTimeMenu();
This function when added to the INO code, triggers the #define DateTimeSetup
All features are added this way into the compiled code.
A list of keywords and features is inside the file /update/feature.txt
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

Not sure I follow why a #define in my ino wouldn't trigger...but at least I understand the concept of what you mean. I'll look at it tomorrow and provide the rest of the code ;) just not sure if I'll have time to learn git again :( I'll see what I can do.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

Just thinking this morning and realized i may still have to flip the float magnets around, but then remembered why I was doing it initially..

I'm planning on moving both floats to one port. Since essentially they do the same thing (shut off my return) most of the time...

I have two choices to do that. I can either wire the switches in paralelle and leave them in their current orientation which would require this code change. Or i could run them in series which would require me to flip the float and no code change.

Its either one switch breaks the circuit in series, or one switch makes the circuit in parallel. I think in the end i'll go with it in series and change the floats to match, but still debating in my head if there is a right way to go.

I still think the code change is relevant and could be useful for someone and who knows I may still want to use it someday.

I need to see how the skimmate switch defaults (supposedly on until full).
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reverse flag for RA_ATOClass

Post by lnevo »

Ok, yeah I see that the #define does not get into the scope from the INO, I guess it needs to be explicitly declared in that file through the include of ReefAngel_Features.h through Globals.h. Anyway, I'll see what I can do later about the push request and adding the functions and keywords. That part seems pretty straightforward..
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reverse flag for RA_ATOClass

Post by lnevo »

I can't get it to recognize the keywords :(

Added to feature.txt

Code: Select all

REVERSE_ATO_LOW,ReefAngel.ReverseATOLow
REVERSE_ATO_HIGH,ReefAngel.ReverseATOHigh
Added to keywords.txt

Code: Select all

ReverseATOLow KEYWORD2
ReverseATOHigh KEYWORD2
Added to ReefAngel.h

Code: Select all

        void inline ReverseATOLow() {};
        void inline ReverseATOHigh() {};
Added to debug sketch

Code: Select all

    ReefAngel.ReverseATOHigh();
But it's not picking up and adding to the ReefAngel_Features.h. Anything I'm missing?
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Reverse flag for RA_ATOClass

Post by jsclownfish »

Following along...I was wanting to do something similar http://forum.reefangel.com/viewtopic.php?f=20&t=1542. I have mine set up in a StandardATO format and it just seems more logical to me for the status to appear green if the water level is above the low float (closed position). It's become less important now with the water level expansion, but it would still be nice.

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

Re: Reverse flag for RA_ATOClass

Post by rimai »

You are missing a description on the feature.txt file

Code: Select all

REVERSE_ATO_LOW,ReefAngel.ReverseATOLow,Inverted Low Float Switch
REVERSE_ATO_HIGH,ReefAngel.ReverseATOHigh,Inverted High Float Switch
That's what it will display on the Arduino IDE when you compile the code as features found.
See if it works now.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

Got it. I'll try when i get home!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Reverse flag for RA_ATOClass

Post by lnevo »

The pull request is in...i need to fix it though! I left a bit of decode in that isActive wont be declared unless its defined...

Also the feature.txt is not in the repo...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reverse flag for RA_ATOClass

Post by lnevo »

Ok, pull request should be good now. There should be 3 commits.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Reverse flag for RA_ATOClass

Post by Sacohen »

I'm going to have 2 float switches in parallel basically set up to disable the ATO when the water level is to high ineither area.

Due to space issues I need to set up my ATO float switches in reverse.
Where the float is down and the wires are at the top.

Like this...

Image

If I do this I can use the following code to reverse the ATO Flag?

Code: Select all

class RA_ATOHighClass : public RA_ATOClass
{
public:
#ifdef REVERSE_HIGH_ATO
    inline bool IsActive() { return digitalRead(highATOPin); }
#else
    inline bool IsActive() { return !digitalRead(highATOPin); }
#endif
};
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Reverse flag for RA_ATOClass

Post by cosmith71 »

You can also pull the plastic clip off the bottom and flip the float upside down to change it.

Sent from my HTC One X using Tapatalk 4 Beta
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Reverse flag for RA_ATOClass

Post by Sacohen »

I saw that from Roberto after I posted the question and I did that. It seems a lot easier to me.

Thanks.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reverse flag for RA_ATOClass

Post by lnevo »

You could have gone either way. For some doing it in code is easier. I gave you the option :D
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Reverse flag for RA_ATOClass

Post by Sacohen »

Thanks. For me flipping the flota is easier now. I hope it will get to the point where coding is easier.
Post Reply