TimeClock.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Control.h"
4 #include <DateTime.h>
5 
6 namespace Graphics
7 {
8 class TimeClock : public Control
9 {
10 public:
11  struct HMS {
12  int8_t hour{0};
13  int8_t min{0};
14  int8_t sec{0};
15 
16  HMS()
17  {
18  }
19 
20  HMS(int8_t h, int8_t m, int8_t s) : hour(h), min(m), sec(s)
21  {
22  }
23 
24  HMS(const DateTime& dt) : hour(dt.Hour), min(dt.Minute), sec(dt.Second)
25  {
26  }
27 
28  bool operator==(const HMS& other) const
29  {
30  return hour == other.hour && min == other.min && sec == other.sec;
31  }
32  };
33 
34  using Control::Control;
35 
36  void update(const HMS& hms)
37  {
38  if(hms == next) {
39  return;
40  }
41  next = hms;
42  flags += Flag::dirty;
43  }
44 
45  void update();
46 
47  void draw(SceneObject& scene) const override;
48 
49 private:
50  mutable HMS active;
51  HMS next{};
52 };
53 
54 } // namespace Graphics
Control()
Definition: Libraries/Graphics/src/include/Graphics/Control/Control.h:34
HMS(int8_t h, int8_t m, int8_t s)
Definition: TimeClock.h:20
BitSet< uint8_t, Flag > flags
Definition: Libraries/Graphics/src/include/Graphics/Control/Control.h:148
void draw(SceneObject &scene) const override
@ dirty
Requires repainting.
Definition: TimeClock.h:11
Basic interactive button on screen.
Definition: Libraries/Graphics/src/include/Graphics/Control/Control.h:12
void update(const HMS &hms)
Definition: TimeClock.h:36
Definition: Virtual.h:30
Date and time class.
Definition: DateTime.h:79
A Scene containing multiple objects.
Definition: Scene.h:50
HMS()
Definition: TimeClock.h:16
bool operator==(const HMS &other) const
Definition: TimeClock.h:28
int8_t hour
Definition: TimeClock.h:12
int8_t sec
Definition: TimeClock.h:14
@ Second
Definition: Timezone.h:41
Definition: TimeClock.h:8
int8_t min
Definition: TimeClock.h:13
HMS(const DateTime &dt)
Definition: TimeClock.h:24