summaryrefslogtreecommitdiff
path: root/src/components/timer/TimerController.h
blob: 5a0b293ee52d853e38dbac6a0795a5c99b0d7dc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include <cstdint>
#include "app_timer.h"
#include "portmacro_cmsis.h"

namespace Pinetime {
  namespace System {
    class SystemTask;
  }
  namespace Controllers {
    
    class TimerController {
    public:
      TimerController(Pinetime::System::SystemTask& systemTask);
      
      void Init();
      
      void StartTimer(uint32_t duration);
      
      void StopTimer();
      
      uint32_t GetTimeRemaining();
      
      bool IsRunning();
    
    private:
      System::SystemTask& systemTask;
      
      static void timerEnd(void* p_context);
  
      TickType_t endTicks;
      bool timerRunning = false;
    };
  }
}