Hey everyone,
Recently we have added a new feature to the dev branch. Further simplified support for the new position sensors.
Instead of the writing the new sensor class as described in docs, all you need to do now is to implement one function in you Arduino sketch.
The process is very simple, in your arduino sketch you define the functions that read your sensor (and intialise it optionally), for example:
float readMySensor(){
// read my sensor
// return the angle value in radians in between 0 and 2PI
return ...;
}
void initMySensor(){
// do the init
}
And then just provide them to the GenericSensor
class constructor.
// Provide the callbacks in the constructor
GenericSensor sensor = GenericSensor(readMySensor, initMySensor);
or if you prefer:
// empty constructor
GenericSensor sensor = GenericSensor();
void setup(){
...
// assign the callbacks directly
sensor.readCallback = readMySensor;
sensor.initCallback = initMySensor;
sensor.init();
....
}
This way of implementing the new sensors will, we hope, enable you guys to more efficiently and easily integrate your own codes into the simplefoc and use other open-source components that inside simplefoc.
You can find an example code in the library examples: