ロボカップジュニアサッカー IRM2121を用いた専用パルスボールを検知するためのライブラリ

Dependents:   BallCheck_IRM2121_InterrputInAdd CatPot_SensorRight

Pingのライブラリを参考にしました。 RoboCupJuniorSoccerにおけるボール検知をまとめて行うために作成したライブラリ。

距離に応じて微妙に値が変わるようになりました。 まともに使えます。

なお、このライブラリには、interruptinの機能を拡張するためのライブラリが含まれています。 そのため、必要なときだけピン変化割り込みに入ることが可能となっています。

値に応じて関数ポインタとかすれば距離によって値かわるようにできるかも if文で十分かもしれません

IRM2121.h

Committer:
ryuna
Date:
2015-01-05
Revision:
2:40101fcb6d44
Parent:
1:b25c8ac20d5b
Child:
3:711dde7b4c12

File content as of revision 2:40101fcb6d44:


    
 #ifndef MBED_IRM_H
 #define MBED_IRM_H

#include "mbed.h"
#include "interruptin_mod.h"
/** IRM2121  class, based on an InterruptIn pin, and a timer
 *  use RoboCup Junior Soccer to find PULSE BALL.
 
 
 * Example:
 * @code
 * // Set interrupt and read sensor.
 * #include "mbed.h"
 * #include "IRM2121.h"
 * IRM2121 IR(p21);
 * 
 * int main() {
 *     int length;
 
 *     while(1) {
 *  
 *        IR.Set();    
 *        wait_ms(20); //check _Busy 1 &_Valid 0 ....config just wait time.
 *        length = IR.Read();
 *     }
 * }
 * @endcode
 */
class IRM2121 {
  public:
    /** Create a IRM2121 object connected to the specified InterruptIn pin
    *
    * @param IRM_PIN InterruptIn pin to connect to 
    */
    IRM2121(PinName IRM_PIN);
    
    
     /** Set a IRM2121 Interrupt Pin 
      *
      * @param none
      */
    void Set(void);
    
    /** Read the result 
      *
      * @param none
      */
    int Read(void);
    
    /**
      * Check two flags( _Valid, _Busy )
      *
      * @param none
      */
    void ReturnVB(bool *valid, bool *busy);
    
    
  protected:
    
    interruptin_mod    _event;
    Timer              _timer;

    bool _Flag;
    bool _Valid;
    bool _Busy;
    unsigned int _Time;
      
    void _Start(void);
    void _Stop (void);
    
  };
  
  #endif