#ifndef _BIWAK_SI705X_H_
#define _BIWAK_SI705X_H_


#include <biwak/gpio.hpp>
#include <biwak/i2c_slave.h>
#include <biwak/input.hpp>


#define SI705X_FLOAT
#undef SI705X_FLOAT

class CSi705x: public CI2cSlave
{
private:
   static constexpr uint16_t REG_ID1            = 0xFA0F;
   static constexpr uint16_t REG_ID2            = 0xFCC9;
   static constexpr uint16_t REG_MEASURE_HOLD   = 0xE3;
   static constexpr uint16_t REG_MEASURE_NOHOLD = 0xF3;

public:
   CSi705x(CI2c &i2c, int addr = 0x40);
   bool probe();
   uint16_t readRaw();
   #if defined ( SI705X_FLOAT )
      float convertTemperature(uint32_t raw) const;
      float getTemperature();
   #else
      int convertTemperature(uint32_t raw) const;
      int getTemperature();
   #endif
};


#endif // _BIWAK_SI705X_H_
