I spend some hours to write a first version in C-like, when someone from rcopensource list point me to this very interesting thread.
So, with this help, I rewrote the state machine of the UI in C++ language with virtual functions and new/del. It looks good, it should be easy to update and maintain. Here is an example of the code for one screen:
// --------------------------------------------- Servo Neutre
screenText OScrServoNeutre::text[LINE][LINE_LENGTH] =
{
/*01234567890123456789 */
"# Servo Neutre &&&&>\0",
"<==Servo \0",
" valeur = &&&& \0",
"< - + >\0"
};
OScreen * OScrServoNeutre::Action(e_command cmd)
{
switch (cmd)
{
case swUpLeft: return (scrServo);
case swUpRight:
servo = IProcessor::ServoSelect();
return (scrServoNeutre);
case swDownLeft:
neutre = IProcessor::ServoNeutreDecr();
return (scrServoNeutre);
case swDownRight:
neutre = IProcessor::ServoNeutreIncr() ;
return (scrServoNeutre);
default: return (scrError);
}
}
void OScrServoNeutre::PostAction()
{
SubVarText();
Display();
}