PAW_Sensor: This library control the PAW sensor. This library get sensor values from the PAW sensor, and send these values to PC through serial-communication. And you need to convert these values to delta h using some module on PC. I create sample python module for this library. If you want to get this module, please access below page, https://github.com/HiroakiMatsuda/PAW-Sensor The PAW Sensor is developed by RT. If you need to get information about this sensors, please access below page. http://www.rt-shop.jp/index.php?main_page=product_info&cPath=42&products_id=1303

Dependents:   PAW_Sensor_HelloWorld

paw.h

Committer:
matsu
Date:
2014-11-09
Revision:
5:eae61a2a67b0
Parent:
4:ea00b3135f6e
Child:
6:a58ad4e085af

File content as of revision 5:eae61a2a67b0:

#ifndef PAW_H
#define PAW_H

#include "mbed.h"

#define STATE_1 0
#define STATE_2 1
#define STATE_3 2
#define STATE_4 3

struct paw_value
{
    public: 
        short ch_1;
        short ch_2;
        short ch_3;
        short ch_4;
        short initial_photo_1;
        short initial_photo_2;
        
        paw_value()
            {
                ch_1 = 0;
                ch_2 = 0;
                ch_3 = 0;
                ch_4 = 0;
                initial_photo_1 = 0;
                initial_photo_2 = 0;
            }
};

/** PAW_Sensor Library
 *
 * Example:
 * @code
 * 
#include "mbed.h"
#include "paw.h"

Serial pc( USBTX, USBRX ); 
const unsigned long baudrate = 115200;

// paw( LED1, LED2, PHOTO1, PHOTO2 )
PAW paw( p8, p9, p16, p17 );
paw_value g_value;

PAW paw_2( p10, p11, p18, p19 );
paw_value g_value_2;

Ticker run;


void run_paw_sensor()
{
    if( paw.process_paw() == STATE_1 )
    {
        paw.print( &pc, 0 );   
    }
}

int main() 
{
    // Initializing Serial Communication
    pc.baud( baudrate );
    pc.format( 8, Serial::None, 1 );
    
    run.attach_us(&run_paw_sensor, 500);
    
    while(1);
}

 * @endcode
 */

class PAW {
    
    public:
    
        /** Create a PAW Sensor instance
         *
         * @param led_1 PAW Sensor's Pin 5
         * @param led_2 PAW Sensor's Pin 4
         * @param photo_1 PAW Sensor's Pin 3
         * @param photo_2 PAW Sensor's Pin 2
         */ 
        PAW( PinName led_1, PinName led_2, PinName photo_1, PinName photo_2 );
        
        /** Get values of PAW Sensor
         *
         * @return Return values of photosensor's voltage.
         */ 
        paw_value get_value();
        
        /** Processing of Paw sensor. This fucntion must be performed periodically.
         *
         * @return Return current processing-state.
         */ 
        unsigned char process_paw();
        
        /** Get current processing-state.
         *
         * @return Return current processing-state.
         */ 
        bool get_state();
        
        /** Send values of PAW Sensor through serial-communication.
         *
         * @param Reference to serial object.
         * @param ID of PAW Sensor. you can chose number from 0 to 255.
         */ 
        void print( Serial* pc, unsigned char id );
        
    protected:
        DigitalOut _led_1;
        DigitalOut _led_2;
        AnalogIn   _photo_1;
        AnalogIn   _photo_2;
        
        unsigned char _state;
        
        paw_value _value;
};

#endif /*** PAW_H ***/