Create this program

Dependencies:   mbed HCSR04 HMC6352 PID TextLCD

infrared.h

Committer:
KoiShin_Sakana
Date:
2015-08-07
Revision:
3:901d18b901b4
Parent:
2:a8bbf677e774
Child:
5:e07e380ddb93

File content as of revision 3:901d18b901b4:

/**
 * @file   : infrared.h (0.1)
 * @brief  : examine point the ball exist
 * @author : Shinnosuke KOIKE
 * @date   : 2015/08/04
 */
 
#ifndef INFRARED_H
#define INFRARED_H

#include "mbed.h"

class Infrared {
public:
    Infrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
        PinName back, PinName backRight, PinName right, PinName frontRight);
    char findBallPos(void);

private:
    BusIn infraredData;
};

class AnalogInfrared {
public:
    AnalogInfrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
        PinName back, PinName backRight, PinName right, PinName frontRight);
    void findBallPosAndDist(char data[]);

private:
    AnalogIn analogFront;
    AnalogIn analogFrontLeft;
    AnalogIn analogLeft;
    AnalogIn analogBackLeft;
    AnalogIn analogBack;
    AnalogIn analogBackRight;
    AnalogIn analogRight;
    AnalogIn analogFrontRight;
};

Infrared::Infrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
        PinName back, PinName backRight, PinName right, PinName frontRight):
    infraredData(front, frontLeft, left, backLeft, back, backRight, right, frontRight) {
}

char Infrared::findBallPos(void) {
    char data = infraredData;
    return data;
}

AnalogInfrared::AnalogInfrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
        PinName back, PinName backRight, PinName right, PinName frontRight):
    analogFront(front), analogFrontLeft(frontLeft), analogLeft(left), analogBackLeft(backLeft),
    analogBack(back), analogBackRight(backRight), analogRight(right), analogFrontRight(frontRight) {
}

void AnalogInfrared::findBallPosAndDist(char data[]) {
    data[0] = analogFront;
    data[1] = analogFrontLeft;
    data[2] = analogLeft;
    data[3] = analogBackLeft;
    data[4] = analogBack;
    data[5] = analogBackRight;
    data[6] = analogRight;
    data[7] = analogFrontRight;
}

#endif