当前位置: 首页>>代码示例>>C++>>正文


C++ Weather::getRH方法代码示例

本文整理汇总了C++中Weather::getRH方法的典型用法代码示例。如果您正苦于以下问题:C++ Weather::getRH方法的具体用法?C++ Weather::getRH怎么用?C++ Weather::getRH使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Weather的用法示例。


在下文中一共展示了Weather::getRH方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getWeather

void getWeather()
{
    // Measure Relative Humidity from the HTU21D or Si7021
    humidity = sensor.getRH();

    // Measure Temperature from the HTU21D or Si7021
    tempf = sensor.getTempF();

    //
    // Temperature is measured every time RH is requested.
    // It is faster, therefore, to read it from previous RH
    // measurement with getTemp() instead with readTemp()
    //

    // Measure the Barometer temperature in F from the MPL3115A2
    baroTemp = sensor.readBaroTempF();

    // Measure Pressure from the MPL3115A2
    pascals = sensor.readPressure();

    // If in altitude mode, you can get a reading in feet  with this line:
    //altf = sensor.readAltitudeFt();

    getSoilTemp(); // Read the DS18B20 waterproof temp sensor
    getSoilMositure(); // Read the soil moisture sensor

    // Calc winddir
    winddir = get_wind_direction();

    // Calc windspeed
    windspeedmph = get_wind_speed();

    // Calc windgustmph
    // Calc windgustdir
    // Report the largest windgust today
    windgustmph = 0;
    windgustdir = 0;

    // Calc windspdmph_avg2m
    float temp = 0;

    for(int i = 0 ; i < 120 ; i++) {
      temp += windspdavg[i];
    }

    temp /= 120.0;
    windspdmph_avg2m = temp;

    // Calc winddir_avg2m
    temp = 0; // Can't use winddir_avg2m because it's an int

    for(int i = 0 ; i < 120 ; i++) {
      temp += winddiravg[i];
    }

    temp /= 120;
    winddir_avg2m = temp;

    //
    // Calc windgustmph_10m
    // Calc windgustdir_10m
    // Find the largest windgust in the last 10 minutes
    //
    windgustmph_10m = 0;
    windgustdir_10m = 0;

    // Step through the 10 minutes
    for(int i = 0; i < 10 ; i++)
    {
      if(windgust_10m[i] > windgustmph_10m)
      {
        windgustmph_10m = windgust_10m[i];
        windgustdir_10m = windgustdirection_10m[i];
      }
    }

    //
    // Total rainfall for the day is calculated within the interrupt
    // Calculate amount of rainfall for the last 60 minutes
    //
    rainin = 0;

    for(int i = 0 ; i < 60 ; i++) {
      rainin += rainHour[i];
    }
}
开发者ID:menloparkinnovation,项目名称:openpux,代码行数:86,代码来源:SparkFun_Photon_Weather_Menlo.cpp


注:本文中的Weather::getRH方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。