das mit den functionpointern geht definitiv, ich verwend hier sowas:
Code:struct behaviour { uint8_t(*run)(uint8_t); // function for that behaviour uint8_t active; } behaviours[] = { { behaviour_escape_bumpers, 1 }, // escape based on bumpers ... }; uint8_t behaviour_escape_bumpers(uint8_t inactive) { ... } void main(void) { ... for(struct behaviour *bp = behaviours; bp->run; bp++) { if(bp->active && bp->run(active)) active = 1; } } ... }
Lesezeichen