Skip to content

Commit

Permalink
Implement KeyRange using 20pt font.
Browse files Browse the repository at this point in the history
Test Settings>Defaults>Key
  • Loading branch information
todd-gochenour committed Jan 13, 2025
1 parent d50cb70 commit c59b93d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 14 deletions.
41 changes: 41 additions & 0 deletions src/deluge/gui/fonts/fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,13 @@ const uint8_t font_metric_bold_9px[] =
0b00110000, 0b00000000,
0b00111000, 0b00000000,
0b00011000, 0b00000000,

0b11111111, 0b00000001, // flat glpyh
0b11111111, 0b00000001,
0b10011000, 0b00000001,
0b10011000, 0b00000001,
0b11111000, 0b00000001,
0b11110000, 0b00000000,
};


Expand Down Expand Up @@ -1054,6 +1061,7 @@ const lv_font_glyph_dsc_t font_metric_bold_9px_desc[] =
{.w_px = 2, .glyph_index = 762}, // |
{.w_px = 5, .glyph_index = 766}, // }
{.w_px = 6, .glyph_index = 776}, // ~
{.w_px = 6, .glyph_index = 788}, // flat glpyh
};


Expand Down Expand Up @@ -1787,6 +1795,19 @@ const uint8_t font_metric_bold_13px[] = {
0b10000000, 0b00000001,
0b11000000, 0b00000001,
0b11000000, 0b00000000,

0b11111111, 0b00011111, // flat glyph
0b11111111, 0b00011111,
0b11111111, 0b00011111,
0b11100000, 0b00011100,
0b11100000, 0b00011100,
0b11100000, 0b00011100,
0b11100000, 0b00011100,
0b11100000, 0b00011111,
0b11000000, 0b00001111,
0b10000000, 0b00000111,
0b00000000, 0b00000000,

};


Expand Down Expand Up @@ -1861,6 +1882,7 @@ const lv_font_glyph_dsc_t font_metric_bold_13px_desc[] = {
{.w_px = 4, .glyph_index = 1258}, // |
{.w_px = 7, .glyph_index = 1266}, // }
{.w_px = 8, .glyph_index = 1280}, // ~
{.w_px = 10, .glyph_index = 1296}, // flat glyph
};


Expand Down Expand Up @@ -2938,6 +2960,24 @@ const uint8_t font_metric_bold_20px[] = {
0b00000000, 0b00111110, 0b00000000,
0b00000000, 0b00011110, 0b00000000,
0b00000000, 0b00000010, 0b00000000,

0b11111111, 0b11111111, 0b00001111, // flat glpyh
0b11111111, 0b11111111, 0b00001111,
0b11111111, 0b11111111, 0b00001111,
0b11111111, 0b11111111, 0b00001111,
0b11111111, 0b11111111, 0b00001111,
0b00000000, 0b00001111, 0b00001111,
0b00000000, 0b00001111, 0b00001111,
0b00000000, 0b00001111, 0b00001111,
0b00000000, 0b00001111, 0b00001111,
0b00000000, 0b00001111, 0b00001111,
0b00000000, 0b10011111, 0b00001111,
0b00000000, 0b11111111, 0b00001111,
0b00000000, 0b11111110, 0b00000111,
0b00000000, 0b11111110, 0b00000111,
0b00000000, 0b11111100, 0b00000011,
0b00000000, 0b11111000, 0b00000001,

};


Expand Down Expand Up @@ -3012,4 +3052,5 @@ const lv_font_glyph_dsc_t font_metric_bold_20px_desc[] = {
{.w_px = 5, .glyph_index = 2883}, // |
{.w_px = 12, .glyph_index = 2898}, // }
{.w_px = 12, .glyph_index = 2934}, // ~
{.w_px = 16, .glyph_index = 2970}, // flat glyph
};
37 changes: 26 additions & 11 deletions src/deluge/gui/menu_item/key_range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ void KeyRange::selectEncoderAction(int32_t offset) {

void KeyRange::getText(char* buffer, int32_t* getLeftLength, int32_t* getRightLength, bool mayShowJustOne) {

*(buffer++) = noteLetter[lower];
int32_t leftLength = 1;

int32_t leftLength = 0;
if (noteIsAltered[lower]) {
*(buffer++) = (display->haveOLED()) ? '#' : '.';
if (display->haveOLED()) {
leftLength++;
uint8_t accidental = majorAccidental[lower];
if (accidental == '#') {
*(buffer++) = noteLetter[lower];
}
else {
*(buffer++) = noteLetter[lower + 1];
}
*(buffer++) = accidental;
leftLength += 2;
}
else {
*(buffer++) = noteLetter[lower];
++leftLength;
}

if (getLeftLength) {
Expand All @@ -82,13 +89,21 @@ void KeyRange::getText(char* buffer, int32_t* getLeftLength, int32_t* getRightLe

*(buffer++) = '-';

*(buffer++) = noteLetter[upper];
int32_t rightLength = 1;
int32_t rightLength = 0;
if (noteIsAltered[upper]) {
*(buffer++) = (display->haveOLED()) ? '#' : '.';
if (display->haveOLED()) {
rightLength++;
uint8_t accidental = majorAccidental[upper];
if (accidental == '#') {
*(buffer++) = noteLetter[upper];
}
else {
*(buffer++) = noteLetter[upper + 1];
}
*(buffer++) = accidental;
rightLength += 2;
}
else {
*(buffer++) = noteLetter[upper];
++rightLength;
}

*buffer = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/deluge/model/scale/preset_scales.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ void noteCodeToString(int32_t noteCode, char* buffer, int32_t* getLengthWithoutD
if (noteIsAltered[n]) { // actually: if code is a black key on the piano?
if ((accidental == '#')) {
*thisChar++ = noteLetter[n];
*thisChar = accidental; // display->haveOLED() ? accidental : '.';
*thisChar = accidental;
}
else {
*thisChar++ = noteLetter[n + 1];
*thisChar = accidental; // display->haveOLED() ? accidental : '.';
*thisChar = accidental;
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/deluge/model/scale/preset_scales.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const uint8_t getScaleMode(Scale scale);
/* Calculate relative major key accidental preference */
// C Db D Eb E F F# G Ab A Bb B
const uint8_t majorAccidental[12] = {129, 129, '#', 129, '#', 129, '#', '#', 129, '#', 129, '#'};
const uint8_t noteLetter[13] = {'C', 'C', 'D', 'D', 'E', 'F', 'F', 'G', 'G', 'A', 'A', 'B', 'C'}; // 1 more for Cb
const uint8_t noteLetter[12] = {'C', 'C', 'D', 'D', 'E', 'F', 'F', 'G', 'G', 'A', 'A', 'B'};
const uint8_t noteIsAltered[12] = {0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0};
const uint8_t getAccidental(int32_t rootNoteCode, Scale scale);
void noteCodeToString(int32_t noteCode, char* buffer, int32_t* getLengthWithoutDot = nullptr,
Expand Down

0 comments on commit c59b93d

Please sign in to comment.