コード例 #1
0
ファイル: DHT.cpp プロジェクト: anth-3/libraries
uint8_t DHT::getStatus(void) {
    // If temperature is at an extreme, set to warning...
    if (_lastTemperature > 100 || _lastTemperature < 60) {
        REMOVE_BIT(_status, STATUS_TEMP_GOOD);
        ADD_BIT(_status, STATUS_TEMP_WARN);
        // If temperature is really extreme, set to alert...
        if (_lastTemperature > 110 || _lastTemperature < 40) {
            REMOVE_BIT(_status, STATUS_TEMP_WARN);
            ADD_BIT(_status, STATUS_TEMP_ALRT);
        }
    }

    // If humidity is low, set to warning...
    if (_lastHumidity < 60) {
        REMOVE_BIT(_status, STATUS_HUMI_GOOD);
        ADD_BIT(_status, STATUS_HUMI_WARN);
        // If humidity is extreme, set to alert...
        if (_lastHumidity < 20) {
            REMOVE_BIT(_status, STATUS_HUMI_WARN);
            ADD_BIT(_status, STATUS_HUMI_ALRT);
        }
    }

    return (_status);
}
コード例 #2
0
ファイル: gegl-tile-backend-swap.c プロジェクト: bantu/gegl
static guint
gegl_tile_backend_swap_hashfunc (gconstpointer key)
{
  const SwapEntry *entry = key;
  guint            hash;
  gint             i;
  gint             srcA  = entry->x;
  gint             srcB  = entry->y;
  gint             srcC  = entry->z;

  /* interleave the 10 least significant bits of all coordinates,
   * this gives us Z-order / morton order of the space and should
   * work well as a hash
   */
  hash = 0;
  for (i = 9; i >= 0; i--)
    {
#define ADD_BIT(bit)    do { hash |= (((bit) != 0) ? 1 : 0); hash <<= 1; } while (0)
      ADD_BIT (srcA & (1 << i));
      ADD_BIT (srcB & (1 << i));
      ADD_BIT (srcC & (1 << i));
#undef ADD_BIT
    }
  return hash;
}
コード例 #3
0
ファイル: DHT.cpp プロジェクト: anth-3/libraries
DHT::DHT(void) {
    _maxCycles = microsecondsToClockCycles(DHT_MAX_CYCLES);
    _lastTemperature = _lastHumidity = 0;
    ADD_BIT(_status, STATUS_TEMP_GOOD | STATUS_HUMI_GOOD);

    DEBUG_PRINTLN("DHT loaded.");
}