Olivier Smeesters / Mbed 2 deprecated DtmfKit

Dependencies:   mbed ExtTextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers system_states.hpp Source File

system_states.hpp

00001 #ifndef _SYSTEM_STATES_HPP
00002 #define _SYSTEM_STATES_HPP
00003 
00004 #include "state.hpp"
00005 #include "system.hpp" // for System::StateId
00006 
00007 #include "mbed.h" // for Timeout
00008 
00009 class StateBase : public State {
00010 protected:
00011     StateBase(System::StateId id, System *system);
00012     virtual ~StateBase();
00013     
00014 public:
00015     System * system() const { return this->system_; }
00016     
00017 private:
00018     System *system_;
00019 };
00020 
00021 class InitState : public StateBase {
00022 public:
00023     InitState(System *system) : StateBase(System::Init, system) { }
00024     
00025     virtual void enterState();
00026     virtual void exitState();
00027 };
00028 
00029 class InteractiveState : public StateBase {
00030 public:
00031     InteractiveState(System::StateId id, System *system) : StateBase(id, system) { }
00032 
00033 protected:
00034     void updateText() const;
00035     void updateCursor() const;
00036 };
00037 
00038 class EditState : public InteractiveState {
00039 public:
00040     EditState(System *system) : InteractiveState(System::Edit, system) { }
00041 
00042     virtual void enterState();
00043 
00044     virtual void handleKey(char key);
00045 
00046 private:
00047     void handleSymbol(char ch) const;
00048 };
00049 
00050 class CommandState : public InteractiveState {
00051 public:
00052     CommandState(System *system) : InteractiveState(System::Command, system) { }
00053 
00054     virtual void enterState();
00055     virtual void exitState();
00056 
00057     virtual void handleKey(char key);
00058 
00059 private:
00060     void handleLeft() const;
00061     void handleRight() const;
00062     void handleHome() const;
00063     void handleEnd() const;
00064     void handleDelete() const;
00065     void handleBackSpace() const;
00066     void handleClear() const;
00067     void handleSend() const;
00068     void handleHelp();
00069     
00070     void showNextStatusMsg();
00071     void showStatusMsg(int index);
00072     
00073     int statusMsgIndex;
00074     Timeout statusMsgTimeout;
00075 };
00076 
00077 class SendingState : public StateBase {
00078 public:
00079     SendingState(System *system) : StateBase(System::Sending, system) { }
00080 
00081     virtual void enterState();
00082 
00083     virtual void handleKey(char key);
00084     
00085 private:
00086     void playSymbol();
00087     void endSymbol();
00088     void nextSymbol();
00089 
00090     static float ToneTime;
00091     static float PauseTime;
00092 
00093     Timeout timer;    
00094 };
00095 
00096 #endif