26 novembre 2008

C++ & UI state machine

Still progressing slowly on the software, and had some problems with the development toolchain Avr-gcc/g++ as it does not support the full c++ syntax, especially new/del/ and virtual functions.
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()

Aucun commentaire: