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.
main.cpp
- Committer:
- YosukeK
- Date:
- 2015-01-21
- Revision:
- 1:aed433d882c9
- Parent:
- 0:32eb0835b5a3
- Child:
- 2:144ca2f5d850
File content as of revision 1:aed433d882c9:
#include "mbed.h"
#include "Roomba.h"
#include "EventArg.h"
/*
 * ルンバ向けイベント引数クラス
 */
//class RoombaEventArg : public EventArg
//{
//    typedef EventArg base;
//    
//    public:
//        //RoombaEventArg(int leftWheetVelocity, int rightWheelVelocity} {
//            
//        //}        
//    
//        RoombaEventArg() {
//            leftWheetVelocity  = 0;
//            rightWheelVelocity = 0;
//        };
//    
//    public:
//        int leftWheetVelocity;
//        int rightWheelVelocity;
//};
//
///*
// * ルンバ制御クラスの実装クラス
// */
//class ImplRoomba : protected Roomba {
//    typedef Roomba base;
//    
//    private:
//        DigitalOut _led;//Notify()で使用するLED:ルンバ状態を通知する
//    
//    public:
//        ImplRoomba(PinName tx, PinName rx, PinName led) :Roomba(tx, rx), _led(led){
//            _led = 0;
//            Roomba::attachSerialReceiveCallback();
//        }
//        
//        /*
//         * @bref 送信メソッド
//         */
//        virtual bool ImplRoomba::send(RoombaEventArg e) {
//            _led != _led;
//            base::start();
//            base::mode(Roomba::Full);//(Roomba::Mode::Full); If write struct Mode and no name enum, Compiler say no sutable constructor conver to enum...
//            base::drive(e.leftWheetVelocity, e.rightWheelVelocity);
//            
//            return true;
//        }
//        
//        /*
//         * @bref 状態通知メソッド
//         */        
//        virtual void ImplRoomba::notify(bool result) {
//            if (result == false) {
//                _led = 1;
//            } else {
//                _led = 0;    
//            }
//        }
//        
//        /*
//         * @bref 周期タイマコールバック
//         */
//        virtual void ImplRoomba::periodicCallback(RoombaEventArg e) {
//            base::periodicCallback(e);
//        }
//};
Ticker ticker;
Serial pc(SERIAL_TX, SERIAL_RX);
//匿名クラスでオーバーライドした書き方がしたい
//Roomba
Roomba roomba(SERIAL_TX, SERIAL_RX, LED1);/* = new Roomba: IRoomba {
    bool Roomba::send() {
        //start, mode, drive
        return true;
    }
    void Roomba::notify() {}
};*/
//Ticker no kawari.
int main() {
    //ticker.attach(roomba.periodicCallback, 0.1);
    
    //TODO:Serial receive message.
    int leftWheelVelocity = 500;
    int rightWheelVelocity = -500;
    EventArg e;//(leftWheelVelocity, rightWheelVelocity);
    e.leftWheetVelocity = leftWheelVelocity;
    e.rightWheelVelocity = rightWheelVelocity;
    
    while (true) {    
        roomba.periodicCallback(e);
        wait_ms(100);
    }
}