Blame view

epsilon-master/escher/src/timer.cpp 365 Bytes
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #include <escher/timer.h>
  
  Timer::Timer(uint32_t period) :
    m_period(period),
    m_numberOfTicksBeforeFire(period)
  {
  }
  
  bool Timer::tick() {
    m_numberOfTicksBeforeFire--;
    if (m_numberOfTicksBeforeFire == 0) {
      bool needRedraw = fire();
      reset();
      return needRedraw;
    }
    return false;
  }
  
  void Timer::reset() {
    m_numberOfTicksBeforeFire = m_period;
  }