Proposal for new feature

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

Proposal for new feature

Post by rimai »

Hey Guys,

I'm thinking that since we have tons of memory to play with on the RA+, it would be cool if we could assign functions on the fly too :)
Something like saving settings into internal memory, except it would be for the functions assigned to a specific ports.
I'd love to hear ideas on how to accomplish this.
The ultimate goal is to be able to load a master code on your RA and easily assign basic functions to each port.
When I say basic functions, I mean the functions the the wizard offers for each port.
My idea would be to have a internal memory location for each of the 72 ports and store a function "code" in it that the master code would read and apply the correct function.
For example:
For demonstration purposes, I'll use this function table:
0- Always Off
1- Always On
2- StandardLights
3- ActinicLights
4- Moonlights
5- Heater
6- Chiller
Let's say memory location 96 would be for Port1 and we wanted it to be a heater port.
Save 2 into memory location 96 and the controller would know you wanted that port to be heater.
Thoughts and comments?
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Proposal for new feature

Post by binder »

I like the idea of it. It would greatly simplify how the controller is programmed and you could just load a basic "code template" that would be your framework / shell running. Then you can change the functions on the fly as needed. It would be great for the standard / generic and most people's controllers but would be difficult for those who customized a lot. :)

Based on what you proposed, I am going to start thinking about this one. I have a trip coming up and will have some downtime on the plane and such. So I'm gonna start working up some ideas for you. I've already got something starting in my head but I need to process it and work it out.

The short of what I'm thinking of doing is this:
Have a generic function added to the library that would take a port...say, ReefAngel.Assign(Port1);
Inside that function Assign, it does the following:
  • Read the memory location assigned to the port (this would be a lookup table or something)
  • Perform a "switch" on the value and call the appropriate function
Here's an example of the code:

Code: Select all

// uint8_t is the same as byte
void ReefAngel::Assign(uint8_t port) {
  // use 95 as the offset since port1 is 1 and 1+95 = 96
  uint8_t loc = InternalMemory.read(port + 95);
  switch ( loc ) {
    default:   // default value that is unrecognized is always off
    case 0:
      Relay.Off(port);
      break;
    case 1:
      Relay.On(port);
      break;
    case 2:
      // use the standard lights simple call
      StandardLights(port);
      break;
    case 3:
      ActinicLights(port);
      break;
    case 4:
      Moonlights(port);
      break;
    case 5:
      StandardHeater(port);
      break;
    case 6:
      StandardFan(port);
      break;
  }
}
Then you would just add in all the functions that we could call. I know some of the stuff I posted are not correct (Moonlights, ActinicLights, etc). Also, the lookup would need to be modified because we would be skipping offsets 9 & 10 between the main relay and 1st expansion box. So there will be 2 offsets that get skipped. That would need to be improved.
This function would expand nicely just by adding on more "cases" and we could even create a DEFINE statement for each case, such as #define 0 ALWAYS_OFF, #define 1 ALWAYS_ON, etc to make it even more readable in the libraries. It would just add 1 more level of the function calls. You could also bypass using the short function calls here and just call the functions that the short functions call. So instead of using StandardLights(port), you would use StandardLights(port, onhr, onmin, offhr, offmin). I'm not sure if this would save anything or not but just a thought.

Anyways, I'll think on this more and see if I can come up with a better solution but this is probably as simple as it can be. :ugeek:
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Proposal for new feature

Post by rimai »

That sounds like what I had in mind :)
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Proposal for new feature

Post by binder »

Good. At least we are on the same page. There may be another way to handle it but this is what jumps out as the simplest way. I'll keep thinking on it too. :)
Post Reply