Exemplo n.º 1
0
struct EventBase* EventBase_new(struct Allocator* allocator)
{
    struct Allocator* alloc = Allocator_child(allocator);
    struct EventBase_pvt* base = Allocator_calloc(alloc, sizeof(struct EventBase_pvt), 1);
    base->loop = uv_loop_new();
    base->alloc = alloc;
    Identity_set(base);

    Allocator_onFree(alloc, onFree, base);
    calibrateTime(base);
    return &base->pub;
}
Exemplo n.º 2
0
/********************************************************************
*
*	sleepDelay
*
********************************************************************/
void Sleep::sleepDelay(unsigned long sleepTime, boolean &abortCycle) {
  ADCSRA &= ~(1<<ADEN);  // adc off
   // PRR = 0xEF; // modules off
  
  ++sleepCycleCount;
  sleepCycleCount = sleepCycleCount % sleepCycleInterval; //recalibrate every interval cycles
  if(sleepCycleCount == 1)
  {
	calibrateTime(sleepTime,abortCycle);
  }
  else
  {
  	set_sleep_mode(sleepMode_);
  	int trem = sleepWDT(sleepTime*calibv,abortCycle); 
  	timeSleep += (sleepTime-trem);
  }
  // PRR = 0x00; //modules on
 ADCSRA |= (1<<ADEN);  // adc on
}