Version 1.0 - Library for Parallax OFN module 27903
Fork of OFN by
Import library
Public Member Functions |
|
OFN (PinName sda, PinName scl) | |
Constructor.
|
|
bool | checkMotion () |
Function to check if motion has been detected Checks the 7th bit of MOTION register and Returns true if motion detected else returns false.
|
|
int | readX () |
Function to get displacement in the X direction Returns an integer value.
|
|
int | readY () |
Function to get displacement in the X direction Returns an integer value.
|
|
int | readOrientation () |
Function to read the Orientation register Returns an integer value 1 - default orientation 0 - rotated by 90 degrees.
|
ofn.h
- Committer:
- nkadam
- Date:
- 2015-03-09
- Revision:
- 1:ba28114bd6bb
- Parent:
- 0:c559e09a7b5d
- Child:
- 2:757ad351c8c6
File content as of revision 1:ba28114bd6bb:
#ifndef OFN_H #define OFN_H #include "mbed.h" #define DEVICE_ADDR 0x33 #define PRODUCT_ID_ADDR 0x00 #define REVISION_ID_ADDR 0x01 #define SOFT_RESET 0x3A #define OFN_ORIENTATION_CTRL 0x77 #define ORIENT_DEFAULT 1 #define ORIENT_ROTATED_CLKWISE 0 class OFN { public: /** * Constructor. * * @param sda mbed pin to use for SDA line of I2C interface. * @param scl mbed pin to use for SCL line of I2C interface. */ OFN(PinName sda, PinName scl); /** * * Function to check if motion has been detected * Checks the 7th bit of MOTION register and * Returns true if motion detected else returns false */ bool checkMotion(); /** * * Function to get displacement in the X direction * Returns an integer value */ int readX(); /** * * Function to get displacement in the X direction * Returns an integer value */ int readY(); /** * * Function to read the Orientation register * Returns an integer value * 1 - default orientation * 0 - rotated by 90 degrees */ int readOrientation(); private: I2C i2c; char MOTREG_ADDR; // To contain address of Motion Register char DELTA_X_ADDR; // To contain address of Delta_X Register char DELTA_Y_ADDR; // To contain address of Delta_Y Register int MotReg; // To contain value of Motion Register bool moved; // To contain value of state of Motion char raw_delta_X[1]; // To contain raw sensor reading of Delta_X int delta_X; // To contain correct reading of Delta_X char raw_delta_Y[1]; // To contain raw sensor reading of Delta_Y int delta_Y; // To contain correct reading of Delta_Y }; #endif /* OFN_H */