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.
Roomba.h
- Committer:
- YosukeK
- Date:
- 2015-01-20
- Revision:
- 0:32eb0835b5a3
- Child:
- 2:144ca2f5d850
File content as of revision 0:32eb0835b5a3:
#include "mbed.h"
#include "EventArg.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 {
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
{
Off,
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];
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);
//Mode getMode();
bool start();
bool drive(int rightWheelVelocity, int leftWheelVelocity);
bool battery(int* batteryCapacity);
};
#endif