<commit_before>/*************************************************** 
  This is a library for the HDC1000 Humidity & Temp Sensor

  Designed specifically to work with the HDC1008 sensor from Adafruit
  ----> https://www.adafruit.com/products/2635

  These sensors use I2C to communicate, 2 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by <NAME>/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
  
  Modified for Photon  needs application.h for types  RMB
 ****************************************************/
#include "application.h"
#include "Adafruit_HDC1000/Adafruit_HDC1000.h"


Adafruit_HDC1000::Adafruit_HDC1000() {
}


boolean Adafruit_HDC1000::begin(uint8_t addr) {
  _i2caddr = addr;

  Wire.begin();
  
  reset();
  if (read16(HDC1000_MANUFID) != 0x5449) return false;
  if (read16(HDC1000_DEVICEID) != 0x1000) return false;
  return true;
}



void Adafruit_HDC1000::reset(void) {
  // reset,combined temp/humidity measurement,and select 14 bit temp & humidity resolution
  uint16_t config = HDC1000_CONFIG_RST | HDC1000_CONFIG_MODE | HDC1000_CONFIG_TRES_14 | HDC1000_CONFIG_HRES_14;

  Wire.beginTransmission(_i2caddr);
  Wire.write(HDC1000_CONFIG);   // set pointer register to configuration register   RMB
  Wire.write(config>>8);        // now write out 2 bytes MSB first    RMB
  Wire.write(config&0xFF);
  Wire.endTransmission();
  delay(15);
}


float Adafruit_HDC1000::readTemperature(void) {
  
  float temp = (read32(HDC1000_TEMP, 20) >> 16);
  temp /= 65536;
  temp *= 165;
  temp -= 40;

  return temp;
}
  

float Adafruit_HDC1000::readHumidity(void) {
  // reads both temp and humidity but masks out temp in highest 16 bits
  // originally used hum but humidity declared in private section of class
  float humidity = (read32(HDC1000_TEMP, 20) & 0xFFFF);

  humidity /= 65536;
  humidity *= 100;

  return humidity;
}

void Adafruit_HDC1000::ReadTempHumidity(void) {
  // HDC1008 setup to measure both temperature and humidity in one conversion
  // this is a different way to access data in ONE read
  // this sets internal private variables that can be accessed by Get() functions

  uint32_t rt,rh ;  // working variables
  
  rt = read32(HDC1000_TEMP, 20);    // get temp and humidity reading together
  rh = rt;                          // save a copy for humidity processing
  
  float (temp = (rt >> 16));        // convert to temp first
  temp /= 65536;
  temp *= 165;
  temp -= 40;
  
  float (humidity = (rh & 0xFFFF));   // now convert to humidity
  humidity /= 65536;
  humidity *= 100;
}

float Adafruit_HDC1000::GetTemperature(void) {
  // getter function to access private temp variable
  
  return temp ;
}

float Adafruit_HDC1000::GetHumidity(void) {
  // getter function to access private humidity variable
  
  return humidity ;
}
<commit_msg>parentheses important in float cast of private var<commit_after>/*************************************************** 
  This is a library for the HDC1000 Humidity & Temp Sensor

  Designed specifically to work with the HDC1008 sensor from Adafruit
  ----> https://www.adafruit.com/products/2635

  These sensors use I2C to communicate, 2 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by <NAME> for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
  
  Modified for Photon  needs application.h for types  RMB
 ****************************************************/
#include "application.h"
#include "Adafruit_HDC1000/Adafruit_HDC1000.h"


Adafruit_HDC1000::Adafruit_HDC1000() {
}


boolean Adafruit_HDC1000::begin(uint8_t addr) {
  _i2caddr = addr;

  Wire.begin();
  
  reset();
  if (read16(HDC1000_MANUFID) != 0x5449) return false;
  if (read16(HDC1000_DEVICEID) != 0x1000) return false;
  return true;
}



void Adafruit_HDC1000::reset(void) {
  // reset,combined temp/humidity measurement,and select 14 bit temp & humidity resolution
  uint16_t config = HDC1000_CONFIG_RST | HDC1000_CONFIG_MODE | HDC1000_CONFIG_TRES_14 | HDC1000_CONFIG_HRES_14;

  Wire.beginTransmission(_i2caddr);
  Wire.write(HDC1000_CONFIG);   // set pointer register to configuration register   RMB
  Wire.write(config>>8);        // now write out 2 bytes MSB first    RMB
  Wire.write(config&0xFF);
  Wire.endTransmission();
  delay(15);
}


float Adafruit_HDC1000::readTemperature(void) {
  
  float temp = (read32(HDC1000_TEMP, 20) >> 16);
  temp /= 65536;
  temp *= 165;
  temp -= 40;

  return temp;
}
  

float Adafruit_HDC1000::readHumidity(void) {
  // reads both temp and humidity but masks out temp in highest 16 bits
  // originally used hum but humidity declared in private section of class
  float humidity = (read32(HDC1000_TEMP, 20) & 0xFFFF);

  humidity /= 65536;
  humidity *= 100;

  return humidity;
}

void Adafruit_HDC1000::ReadTempHumidity(void) {
  // HDC1008 setup to measure both temperature and humidity in one conversion
  // this is a different way to access data in ONE read
  // this sets internal private variables that can be accessed by Get() functions

  uint32_t rt,rh ;  // working variables
  
  rt = read32(HDC1000_TEMP, 20);    // get temp and humidity reading together
  rh = rt;                          // save a copy for humidity processing
  
  // important to use ( ) around temp so private variable accessed and float cast done
  float (temp = (rt >> 16));        // convert to temp first
  temp /= 65536;
  temp *= 165;
  temp -= 40;
  
  // important to use ( ) around humidity so private variable accessed and float cast done
  float (humidity = (rh & 0xFFFF));   // now convert to humidity
  humidity /= 65536;
  humidity *= 100;
}

float Adafruit_HDC1000::GetTemperature(void) {
  // getter function to access private temp variable
  
  return temp ;
}

float Adafruit_HDC1000::GetHumidity(void) {
  // getter function to access private humidity variable
  
  return humidity ;
}

{'fraction_non_alphanumeric': 0.11493329046777045, 'fraction_numerical': 0.06108342710175213, 'mean_word_length': 3.6676669167291824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '97332', 'n_tokens_mistral': 2292, 'n_tokens_neox': 1876, 'n_words': 631}