#ifndef USS_SRF02_H_
#define USS_SRF02_H_

class USS_SRF02
{
public:
    //gpio pins where the sonar is connected
    static constexpr int SRF02_SDA = 8; //i2c data pin ;
    static constexpr int SRF02_SCL = 9; //i2c clock pin ;

    // addresses of the sonars, the number is also as a sticker on the devices themselves
    static constexpr int DEVICE_ADDRESS1 = 0x74;
    static constexpr int DEVICE_ADDRESS2 = 0x76;
    static constexpr int DEVICE_ADDRESS3 = 0x77;

    //path to i2c file
    static constexpr char DEVICE[] = "/dev/i2c-1";

    static constexpr int COMMAND_REGISTER = 0x00;
    static constexpr int RESULT_HIGH_BYTE = 0x02;
    static constexpr int RESULT_LOW_BYTE = 0x03;
    static constexpr int RANGING_MODE_CM = 0x51;

    static constexpr int DELAY = 70; //70 ms for ranging to finish

    explicit USS_SRF02(int devId);

    int getDistance();

private:
    int fd;
};


#endif /* USS_SRF02_H_ */