diff --git a/src/droplets/droplet.cpp b/src/droplets/droplet.cpp index dbfc6e0..6908a69 100644 --- a/src/droplets/droplet.cpp +++ b/src/droplets/droplet.cpp @@ -1,12 +1,17 @@ #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); + WriteCenteredString(*patch, (screen_min + screen_max) / 2, 0, + Font_6x8, name); +} + +void Droplet::UpdateState(DropletState m_state) { + state = m_state; + screen_min = 0; + screen_max = SSD1309_WIDTH; + if (state == DropletState::kLeft) { + screen_max = SSD1309_WIDTH / 2; + } else if (state == DropletState::kRight) { + screen_min = SSD1309_WIDTH / 2; + } } diff --git a/src/droplets/droplet.h b/src/droplets/droplet.h index dc6d0ba..e8536ad 100644 --- a/src/droplets/droplet.h +++ b/src/droplets/droplet.h @@ -20,8 +20,12 @@ class Droplet { virtual void Control()=0; virtual void Process(float**, float**, size_t)=0; virtual void Draw()=0; + const int kTitleHeight = 8; + int screen_min; + int screen_max; void DrawName(daisy::DaisyPatch*, std::string); + void UpdateState(DropletState); }; #endif // CASCADE_DROPLETS_DROPLET_H_ diff --git a/src/droplets/noise_droplet.cpp b/src/droplets/noise_droplet.cpp index 1d8902b..0cc86f2 100644 --- a/src/droplets/noise_droplet.cpp +++ b/src/droplets/noise_droplet.cpp @@ -6,7 +6,7 @@ NoiseDroplet::NoiseDroplet(DaisyPatch* m_patch, noise.Init(); filter.Init(); patch = m_patch; - state = m_state; + UpdateState(m_state); } void NoiseDroplet::Control() {} @@ -28,5 +28,10 @@ void NoiseDroplet::Process(float** in, float** out, size_t size) { } void NoiseDroplet::Draw() { + for (int h = 0; h < kTitleHeight; h++) { + for (int w = screen_min; w < screen_max; w++) { + patch->display.DrawPixel(w, h, rand() % 15 == 0); + } + } DrawName(patch, "Noise"); } diff --git a/src/main.cpp b/src/main.cpp index 8ade0d0..9bb1376 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,8 +56,8 @@ void ProcessOled() { if (menu.InMenu()) { menu.ProcessMenuOled(); } else { - droplet->Draw(); WriteString(patch, 0, 0, Font_6x8, menu.SelectedName()); + droplet->Draw(); } patch.display.Update(); }