コード例 #1
0
float Light::readIntegratedSlope()
{
    float value = ((float)readEv() - readIntegratedEv()) / (float)integration;

    value *= 30.0; // stops per 30min

    return value;
}
コード例 #2
0
float Light::readIntegratedSlope()
{
    if(!integrationActive) return 0.0;

    float value = (readEv() - integrated) / (float)integration;

    value *= (60.0 / 3.0); // stops per hour

    return value;
}
コード例 #3
0
void Light::integrationStart(uint8_t integration_minutes, int8_t darkOffset)
{
	start();
    integration = integration_minutes;
    pos = 0;
    lastSeconds = clock.Seconds() + 1; // +1 so it can never be zero
    for(uint8_t i = 0; i < LIGHT_INTEGRATION_COUNT; i++)
    {
    	iev[i] = readEv(); // initialize array with readings //
    	wdt_reset();
    }
}
コード例 #4
0
void Light::task()
{
	if(lastSeconds == 0) return;

    if(clock.Seconds() > lastSeconds + ((integration * 60) / LIGHT_INTEGRATION_COUNT))
    {
        lastSeconds = clock.Seconds();
        iev[pos] = readEv();
        pos++;
        if(pos >= LIGHT_INTEGRATION_COUNT) pos = 0;
        iev[pos] = 0;
    }
}
コード例 #5
0
void Light::integrationStart(uint8_t integration_minutes)
{
	  start();
    //DEBUG(STR(" ####### LIGHT INTEGRATION START #######\r\n"));
    integration = (uint16_t)integration_minutes;
    lastSeconds = 0;
    for(uint8_t i = 0; i < LIGHT_INTEGRATION_COUNT; i++)
    {
    	iev[i] = readEv(); // initialize array with readings //
    	wdt_reset();
    }
    integrationActive = true;
    slope = 0.0;
    median = iev[0];
    integrated = iev[0];
    lockedSlope = 0.0;
    task();
}
コード例 #6
0
void Light::task()
{
	if(!initialized || !integrationActive) return;

  if(skipTask) return;

  if(paused)
  {
    lcd.backlight(255);
    wasPaused = 5;
    return;
  }

  if(wasPaused > 0)
  {
    lcd.backlight(0);
    wasPaused--;
    return;
  }


  if(lastSeconds == 0 || (clock.Seconds() > lastSeconds + (uint32_t)((integration * 60) / LIGHT_INTEGRATION_COUNT)))
  {
    lastSeconds = clock.Seconds();
    for(uint8_t i = 0; i < LIGHT_INTEGRATION_COUNT - 1; i++)
    {
      iev[i] = iev[i + 1];
    }
    iev[LIGHT_INTEGRATION_COUNT - 1] = readEv();
    slope = readIntegratedSlopeMedian();

    if(iev[LIGHT_INTEGRATION_COUNT - 1] <= NIGHT_THRESHOLD)
    {
      underThreshold = true;
      if(lockedSlope == 0.0 && slope) lockedSlope = slope;
    }
    else if(iev[LIGHT_INTEGRATION_COUNT - 1] > NIGHT_THRESHOLD + NIGHT_THRESHOLD_HYSTERESIS)
    {
      underThreshold = false;
      lockedSlope = 0.0;
    }

    median = arrayMedian50(iev, LIGHT_INTEGRATION_COUNT);

    float sum = 0.0;
    for(uint8_t i = 0; i < LIGHT_INTEGRATION_COUNT; i++) sum += iev[i];
    integrated = sum / (float)(LIGHT_INTEGRATION_COUNT);

    if(conf.debugEnabled)
    {
      //DEBUG(STR("\r\nIEV: "));
      //for(uint8_t i = 0; i < LIGHT_INTEGRATION_COUNT; i++)
      //{
      //  DEBUG(iev[i]);
      //  DEBUG(STR(","));
      //}
      //DEBUG_NL();
//
      //DEBUG(STR("#######LOCKED "));
      //DEBUG(lockedSlope);
      //DEBUG(STR(" #######\r\n"));
//
      //DEBUG(STR("####### SLOPE "));
      //DEBUG(slope);
      //DEBUG(STR(" #######\r\n"));
//
//
      //DEBUG(STR("#######   INT "));
      //DEBUG(integrated);
      //DEBUG(STR(" #######\r\n"));
//
      //DEBUG(STR("#######   MED "));
      //DEBUG(median);
      //DEBUG(STR(" #######\r\n"));
//
      //DEBUG(STR("#######    EV "));
      //DEBUG(iev[LIGHT_INTEGRATION_COUNT - 1]);
      //DEBUG(STR(" #######\r\n"));
    }
  }
}