//-----------------------------------------------------------------------------
///
/// \brief  timer
///
///         Generic functions (no direct mcu depencies)
///
/// \date   20151115
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//-----------------------------------------------------------------------------


//---Includes------------------------------------------------------------------


#include <biwak/softtimer.h>


//---Implementation------------------------------------------------------------


#if 0
//QTimer::singleShot(200, this, SLOT(updateCaption()));
#define singleShot(time, object, slot) \
         _singleShotTimer<typeof(object)>(time, object, void (slotClass::*_methodPtr)( ))

template <class slotClass >
void _singleShotTimer( int timeoutMs, slotClass *slotObject, void (slotClass::*_methodPtr)() )
{
   functor=new CFunctorMethod<sigReturn, slotClass, sigTypes...>(slotObject, _methodPtr);
};
#endif

void CSoftTimer::start(int msec)
{
   m_startValue=lrNow();
   m_endValue=m_startValue+msecToLrt(msec);
   m_running=true;

   return;
}


void CSoftTimer::eventLoop()
{
   if(!m_running)
      return;

   if( lrNow() >= m_endValue )
   {
      timeout.emitSignal();
      m_running=false;
   }

   return;
}


//---fin-----------------------------------------------------------------------
