Changed hts221 into Class.

Dependents:   WeatherSensor-Joe PAG-CourseWork-NicksEdits SOFT253_Assignment SOFT253_Assignment_V2 ... more

Fork of hts221 by Kyle Rodgers

Revision:
1:da79e74eadd1
Parent:
0:030da9425166
Child:
2:6d7166d49741
--- a/hts221.h	Fri Jan 30 08:49:01 2015 +0000
+++ b/hts221.h	Fri Jul 24 15:21:28 2015 +0000
@@ -81,19 +81,39 @@
 #define T_DA_On                  0x01 // Temperature data avialable, set to 1 whenever a new humidity sample is available.
 #define T_DA_Off                 0x00
  
-bool hts221_init(void);
-
-void hts221_register_write(uint8_t register_address, const uint8_t value);
-
-void hts221_register_read(char register_address, char *destination, uint8_t number_of_bytes);
+class HTS221{
+public:
+    HTS221 (PinName sda, PinName scl);
+    void calib(void);
+    bool init(void);
+    void ReadTempHumi( float *pTemp , float *pHumi);
+    
+private:
+    void register_write(uint8_t register_address, const uint8_t value);
+    void register_read(char register_address, char *destination, uint8_t number_of_bytes);
+    bool verify_product_id(void);
+    float linear_interpolation(int16_t x0, float y0, int16_t x1, float y1, float mes);
+    
+    I2C _i2c;
+    
+    static const char expected_who_am_i = 0xBCU; //!< Expected value to get from WHO_AM_I register.
 
-bool hts221_verify_product_id(void);
-
-void HTS221_Calib(void);
+    uint8_t H0_rH_x2; 
+    uint8_t H1_rH_x2;
+    uint16_t T0_degC_x8;
+    uint16_t T1_degC_x8;
 
-void HTS221_ReadTempHumi( float *pTemp , float *pHumi);
+    int16_t H0_T0_OUT;
+    int16_t H1_T0_OUT;
+    int16_t T0_OUT;
+    int16_t T1_OUT;
 
-float linear_interpolation(int16_t x0, float y0, int16_t x1, float y1, float mes);
+    float T0_DegC_cal;
+    float T1_DegC_cal;
+    float H0_RH_cal;
+    float H1_RH_cal;
+
+};
 
 #endif /* HTS221_H */