Пример #1
0
boolean Adafruit_TSL2591::begin(void)
{
  Wire.begin();

  /*
  for (uint8_t i=0; i<0x20; i++)
  {
    uint8_t id = read8(0x12);
    Serial.print("$"); Serial.print(i, HEX);
    Serial.print(" = 0x"); Serial.println(read8(i), HEX);
  }
  */

  uint8_t id = read8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_ID);
  if (id == 0x50 )
  {
      //Serial.println("Found Adafruit_TSL2591");
  }
  else
  {
    return false;
  }

  _initialized = true;

  // Set default integration time and gain
  setTiming(_integration);
  setGain(_gain);

  // Note: by default, the device is in power down mode on bootup
  disable();

  return true;
}
Пример #2
0
/*
 Function: 
 Returns: 
 Parameters: 
 Values: 
*/
boolean WaspSensorAmbient::begin(void) 
{
  Wire.begin();

 // Initialise I2C
  Wire.beginTransmission(_addr);

  Wire.send(TSL2561_REGISTER_ID);

  Wire.endTransmission();
  Wire.requestFrom(_addr, 1);

  int x = Wire.receive();
  
  if (x & 0x0A ) 
  {} 
  else 
  {
    return false;
  }
  _initialized = true;

  // Set default integration time and gain
  setTiming(_integration);
  setGain(_gain);
  
  // Note: by default, the device is in power down mode on bootup
  disable();

  return true;
}
Пример #3
0
boolean TSL2561::begin(void) {
  Wire.begin();

 // Initialise I2C
  Wire.beginTransmission(_addr);
#if ARDUINO >= 100
  Wire.write(TSL2561_REGISTER_ID);
#else
  Wire.send(TSL2561_REGISTER_ID);
#endif
  Wire.endTransmission();
  Wire.requestFrom(_addr, 1);
#if ARDUINO >= 100
  int x = Wire.read();
#else
  int x = Wire.receive();
#endif
  //Serial.print("0x"); Serial.println(x, HEX);
  if (x & 0x0A ) {
    //Serial.println("Found TSL2561");
  } else {
    return false;
  }
  _initialized = true;

  // Set default integration time and gain
  setTiming(_integration);
  setGain(_gain);
  // Note: by default, the device is in power down mode on bootup
  disable();

  return true;
}
Пример #4
0
boolean SFE_TSL2561::setTiming(boolean gain, unsigned char time, unsigned int &ms)
// If gain = false (0), device is set to low gain (1X)
// If gain = high (1), device is set to high gain (16X)
// If time = 0, integration will be 13.7ms
// If time = 1, integration will be 101ms
// If time = 2, integration will be 402ms
// If time = 3, use manual start / stop (ms = 0)
// ms will be set to integration time
// Returns true (1) if successful, false (0) if there was an I2C error
// (Also see getError() below)
{
    // Calculate ms for user
    switch (time)
    {
    case 0:
        ms = 14;
        break;
    case 1:
        ms = 101;
        break;
    case 2:
        ms = 402;
        break;
    default:
        ms = 0;
    }
    // Set integration using base function
    return(setTiming(gain,time));
}
Пример #5
0
DaySimulator::DaySimulator(QObject *parent) : EventSimulator(parent)
{
    this->setCycle(kDayCycle);
    this->setDuration(kDayEventDuration);
    setRandomTime(kDayRandom);
    setTiming( ((kDayCycle-kDayRandom) / 2.0) / kDayCycle);
    qDebug() << "Random time for day is " << getRandomTime() <<", timing is " << getTiming();

}
static RefPtr<Inspector::Protocol::Network::Response> buildObjectForResourceResponse(const ResourceResponse& response, DocumentLoader* loader)
{
    if (response.isNull())
        return nullptr;

    double status = response.httpStatusCode();
    Ref<InspectorObject> headers = buildObjectForHeaders(response.httpHeaderFields());

    auto responseObject = Inspector::Protocol::Network::Response::create()
        .setUrl(response.url().string())
        .setStatus(status)
        .setStatusText(response.httpStatusText())
        .setHeaders(WTFMove(headers))
        .setMimeType(response.mimeType())
        .release();

    responseObject->setFromDiskCache(response.source() == ResourceResponse::Source::DiskCache || response.source() == ResourceResponse::Source::DiskCacheAfterValidation);
    responseObject->setTiming(buildObjectForTiming(response.networkLoadTiming(), loader));

    return WTFMove(responseObject);
}
Пример #7
0
boolean SAT_Lum::begin() { // jfomhover on 07/08/2013 : argument (uint8_t nodeid) was not used in here..
/*  Wire.begin(); */ // jfomhover on 07/08/2013 : shouldn't be made, cause already begun in OnboardCommLayer.cpp
	OBCL.begin();

	uint8_t retByte = 0;

	int8_t t_ret = OBCL.exchangeByte(_addr, SAT_Lum_REGISTER_ID, &retByte, I2C_COMM_INSTANTTIMEOUT);

	if ((retByte ^ 0x0A) != 0) {
		// sensor not found
		_initialized = false;
		return(false);
	}
	_initialized = true;

	// Set default integration time and gain
	setTiming(_integration);
	setGain(_gain);
	// Note: by default, the device is in power down mode on bootup
	disable();

	return true;
}
Пример #8
0
void DaySimulator::setCycle(const uint &cycle)
{
    EventSimulator::setCycle(cycle);
    setTiming( ((cycle-getRandomTime()) / 2.0) / cycle);

}
Пример #9
0
void DaySimulator::setRandomTime(const uint &randomTime)
{
    EventSimulator::setRandomTime(randomTime);
    setTiming( ((getCycle()-randomTime) / 2.0) / getCycle());
}