Hello,
I have a volatile variable:
volatile boolean isPowerSupplyDown = false;
I want this variable to be a parameter in a function.
The kind of this is to not made the temperature acquisition if the variable isPowerSupplyDown goes up.
So the question is:
Is that needed to pass a pointer to the variable or the variable itself ?
That's a part of my library:
MIN_MAX BatteryBox::getMiniMaxi(volatile boolean *isPowerDown){
for (byte i = 0; i < nbSensors; i++){
if (*isPowerDown)
break;
.............
}
I just want to exit from the loop if the variable isPowerDown goes up.
The volatile keyword tells the compile that the value can change outside of the function that is executing. An input argument can NEVER change. What was passed by value to the function can not change.
What you are trying to do does not make sense. As rob says, a global (volatile) variable is the solution.
So even if the varialbe is global, it can't be see in the library... ... Yes, it can. Example:
I suspect that what OP meant was that if the variable is defined in the sketch, it can't be seen in the library. Obviously that isn't true, either. OP needs to learn about compilation units and the extern keyword.