Locking ports
Locking ports
Inspired by binder's port locking within the android app, I wanted to code something tin the ino to make sure some ports (dosers) don't get overridden by mistake. The problem is I can reset th masks as a last step in the loop, but ShowInterface calls Refresh which gets e wifi data and also does the Relay.write. So there would always be a split second where the port was on. Any thoughts or suggestions?
Re: Locking ports
I think Roberto has a new override feature that will help address this issue, but I am not 100% positive.
Re: Locking ports
The new override is for PWM signals....
Maybe create an array of ports that are locked?
Just like what we have for FeedingModePorts, WaterChangePorts and others?
Maybe create an array of ports that are locked?
Just like what we have for FeedingModePorts, WaterChangePorts and others?
Roberto.
Re: Locking ports
Yeah, another array is fine. Just want to make sure the masks are cleared for anything that should not get masked
Re: Locking ports
Cool!!!
Send me another pull request.
Just to make sure that this is not going to increase size on the preloaded code, this feature needs to within a define too, just like you did the other one.
Send me another pull request.
Just to make sure that this is not going to increase size on the preloaded code, this feature needs to within a define too, just like you did the other one.
Roberto.
Locking ports
Uhm...not sure how to do the bitwise operations for that...
Re: Locking ports
Just use the FeedingPorts or WaterChangePorts as examples. It's pretty straight forward.lnevo wrote:Uhm...not sure how to do the bitwise operations for that...
Locking ports
Ok need a check on my binary math..I have everything in place just need to verify the following..
OverridePorts = B00110010
RelayMaskOff |= OverridePorts;
RelayMaskOn &= ~OverridePorts;
I think that should do it...
Thanks for the review
OverridePorts = B00110010
RelayMaskOff |= OverridePorts;
RelayMaskOn &= ~OverridePorts;
I think that should do it...
Thanks for the review
Locking ports
This was my test calculations..
/* put code here
override 00000011
|MaskOff 11110010
result 11110011
~override 11111100
&MaskOn 00011001
result 00011000
*/
/* put code here
override 00000011
|MaskOff 11110010
result 11110011
~override 11111100
&MaskOn 00011001
result 00011000
*/
Locking ports
Ok the code is ready to go, just need to try and compile it later...
Usage would look like this:
ReefAngel.AddPortOverrides();
ReefAngel.OverridePorts = B00011001; // Ports 1, 4, and 5
ReefAngel.OverridePortsE[0] = Port1bit | Port2Bit;
Now those ports will only work with On(); Off;
Any relay mask applied would be ignore (but still in place...)
Also if you set the variable within the loop() function, you could use a memory flag to enable/disable the lock by changing the variable
I'll work on the pull request soon and change my ino to use this
Usage would look like this:
ReefAngel.AddPortOverrides();
ReefAngel.OverridePorts = B00011001; // Ports 1, 4, and 5
ReefAngel.OverridePortsE[0] = Port1bit | Port2Bit;
Now those ports will only work with On(); Off;
Any relay mask applied would be ignore (but still in place...)
Also if you set the variable within the loop() function, you could use a memory flag to enable/disable the lock by changing the variable
I'll work on the pull request soon and change my ino to use this
Re: Locking ports
bumplnevo wrote:Ok need a check on my binary math..I have everything in place just need to verify the following..
OverridePorts = B00110010
RelayMaskOff |= OverridePorts;
RelayMaskOn &= ~OverridePorts;
I think that should do it...
Thanks for the review
Re: Locking ports
I see you used "OverridePorts" as the variable name. This to me sounds like the ports that you can override. I'm thinking this is the opposite of what you were intending. The ports you specify are the ones that are Locked and not able to be overridden, correct? Or do I have this backwards?
Re: Locking ports
The principle was that if you Override the ports they can not be masked... the override will block the relaymask.
The idea was to override the user input and only allow the programming of the ports via on/off.
Sorry for the confusing naming... the pull request is already put in and the whole process confuses the hell out of me. Feel free to change the names, functions, whatever.
The idea was to override the user input and only allow the programming of the ports via on/off.
Sorry for the confusing naming... the pull request is already put in and the whole process confuses the hell out of me. Feel free to change the names, functions, whatever.
Re: Locking ports
I "think" it looks correct but Roberto should be able to confirm. I always get confused when looking at the relayon/off masks for some reason.lnevo wrote:How about the math?
Re: Locking ports
Nope I can't load my code until I get some additional hardware because I've mode a hundred million changes But I put the changes right before the Relay.Write and it all compiles. I'm pretty confident
Re: Locking ports
Tested. Working Sending you a diff patch because me and git have issues!
Re: Locking ports
<aside>You're not alone... using git is like having my teeth pulled</aside>
Current setup:
60g 24" custom cube (fish and softies right now)
AI Sol Blue, Ecotech MP-10wES
Coralife skimmer
100% customer controller, transitioning to ReefAngel
60g 24" custom cube (fish and softies right now)
AI Sol Blue, Ecotech MP-10wES
Coralife skimmer
100% customer controller, transitioning to ReefAngel