Skip to content

Commit 4f99e2e

Browse files
committed
refactor: restructure directory
1 parent 4959958 commit 4f99e2e

File tree

16 files changed

+100
-100
lines changed

16 files changed

+100
-100
lines changed

Spresense-CycleComputer.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#include "src/CycleComputer.h"
44
#include "src/drivers/Gnss.h"
55
#include "src/drivers/OLED.h"
6-
#include "src/system/Input.h"
6+
#include "src/ui/Input.h"
77

8-
drivers::OLED display(Wire);
9-
application::Input input;
10-
application::CycleComputer<drivers::OLED, drivers::Gnss, application::Input> computer(display, drivers::Gnss::getInstance(), input);
8+
drivers::OLED display(Wire);
9+
ui::Input input;
10+
application::CycleComputer<drivers::OLED, drivers::Gnss, ui::Input> computer(display, drivers::Gnss::getInstance(), input);
1111

1212
void setup() {
1313
LowPower.begin();

src/CycleComputer.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#pragma once
22

33
#include "Config.h"
4-
#include "system/Clock.h"
5-
#include "system/DisplayData.h"
6-
#include "system/InputEvent.h"
7-
#include "system/Mode.h"
8-
#include "system/Trip.h"
4+
#include "domain/Clock.h"
5+
#include "domain/Trip.h"
6+
#include "ui/DisplayData.h"
7+
#include "ui/InputEvent.h"
8+
#include "ui/Mode.h"
99
#include <cstdio>
1010

1111
namespace application {
@@ -15,14 +15,14 @@ template <typename DisplayT, typename GnssT, typename InputT> class CycleCompute
1515
DisplayT &display;
1616
InputT &input;
1717
GnssT &gnss;
18-
Mode mode;
19-
Trip trip;
20-
Clock clock;
18+
ui::Mode mode;
19+
domain::Trip trip;
20+
domain::Clock clock;
2121
unsigned long lastDisplayUpdate = 0;
2222
bool forceUpdate = false;
2323

2424
public:
25-
CycleComputer(DisplayT &displayData, GnssT &gnss, InputT &input) : display(displayData), gnss(gnss), input(input) {}
25+
CycleComputer(DisplayT &displayData, GnssT &gnss, InputT &input) : display(displayData), input(input), gnss(gnss) {}
2626

2727
void begin() {
2828
display.begin();
@@ -42,18 +42,18 @@ template <typename DisplayT, typename GnssT, typename InputT> class CycleCompute
4242

4343
private:
4444
void handleInput() {
45-
InputEvent event = input.update();
45+
ui::InputEvent event = input.update();
4646

4747
switch (event) {
48-
case InputEvent::BTN_A:
48+
case ui::InputEvent::BTN_A:
4949
mode.next();
5050
forceUpdate = true;
5151
break;
52-
case InputEvent::BTN_B:
52+
case ui::InputEvent::BTN_B:
5353
mode.prev();
5454
forceUpdate = true;
5555
break;
56-
case InputEvent::BTN_BOTH:
56+
case ui::InputEvent::BTN_BOTH:
5757
trip.reset();
5858
forceUpdate = true;
5959
break;
@@ -70,45 +70,45 @@ template <typename DisplayT, typename GnssT, typename InputT> class CycleCompute
7070
lastDisplayUpdate = currentMillis;
7171
forceUpdate = false;
7272

73-
char buf[32];
74-
DisplayDataType type;
73+
char buf[32];
74+
ui::DisplayDataType type;
7575
getDisplayData(mode.get(), type, buf, sizeof(buf));
7676

7777
display.show(type, buf);
7878
}
7979

80-
void getDisplayData(Mode::ID modeId, DisplayDataType &type, char *buf, size_t size) {
80+
void getDisplayData(ui::Mode::ID modeId, ui::DisplayDataType &type, char *buf, size_t size) {
8181
switch (modeId) {
82-
case Mode::ID::SPEED:
83-
type = DisplayDataType::SPEED;
82+
case ui::Mode::ID::SPEED:
83+
type = ui::DisplayDataType::SPEED;
8484
trip.getSpeedStr(buf, size);
8585
break;
86-
case Mode::ID::MAX_SPEED:
87-
type = DisplayDataType::MAX_SPEED;
86+
case ui::Mode::ID::MAX_SPEED:
87+
type = ui::DisplayDataType::MAX_SPEED;
8888
trip.getMaxSpeedStr(buf, size);
8989
break;
90-
case Mode::ID::AVG_SPEED:
91-
type = DisplayDataType::AVG_SPEED;
90+
case ui::Mode::ID::AVG_SPEED:
91+
type = ui::DisplayDataType::AVG_SPEED;
9292
trip.getAvgSpeedStr(buf, size);
9393
break;
94-
case Mode::ID::DISTANCE:
95-
type = DisplayDataType::DISTANCE;
94+
case ui::Mode::ID::DISTANCE:
95+
type = ui::DisplayDataType::DISTANCE;
9696
trip.getDistanceStr(buf, size);
9797
break;
98-
case Mode::ID::TIME:
99-
type = DisplayDataType::TIME;
98+
case ui::Mode::ID::TIME:
99+
type = ui::DisplayDataType::TIME;
100100
clock.getTimeStr(buf, size);
101101
break;
102-
case Mode::ID::MOVING_TIME:
103-
type = DisplayDataType::MOVING_TIME;
102+
case ui::Mode::ID::MOVING_TIME:
103+
type = ui::DisplayDataType::MOVING_TIME;
104104
trip.getMovingTimeStr(buf, size);
105105
break;
106-
case Mode::ID::ELAPSED_TIME:
107-
type = DisplayDataType::ELAPSED_TIME;
106+
case ui::Mode::ID::ELAPSED_TIME:
107+
type = ui::DisplayDataType::ELAPSED_TIME;
108108
trip.getElapsedTimeStr(buf, size);
109109
break;
110110
default:
111-
type = DisplayDataType::INVALID;
111+
type = ui::DisplayDataType::INVALID;
112112
buf[0] = '\0';
113113
break;
114114
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <GNSS.h>
55
#include <cstdio>
66

7-
namespace application {
7+
namespace domain {
88

99
class Clock {
1010
private:
@@ -29,4 +29,4 @@ class Clock {
2929
}
3030
};
3131

32-
} // namespace application
32+
} // namespace domain
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <GNSS.h>
44

5-
namespace application {
5+
namespace domain {
66

77
class Odometer {
88
private:
@@ -31,4 +31,4 @@ class Odometer {
3131
}
3232
};
3333

34-
} // namespace application
34+
} // namespace domain
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <GNSS.h>
44

5-
namespace application {
5+
namespace domain {
66

77
class Speedometer {
88
private:
@@ -32,4 +32,4 @@ class Speedometer {
3232
}
3333
};
3434

35-
} // namespace application
35+
} // namespace domain
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <GNSS.h>
55
#include <cstdio>
66

7-
namespace application {
7+
namespace domain {
88

99
class Stopwatch {
1010
private:
@@ -55,4 +55,4 @@ class Stopwatch {
5555
}
5656
};
5757

58-
} // namespace application
58+
} // namespace domain
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <GNSS.h>
88

9-
namespace application {
9+
namespace domain {
1010

1111
class Trip {
1212
private:
@@ -95,4 +95,4 @@ class Trip {
9595
}
9696
};
9797

98-
} // namespace application
98+
} // namespace domain

src/drivers/OLED.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <Arduino.h>
66

77
#include "../Config.h"
8-
#include "../system/DisplayData.h"
8+
#include "../ui/DisplayData.h"
99

1010
namespace drivers {
1111

@@ -26,11 +26,11 @@ class OLED {
2626
display.display();
2727
}
2828

29-
void show(application::DisplayDataType type, const char *value) {
29+
void show(ui::DisplayDataType type, const char *value) {
3030
display.clearDisplay();
3131

3232
drawHeader();
33-
application::DisplayMetadata meta = application::getDisplayMetadata(type);
33+
ui::DisplayMetadata meta = ui::getDisplayMetadata(type);
3434
drawMainArea(meta.title.c_str(), value, meta.unit.c_str());
3535
drawFooter();
3636

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <Arduino.h>
44

5-
namespace application {
5+
namespace ui {
66

77
enum class DisplayDataType {
88
SPEED,
@@ -41,4 +41,4 @@ inline DisplayMetadata getDisplayMetadata(DisplayDataType type) {
4141
}
4242
}
4343

44-
} // namespace application
44+
} // namespace ui
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "InputEvent.h"
66

7-
namespace application {
7+
namespace ui {
88

99
class Input {
1010
private:
@@ -31,4 +31,4 @@ class Input {
3131
}
3232
};
3333

34-
} // namespace application
34+
} // namespace ui

0 commit comments

Comments
 (0)