File tree 3 files changed +50
-46
lines changed
3 files changed +50
-46
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 19
19
#include " displayapp/Messages.h"
20
20
#include " BootErrors.h"
21
21
22
- #include " StaticStack.h"
22
+ #include " utility/ StaticStack.h"
23
23
24
24
namespace Pinetime {
25
25
@@ -126,8 +126,8 @@ namespace Pinetime {
126
126
void ApplyBrightness ();
127
127
128
128
static constexpr size_t returnAppStackSize = 10 ;
129
- StaticStack<Apps, returnAppStackSize> returnAppStack;
130
- StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
129
+ Utility:: StaticStack<Apps, returnAppStackSize> returnAppStack;
130
+ Utility:: StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
131
131
132
132
bool isDimmed = false ;
133
133
};
Original file line number Diff line number Diff line change
1
+ #include < array>
2
+ #include < cstddef>
3
+
4
+ namespace Pinetime {
5
+ namespace Utility {
6
+ template <typename T, size_t N>
7
+ class StaticStack {
8
+ public:
9
+ T Pop ();
10
+ void Push (T element);
11
+ void Reset ();
12
+ T Top ();
13
+
14
+ private:
15
+ std::array<T, N> elementArray;
16
+ // Number of elements in stack, points to the next empty slot
17
+ size_t stackPointer = 0 ;
18
+ };
19
+
20
+ // Returns random data when popping from empty array.
21
+ template <typename T, size_t N>
22
+ T StaticStack<T, N>::Pop() {
23
+ if (stackPointer > 0 ) {
24
+ stackPointer--;
25
+ }
26
+ return elementArray[stackPointer];
27
+ }
28
+
29
+ template <typename T, size_t N>
30
+ void StaticStack<T, N>::Push(T element) {
31
+ if (stackPointer < elementArray.size ()) {
32
+ elementArray[stackPointer] = element;
33
+ stackPointer++;
34
+ }
35
+ }
36
+
37
+ template <typename T, size_t N>
38
+ void StaticStack<T, N>::Reset() {
39
+ stackPointer = 0 ;
40
+ }
41
+
42
+ template <typename T, size_t N>
43
+ T StaticStack<T, N>::Top() {
44
+ return elementArray[stackPointer - 1 ];
45
+ }
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments