From 64ea63f2efadddf9bf185f7ce24bf3c56538b287 Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Thu, 22 Dec 2022 19:01:49 +0100 Subject: Add controller --- controller.cpp | 26 ++++++++++++++++++++++++++ controller.h | 30 ++++++++++++++++++++++++++++++ schack.ino | 3 +++ 3 files changed, 59 insertions(+) create mode 100644 controller.cpp create mode 100644 controller.h diff --git a/controller.cpp b/controller.cpp new file mode 100644 index 0000000..6a4b900 --- /dev/null +++ b/controller.cpp @@ -0,0 +1,26 @@ +#include "Arduino.h" +#include "controller.h" + + +Controller::Controller(MP3Controller *mp3Controller) { + this->mp3Controller = mp3Controller; +} + +void Controller::next() { + mp3Controller->nextFile(); +} + +void Controller::nextS() { + mp3Controller->nextSection(); +} + +void Controller::previousS() { + mp3Controller->previousSection(); +} + +void Controller::previous() { + mp3Controller->previousFile(); +} + +void Controller::setRoot(String newRoot) { root = newRoot; } +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 @@ +#ifndef CONTROLLER_H +#define CONTROLLER_H + +class MP3Controller { +public: + virtual void nextFile() = 0; + virtual void previousFile() = 0; + virtual void nextSection() = 0; + virtual void previousSection() = 0; +}; + +class Controller { + String root = "/"; + MP3Controller *mp3Controller; +public: + Controller(MP3Controller*); + + void next(); + void nextS(); + void previous(); + void previousS(); + + void setRoot(String); + String getRoot(); + + String getAPSSID() { return "ESP8266"; } + String getAPPassword() { return "test1234"; } +}; + +#endif diff --git a/schack.ino b/schack.ino index 6efcf5c..2cc3da2 100644 --- a/schack.ino +++ b/schack.ino @@ -1,12 +1,15 @@ +#include "controller.h" #include "mp3player.h" MP3Player *mp3Player; +Controller *controller; void setup() { Serial.begin(9600); SD.begin(SS); mp3Player = new MP3Player(); + controller = new Controller(mp3Player); } -- cgit v1.2.3