DrawName moved to Droplets

This commit is contained in:
Christian Colglazier 2020-09-14 15:15:10 -04:00
parent bbe0dd00f0
commit 03c87b94c6
5 changed files with 21 additions and 15 deletions

View File

@ -1,6 +1,7 @@
TARGET = cascade 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 LIBDAISY_DIR = ./lib/libDaisy
DAISYSP_DIR = ./lib/daisySP DAISYSP_DIR = ./lib/daisySP

12
src/droplets/droplet.cpp Normal file
View File

@ -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);
}

View File

@ -5,6 +5,10 @@
#include "daisy_patch.h" #include "daisy_patch.h"
#include <string>
#include "../util.h"
using namespace daisy; using namespace daisy;
enum class DropletState {kFull, kLeft, kRight}; enum class DropletState {kFull, kLeft, kRight};
@ -16,6 +20,8 @@ class Droplet {
virtual void Control()=0; virtual void Control()=0;
virtual void Process(float**, float**, size_t)=0; virtual void Process(float**, float**, size_t)=0;
virtual void Draw()=0; virtual void Draw()=0;
void DrawName(daisy::DaisyPatch*,
std::string);
}; };
#endif // CASCADE_DROPLETS_DROPLET_H_ #endif // CASCADE_DROPLETS_DROPLET_H_

View File

@ -28,17 +28,5 @@ void NoiseDroplet::Process(float** in, float** out, size_t size) {
} }
void NoiseDroplet::Draw() { void NoiseDroplet::Draw() {
DrawName(patch); DrawName(patch, "Noise");
}
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");
} }

View File

@ -14,7 +14,6 @@ class NoiseDroplet: public Droplet {
DaisyPatch* patch; DaisyPatch* patch;
daisysp::WhiteNoise noise; daisysp::WhiteNoise noise;
daisysp::NlFilt filter; daisysp::NlFilt filter;
void DrawName(DaisyPatch*);
public: public:
NoiseDroplet(DaisyPatch*, float, DropletState); NoiseDroplet(DaisyPatch*, float, DropletState);
void Control(); void Control();