From 03c87b94c60418e99fb52285c95a4460091d83d5 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Mon, 14 Sep 2020 15:15:10 -0400 Subject: [PATCH] DrawName moved to Droplets --- Makefile | 3 ++- src/droplets/droplet.cpp | 12 ++++++++++++ src/droplets/droplet.h | 6 ++++++ src/droplets/noise_droplet.cpp | 14 +------------- src/droplets/noise_droplet.h | 1 - 5 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 src/droplets/droplet.cpp diff --git a/Makefile b/Makefile index 7fc64f5..ae0649c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ TARGET = cascade -CPP_SOURCES = src/main.cpp src/util.cpp src/menu.cpp src/droplets/noise_droplet.cpp +CPP_SOURCES = src/main.cpp src/util.cpp src/menu.cpp \ + src/droplets/droplet.cpp src/droplets/noise_droplet.cpp LIBDAISY_DIR = ./lib/libDaisy DAISYSP_DIR = ./lib/daisySP diff --git a/src/droplets/droplet.cpp b/src/droplets/droplet.cpp new file mode 100644 index 0000000..dbfc6e0 --- /dev/null +++ b/src/droplets/droplet.cpp @@ -0,0 +1,12 @@ +#include "droplet.h" + +void Droplet::DrawName(DaisyPatch* patch, std::string name) { + int min = 0; + int max = SSD1309_WIDTH; + if (state == DropletState::kLeft) { + max = SSD1309_WIDTH / 2; + } else if (state == DropletState::kRight) { + min = SSD1309_WIDTH / 2; + } + WriteCenteredString(*patch, (min + max) / 2, 0, Font_6x8, name); +} diff --git a/src/droplets/droplet.h b/src/droplets/droplet.h index efbc4ee..dc6d0ba 100644 --- a/src/droplets/droplet.h +++ b/src/droplets/droplet.h @@ -5,6 +5,10 @@ #include "daisy_patch.h" +#include + +#include "../util.h" + using namespace daisy; enum class DropletState {kFull, kLeft, kRight}; @@ -16,6 +20,8 @@ class Droplet { virtual void Control()=0; virtual void Process(float**, float**, size_t)=0; virtual void Draw()=0; + void DrawName(daisy::DaisyPatch*, + std::string); }; #endif // CASCADE_DROPLETS_DROPLET_H_ diff --git a/src/droplets/noise_droplet.cpp b/src/droplets/noise_droplet.cpp index 67fc25d..1d8902b 100644 --- a/src/droplets/noise_droplet.cpp +++ b/src/droplets/noise_droplet.cpp @@ -28,17 +28,5 @@ void NoiseDroplet::Process(float** in, float** out, size_t size) { } void NoiseDroplet::Draw() { - DrawName(patch); -} - - -void NoiseDroplet::DrawName(DaisyPatch* patch) { - int min = 0; - int max = SSD1309_WIDTH; - if (state == DropletState::kLeft) { - max = SSD1309_WIDTH / 2; - } else if (state == DropletState::kRight) { - min = SSD1309_WIDTH / 2; - } - WriteCenteredString(*patch, (min + max) / 2, 0, Font_6x8, "Noise"); + DrawName(patch, "Noise"); } diff --git a/src/droplets/noise_droplet.h b/src/droplets/noise_droplet.h index c51d1bb..4ef697c 100644 --- a/src/droplets/noise_droplet.h +++ b/src/droplets/noise_droplet.h @@ -14,7 +14,6 @@ class NoiseDroplet: public Droplet { DaisyPatch* patch; daisysp::WhiteNoise noise; daisysp::NlFilt filter; - void DrawName(DaisyPatch*); public: NoiseDroplet(DaisyPatch*, float, DropletState); void Control();