INSAT Mini Project
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_6180XA1 by
Diff: x_nucleo_6180xa1.h
- Revision:
- 48:e799ad44dab7
- Parent:
- 42:692c6223dc24
- Child:
- 49:f0dd44dd59c5
--- a/x_nucleo_6180xa1.h Mon May 23 09:59:39 2016 +0000 +++ b/x_nucleo_6180xa1.h Tue Jun 07 14:56:36 2016 +0200 @@ -57,11 +57,11 @@ /* Classes--------------------------------------------------------------------*/ /* Classes -------------------------------------------------------------------*/ -/** Class representing the X-NUCLEO-VL6180XA1 expansion board +/** Class representing the X-NUCLEO-VL6180XA1 expansion board singleton obj */ class X_NUCLEO_6180XA1 { - public: +private: /** Constructor 1 * @param[in] &i2c device I2C to be used for communication */ @@ -124,7 +124,7 @@ if(sensor_top!=NULL) { delete sensor_top; - sensor_top=NULL; + sensor_top=NULL; } if(gpio0_bottom!=NULL) { @@ -134,7 +134,7 @@ if(sensor_bottom!=NULL) { delete sensor_bottom; - sensor_bottom=NULL; + sensor_bottom=NULL; } if(gpio0_left!=NULL) { @@ -144,7 +144,7 @@ if(sensor_left!=NULL) { delete sensor_left; - sensor_left=NULL; + sensor_left=NULL; } if(gpio0_right!=NULL) { @@ -154,26 +154,41 @@ if(sensor_right!=NULL) { delete sensor_right; - sensor_right=NULL; + sensor_right=NULL; } - delete stmpe1600; - stmpe1600 = NULL; - delete Switch; - Switch = NULL; - delete display; - display = NULL; + delete stmpe1600; + stmpe1600 = NULL; + delete Switch; + Switch = NULL; + delete display; + display = NULL; _instance=NULL; } - /** - * @brief Creates a singleton object instance + /** + * @brief Override default copy constructor as empty + * @param[in] &X_NUCLEO_6180XA1 singleton object reference + * @return + */ + X_NUCLEO_6180XA1() {}; + + /** + * @brief Override default assignement operator to avoid multiple singletons + * @param[in] &X_NUCLEO_6180XA1 singleton object reference + * @return + */ + void operator = (const X_NUCLEO_6180XA1&); + +public: + /** + * @brief Creates a singleton object instance * @param[in] &i2c device I2C to be used for communication - * @return Pointer to the object instance - */ + * @return Pointer to the object instance + */ static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c); - /** - * @brief Creates a singleton object instance + /** + * @brief Creates a singleton object instance * @param[in] &i2c device I2C to be used for communication * @param[in] PinName gpio1_top the pin connected to top sensor INT * @param[in] PinName gpio1_bottem the pin connected to bottom sensor INT @@ -184,6 +199,8 @@ static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c, PinName gpio1_top, PinName gpio1_bottom, PinName gpio1_left, PinName gpio1_right); + + /** * @brief Initialize the board and sensors with deft values * @return 0 on success @@ -203,15 +220,15 @@ VL6180X *sensor_bottom; VL6180X *sensor_left; VL6180X *sensor_right; - STMPE1600 * stmpe1600; - SWITCH * Switch; + STMPE1600 * stmpe1600; + SWITCH * Switch; + Display *display; + +private: STMPE1600DigiOut *gpio0_top; STMPE1600DigiOut *gpio0_bottom; STMPE1600DigiOut *gpio0_left; STMPE1600DigiOut *gpio0_right; - Display *display; - - private: static X_NUCLEO_6180XA1 *_instance; };