Calling interfaces from within interfaces

If you have a simple question and just want an answer.
SpacedCowboy
Experienced Member
Posts: 67
Joined: Fri Aug 24, 2012 9:37 pm

Calling interfaces from within interfaces

Post by SpacedCowboy »

So,  I doubt what I want to do is possible, but maybe someone's come across the issue I'm talking about and has a neat way of solving it...

Basically I have an interface that controls a peripheral. There's a whole load of low-level operations that are available to call via the interface, but I'd like to build a little on top of that, and provide some 'macro' operations that call operations X, Y, Z from within the same interface. I'd also like to have an interface function that periodically calls X,Y,Z from within the same interface... Something like:

select

{

case X():



break;

 

case Y():



break;

 

case Z():



break;

 

case XYZ():

self.X();

self.Y();

self.Z();

break;

 

case t when timerafter(time) :> void:



self.XYZ();

break;

}

 
Is the best way to put the code for X(),Y() and Z() in C functions, and then call them individually from XYZ(). What I'm trying to avoid is code duplication. Or is there a better way ?
 
Cheers
   Simon
 
 

 

 

robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post by robertxmos »

The lowering of select statements is non-trivial.
The correct solution is to use function calls.