diff options
author | jdlugosz963 <jdlugosz963@gmail.com> | 2022-12-22 19:01:49 +0100 |
---|---|---|
committer | jdlugosz963 <jdlugosz963@gmail.com> | 2022-12-22 19:01:49 +0100 |
commit | 64ea63f2efadddf9bf185f7ce24bf3c56538b287 (patch) | |
tree | 1980e7d377fe17e6b404435c229885518b6a52c1 | |
parent | afe2df4dfa6d6858f5352f55e8e00ba05faf69fa (diff) | |
download | shack-64ea63f2efadddf9bf185f7ce24bf3c56538b287.tar.gz shack-64ea63f2efadddf9bf185f7ce24bf3c56538b287.zip |
Add controller
-rw-r--r-- | controller.cpp | 26 | ||||
-rw-r--r-- | controller.h | 30 | ||||
-rw-r--r-- | schack.ino | 3 |
3 files changed, 59 insertions, 0 deletions
diff --git a/controller.cpp b/controller.cpp new file mode 100644 index 0000000..6a4b900 --- /dev/null +++ b/controller.cpp | |||
@@ -0,0 +1,26 @@ | |||
1 | #include "Arduino.h" | ||
2 | #include "controller.h" | ||
3 | |||
4 | |||
5 | Controller::Controller(MP3Controller *mp3Controller) { | ||
6 | this->mp3Controller = mp3Controller; | ||
7 | } | ||
8 | |||
9 | void Controller::next() { | ||
10 | mp3Controller->nextFile(); | ||
11 | } | ||
12 | |||
13 | void Controller::nextS() { | ||
14 | mp3Controller->nextSection(); | ||
15 | } | ||
16 | |||
17 | void Controller::previousS() { | ||
18 | mp3Controller->previousSection(); | ||
19 | } | ||
20 | |||
21 | void Controller::previous() { | ||
22 | mp3Controller->previousFile(); | ||
23 | } | ||
24 | |||
25 | void Controller::setRoot(String newRoot) { root = newRoot; } | ||
26 | String Controller::getRoot() { return root; } | ||
diff --git a/controller.h b/controller.h new file mode 100644 index 0000000..de8d86b --- /dev/null +++ b/controller.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef CONTROLLER_H | ||
2 | #define CONTROLLER_H | ||
3 | |||
4 | class MP3Controller { | ||
5 | public: | ||
6 | virtual void nextFile() = 0; | ||
7 | virtual void previousFile() = 0; | ||
8 | virtual void nextSection() = 0; | ||
9 | virtual void previousSection() = 0; | ||
10 | }; | ||
11 | |||
12 | class Controller { | ||
13 | String root = "/"; | ||
14 | MP3Controller *mp3Controller; | ||
15 | public: | ||
16 | Controller(MP3Controller*); | ||
17 | |||
18 | void next(); | ||
19 | void nextS(); | ||
20 | void previous(); | ||
21 | void previousS(); | ||
22 | |||
23 | void setRoot(String); | ||
24 | String getRoot(); | ||
25 | |||
26 | String getAPSSID() { return "ESP8266"; } | ||
27 | String getAPPassword() { return "test1234"; } | ||
28 | }; | ||
29 | |||
30 | #endif | ||
@@ -1,12 +1,15 @@ | |||
1 | #include "controller.h" | ||
1 | #include "mp3player.h" | 2 | #include "mp3player.h" |
2 | 3 | ||
3 | MP3Player *mp3Player; | 4 | MP3Player *mp3Player; |
5 | Controller *controller; | ||
4 | 6 | ||
5 | void setup() { | 7 | void setup() { |
6 | Serial.begin(9600); | 8 | Serial.begin(9600); |
7 | SD.begin(SS); | 9 | SD.begin(SS); |
8 | 10 | ||
9 | mp3Player = new MP3Player(); | 11 | mp3Player = new MP3Player(); |
12 | controller = new Controller(mp3Player); | ||
10 | } | 13 | } |
11 | 14 | ||
12 | 15 | ||