Please have a look at the following piece of code. I'm trying to get my head around how this works, but I'm not very successful at that.
The biggest question mark for me is that it looks to me like a function (paramAction) is defined twice, but called with a different number of parameters at different places.
Looks like some recursive calling of functions is going on here, but I'm not sure...
Can someone please enlighten me ?
template<typename T> void paramAction(uint8_t action, volatile T& value, uint8_t menuid,
const char* label, void (*display)(const char* enumArray[], int32_t value, int32_t _min),
const char* enumArray[], int32_t _min, int32_t _max, void (*trigger)(int) ) {
switch(action) {
case UPDATE:
case UPDATE_MENU: {
// do stuff
break;
}
default:
actionCommon(action, (uint16_t *)&value, sizeof(value)/2);
break;
}
}
void paramAction(uint8_t action, uint8_t id = ALL) {
if ((action == SAVE) || (action == LOAD)) {
// do other stuff
}
switch (id) {
case ALL: for(id = 1; id != N_ALL_PARAMS+1; id++) paramAction(action, id);
case VERS: paramAction(action,eeprom_version,0,NULL,displayNum,NULL,0,0,triggerNoop);break;
}
}
void setup() {
paramAction(LOAD,VERS);
// do something
paramAction(LOAD);
}