예제 #1
0
int readMeasures()
{
	int temperature   = getTemperature();
	double humidity   = getHumidity();
	double luminosity = getLuminosity() ;

	char str[250];
	sprintf(str," temperature=%d, humidity=%lf, luminosity=%lf",  temperature, humidity, luminosity);
	printf("[Entry_point] Reading measures : %s\n", str);

	/*payload =
		"["
	    "{"
	    "\"machine.temperature\": [{"
	    "  \"timestamp\" : %d, "
	    "  \"value\" : \"%lf\""
	    "}]"
	    "}"
	    "]";*/
	int timestamp = getTimeStamp();
	temp_ts[temp_size] = timestamp;
	temp_values[temp_size] = malloc(10);
	sprintf(temp_values[temp_size], "%d", temperature);
	temp_size++;

	hum_ts[hum_size] = timestamp;
	hum_values[hum_size] = malloc(10);
	sprintf(hum_values[hum_size], "%lf", humidity);
	hum_size++;

	return 0;
}
예제 #2
0
void Adafruit_TSL2561::getEvent(sensors_event_t *event)
{
  uint16_t broadband, ir;
  
  /* Clear the event */
  memset(event, 0, sizeof(sensors_event_t));
  
  event->version   = sizeof(sensors_event_t);
  event->sensor_id = _tsl2561SensorID;
  event->type      = SENSOR_TYPE_LIGHT;
  event->timestamp = 0;

  /* Calculate the actual lux value */
  getLuminosity(&broadband, &ir);
  event->light = calculateLux(broadband, ir);
}
예제 #3
0
void MaterialMgr::save(FILE* f, unsigned int matId)
{
  MAT_ID_OK(matId);
  const char* matName;
  if ((matName = getName(matId)) && (matName[0] != '#'))
  {
    fprintf(f, "\r\n#Material\r\n");

    fprintf(f, "Name=%s\r\n", getName(matId));
    fprintf(f, "ColoreR=%i\r\n", getColorRed(matId));
    fprintf(f, "ColoreG=%i\r\n", getColorGreen(matId));
    fprintf(f, "ColoreB=%i\r\n", getColorBlue(matId));
    fprintf(f, "Specular=%i\r\n", getSpecular(matId));
    fprintf(f, "Shininess=%i\r\n", getShininess(matId));
    fprintf(f, "Luminosity=%i\r\n", getLuminosity(matId));
    fprintf(f, "Emission=%i\r\n", getEmission(matId));
    fprintf(f, "Trasparency=%i\r\n", getTrasparency(matId));
  }
}
bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
{
  uint16_t broadband, ir;

  /* Clear the event */
  memset(event, 0, sizeof(sensors_event_t));

  event->version   = sizeof(sensors_event_t);
  event->sensor_id = _tsl2561SensorID;
  event->type      = SENSOR_TYPE_LIGHT;
  event->timestamp = millis();

  /* Calculate the actual lux value */
  getLuminosity(&broadband, &ir);
  event->light = calculateLux(broadband, ir);

  if (event->light == 65536) {
    return false;
  }
  return true;
}