mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-07-05 03:32:02 +00:00
Titles adjust to droplet size
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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_
|
||||
|
@ -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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user