File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1919#include " displayapp/Messages.h"
2020#include " BootErrors.h"
2121
22- #include " StaticStack.h"
22+ #include " utility/ StaticStack.h"
2323
2424namespace Pinetime {
2525
@@ -126,8 +126,8 @@ namespace Pinetime {
126126 void ApplyBrightness ();
127127
128128 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;
131131
132132 bool isDimmed = false ;
133133 };
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