I'll try to describe this the best I can...
Let's say my sketch has a constant "foo=100" and I have a library called "libby" with a function called "funk". Inside of funk there is a variable "boo" that will *always* be foo/2. My question is, what is the approach that would allow the computation to happen only once even though funk is called many times in the sketch.
For example, is this a valid approach?
Sketch:
#include <libby.h>
const byte foo=100;
libbyClass libbyObject;
setup(){}
loop(){
libbyObject.funk(foo);
}
libby.cpp:
#include "libby.h"
libbyClass::libbyClass(){}
void libbyClass::funk(byte var){
static byte boo=var/2;
}
libby.h:
#ifndef libby_H
#define libby_H
#include "Arduino.h"
class libbyClass{
public:
libbyClass();
void funk(byte var);
};
# endif
Thanks!