Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Roomba.h
- Revision:
- 2:144ca2f5d850
- Parent:
- 0:32eb0835b5a3
diff -r aed433d882c9 -r 144ca2f5d850 Roomba.h
--- a/Roomba.h	Wed Jan 21 16:20:12 2015 +0000
+++ b/Roomba.h	Sat Feb 14 11:32:14 2015 +0000
@@ -1,69 +1,39 @@
 #include "mbed.h"
-#include "EventArg.h"
+//#include "Data.h"
 
 #ifndef __ROOMBA_H_INCLUDED__
 #define __ROOMBA_H_INCLUDED__
 
-/**
- * ルンバ制御クラスのインターフェース
- * 下記メソッドを継承先が実装すること
- */
-class IRoomba {
-    public:
-        //virtual ~IRoomba(){};//なぜ宣言を書いたのか、コメントにした理由とともに忘れた
-        virtual bool send(EventArg e) = 0;
-        virtual void notify(bool result) = 0;
-};
 
 /**
  * ルンバ制御クラス
  */
-class Roomba : public IRoomba {
+class Roomba {
     public:
-        virtual bool send(EventArg e);
-        virtual void notify(bool result);
-        
-        //Mode.Fullのような書き方(またはそれに近い書き方がしたい)
-        //調べていたら、Roomba::Mode::Fullのように書くことできそうだとわかったので試したが、上手く行かない
-        //上手く行かない理由の考察はできていない
-        //http://stackoverflow.com/questions/8213696/accessing-enum-values-defined-in-a-struct
-        //struct Mode
-        //{
-            enum Mode
+        struct Mode
+        {
+            enum EMode
             {
                 Off,
-                Passive,//??
+                Passive,
                 Safe,
                 Full
             };
-        //};
-    
-    private:
-        Serial _s;
-        Roomba::Mode _mode;// = Roomba::Mode.Off;
-        //EventArg::EventArg _e;
-        DigitalOut _led;//Notify()で使用するLED:ルンバ状態を通知する
-        //void (Roomba::*serialReceiveCallback)(); //= notify;
-        void (Roomba::*mp)();//member function pointer
-        
-        char command[10];
+        };
+
+        Roomba(PinName tx, PinName rx);
         
-        int count;    //タイムアウト検出カウンタ(カウント値が一定数を超えればタイムアウト)
-        bool timedOut;//タイムアウト検出フラグ
-        
-    public:
-        Roomba(PinName tx, PinName rx, PinName led);
-        
-        void attachPeriodicCallback();
-        virtual void periodicCallback(EventArg e);
-        void attachSerialReceiveCallback();
-        void serialReceiveCallback();
-        
-        bool mode(Roomba::Mode m);
+        bool mode(Roomba::Mode::EMode m);
         //Mode getMode();
         bool start();
         bool drive(int rightWheelVelocity, int leftWheelVelocity);
         bool battery(int* batteryCapacity);
+
+    protected:
+        Serial _s;
+    
+    private:
+        Roomba::Mode::EMode _mode;
 };
 
 #endif
\ No newline at end of file