Toyoshi Yoshimoto / GP2Y0E03
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GP2Y0E03.h Source File

GP2Y0E03.h

00001 #ifndef GP2Y0E03_H
00002 #define GP2Y0E03_H
00003 
00004 #include <mbed.h>
00005 #include <I2C.h>
00006 
00007 #define DMS_ADDR (0x80)
00008 #define DMS_DIST (0x5E)
00009 #define DMS_RSTADR (0xEE)
00010 #define DMS_RSTCMD (0x06)
00011 #define DMS_128 (0x1)
00012 #define DMS_64 (0x2)
00013 #define DMS_SCALE (0x35)
00014 
00015 class GP2Y0E03 {
00016 private:
00017     I2C* i2cRef;
00018     char wdata[2];
00019     char rdata[2];
00020     int status;
00021 
00022 public:
00023     GP2Y0E03(I2C* ch);
00024     int writeCommand(char regadr, char dat);
00025     int readData(char regadr, char* dat);
00026     int readDistance(int* dist);
00027 };
00028 #endif // GP2Y0E03_H