Skip to content

Commit

Permalink
Enhancements to the UI of ProbMeloD: Make the cursor bigger when not …
Browse files Browse the repository at this point in the history
…editing, flash the dotted line when editing, and display the note and value when changing a probability
  • Loading branch information
benirose committed Nov 17, 2022
1 parent 0f08b21 commit dae365c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
37 changes: 33 additions & 4 deletions software/o_c_REV/HEM_ProbabilityMelody.ino
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public:
if (pulse_animation > 0) {
pulse_animation--;
}

// animate value changes
if (value_animation > 0) {
value_animation--;
}
}

void View() {
Expand All @@ -93,6 +98,7 @@ public:

void OnButtonPress() {
isEditing = !isEditing;
ResetCursor();
}

void OnEncoderMove(int direction) {
Expand All @@ -105,6 +111,7 @@ public:
if (cursor < 12) {
// editing note probability
weights[cursor] = constrain(weights[cursor] += direction, 0, HEM_PROB_MEL_MAX_WEIGHT);
value_animation = HEMISPHERE_CURSOR_TICKS;
} else {
// editing scaling
if (cursor == 12) down = constrain(down += direction, 1, up);
Expand Down Expand Up @@ -175,6 +182,10 @@ private:
ProbLoopLinker *loop_linker = loop_linker->get();

int pulse_animation = 0;
int value_animation = 0;
const uint8_t x[12] = {2, 7, 10, 15, 18, 26, 31, 34, 39, 42, 47, 50};
const uint8_t p[12] = {0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0};
const char* n[12] = {"C", "C", "D", "D", "E", "F", "F", "G", "G", "A", "A", "B"};

int GetNextWeightedPitch() {
int total_weights = 0;
Expand Down Expand Up @@ -226,8 +237,6 @@ private:
}

void DrawParams() {
uint8_t x[12] = {2, 7, 10, 15, 18, 26, 31, 34, 39, 42, 47, 50};
uint8_t p[12] = {0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0};
int note = pitch % 12;
int octave = (pitch - 60) / 12;

Expand All @@ -240,7 +249,12 @@ private:
gfxRect(xOffset - 1, yOffset, 3, 10);
} else {
if (isEditing && i == cursor) {
gfxLine(xOffset, yOffset, xOffset, yOffset + 10);
// blink line when editing
if (CursorBlink()) {
gfxLine(xOffset, yOffset, xOffset, yOffset + 10);
} else {
gfxDottedLine(xOffset, yOffset, xOffset, yOffset + 10);
}
} else {
gfxDottedLine(xOffset, yOffset, xOffset, yOffset + 10);
}
Expand All @@ -250,7 +264,10 @@ private:

// cursor for keys
if (!isEditing) {
if (cursor < 12) gfxCursor(x[cursor] - 1, p[cursor] ? 25 : 60, 6);
if (cursor < 12) {
gfxCursor(x[cursor] - 1, p[cursor] ? 24 : 60, p[cursor] ? 5 : 6);
gfxCursor(x[cursor] - 1, p[cursor] ? 25 : 61, p[cursor] ? 5 : 6);
}
if (cursor == 12) gfxCursor(7, 23, 22);
if (cursor == 13) gfxCursor(37, 23, 22);
}
Expand Down Expand Up @@ -279,6 +296,18 @@ private:
// gfxRect(x[note] + (p[note] ? 0 : 1), p[note] ? 29 : 54, 3, 2);
gfxRect(58, 54 - (octave * 6), 3, 3);
}

if (value_animation > 0 && cursor < 12) {
gfxRect(1, 15, 60, 10);
gfxInvert(1, 15, 60, 10);

gfxPrint(18, 16, n[cursor]);
if (p[cursor]) {
gfxPrint(24, 16, "#");
}
gfxPrint(34, 16, weights[cursor]);
gfxInvert(1, 15, 60, 10);
}
}
};

Expand Down
5 changes: 4 additions & 1 deletion software/o_c_REV/HEM_ScaleDuet.ino
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ private:
for (uint8_t i = 0; i < 12; i++)
{
if ((mask[scale] >> i) & 0x01) gfxInvert(x[i], (p[i] ? 37 : 51), 4 - p[i], 4 - p[i]);
if (i == (cursor - (scale * 12))) gfxCursor(x[i] - 1, p[i] ? 25 : 60, 6);
if (i == (cursor - (scale * 12))) {
gfxCursor(x[i] - 1, p[i] ? 24 : 60, p[i] ? 5 : 6);
gfxCursor(x[i] - 1, p[i] ? 25 : 61, p[i] ? 5 : 6);
}
}

// If C is selcted, display a selector on the higher C, too
Expand Down

0 comments on commit dae365c

Please sign in to comment.