Skip to content

Commit 240a07d

Browse files
committed
monosynth1: add serial midi in, add start of display
1 parent e4afe8f commit 240a07d

File tree

4 files changed

+668
-0
lines changed

4 files changed

+668
-0
lines changed

arduino/monosynth1/SynthUI.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef SYNTHUI_H
2+
#define SYNTHUI_H
3+
4+
#include <stdio.h>
5+
#include <stdarg.h>
6+
#include <Adafruit_GFX.h>
7+
8+
#define KEY_NONE 0 // No key presses are detected
9+
#define KEY_UP 1 // Up key is pressed (navigate up through the menu items list, select next value of the digit/char of editable variable, or previous option in select)
10+
#define KEY_RIGHT 2 // Right key is pressed (navigate through the link to another (child) menu page, select next digit/char of editable variable, execute code associated with button)
11+
#define KEY_DOWN 3 // Down key is pressed (navigate down through the menu items list, select previous value of the digit/char of editable variable, or next option in select)
12+
#define KEY_LEFT 4 // Left key is pressed (navigate through the Back button to the previous menu page, select previous digit/char of editable variable)
13+
#define KEY_CANCEL 5 // Cancel key is pressed (navigate to the previous (parent) menu page, exit edit mode without saving the variable, exit context loop if allowed within context's settings)
14+
#define KEY_OK 6 // Ok/Apply key is pressed (toggle bool menu item, enter edit mode of the associated non-bool variable, exit edit mode with saving the variable, execute code associated with button)
15+
16+
17+
class SynthUI {
18+
public:
19+
SynthUI(Adafruit_GFX* adisplay) {
20+
display = adisplay;
21+
}
22+
23+
void set_font(const GFXfont* fnt = NULL) {
24+
display->setFont(fnt);
25+
}
26+
27+
/**
28+
* Print text at a given x,y, using an optionally specified font
29+
*/
30+
void print_text(int x, int y, const char* str, const GFXfont* fnt = NULL) {
31+
if (fnt != NULL) { display->setFont(fnt); }
32+
display->setTextColor(WHITE, 0);
33+
display->setCursor(x, y);
34+
display->print(str);
35+
}
36+
37+
void print_textf(int x, int y, const char* fmt, ...) {
38+
char buf[80];
39+
va_list va;
40+
va_start(va, fmt);
41+
vsnprintf(buf, 80, fmt, va);
42+
va_end(va);
43+
print_text(x, y, buf);
44+
}
45+
46+
/**
47+
* Draw vertical slider with a "thumb" position identifying value
48+
* thumpos ranges 0.0-1.0
49+
*/
50+
void draw_vertical_slider(int x, int y, float thumbpos, int w = 5, int h = 63, int thumbw = 0, int thumbh = 10) {
51+
int ypos = thumbpos * h;
52+
thumbw = (thumbw == 0) ? w : thumbw; // make thumbw same width as slider if not specified
53+
display->drawRect(x, y, w, h, WHITE);
54+
display->fillRect(x, y + ypos, thumbw, thumbh, WHITE);
55+
}
56+
/**
57+
* Draw horizontal slider with a "thumb" position identifying value
58+
* thumpos ranges 0.0-1.0
59+
*/
60+
void draw_horizontal_slider(int x, int y, float thumbpos, int w = 127, int h = 5, int thumbw = 10, int thumbh = 0) {
61+
int xpos = thumbpos * (w - thumbw);
62+
thumbh = (thumbh == 0) ? h : thumbh; // make thumbh same height as slider if not specified
63+
display->drawRect(x, y - h, w, h, WHITE);
64+
display->fillRect(x + xpos, y - h, thumbw, thumbh, WHITE);
65+
}
66+
67+
68+
Adafruit_GFX* display;
69+
};
70+
71+
#endif
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
// Created by https://oleddisplay.squix.ch/ Consider a donation
2+
// In case of problems make sure that you are using the font file with the correct version!
3+
const uint8_t Dialog_bold_12Bitmaps[] PROGMEM = {
4+
5+
// Bitmap Data:
6+
0x00, // ' '
7+
0xDB,0x6D,0x86,0xC0, // '!'
8+
0xAA,0xA0, // '"'
9+
0x12,0x0B,0x1F,0xC4,0x82,0x47,0xF1,0xA0,0xD0,0x48,0x00, // '#'
10+
0x10,0x7C,0xD0,0xF0,0xFC,0x7E,0x1E,0x16,0xFC,0x10,0x10, // '$'
11+
0x71,0x08,0x90,0x8A,0x08,0xE0,0x75,0xC0,0xE2,0x0A,0x21,0x22,0x11,0xC0, // '%'
12+
0x38,0x19,0x06,0x00,0xC0,0x79,0xB7,0x6C,0xF3,0x1C,0x7D,0x80, // '&'
13+
0xA8, // '''
14+
0x73,0x19,0x8C,0x63,0x18,0x63,0x1C, // '('
15+
0xE3,0x18,0x63,0x18,0xC6,0x63,0x38, // ')'
16+
0x22,0xA7,0x1C,0xA8,0x80, // '*'
17+
0x10,0x10,0x10,0xFE,0x10,0x10,0x10, // '+'
18+
0x66,0x48, // ','
19+
0xF7,0x80, // '-'
20+
0xD8, // '.'
21+
0x11,0x88,0x42,0x21,0x08,0xC4,0x00, // '/'
22+
0x38,0x6C,0xC6,0xC6,0xC6,0xC6,0xC6,0x6C,0x38, // '0'
23+
0xF0,0x60,0xC1,0x83,0x06,0x0C,0x18,0xFC, // '1'
24+
0x7C,0x86,0x06,0x06,0x0C,0x18,0x30,0x60,0xFE, // '2'
25+
0x7C,0x86,0x06,0x06,0x3C,0x06,0x06,0x86,0x7C, // '3'
26+
0x1C,0x3C,0x2C,0x4C,0xCC,0x8C,0xFE,0x0C,0x0C, // '4'
27+
0xFC,0xC0,0xC0,0xFC,0x0E,0x06,0x06,0x0E,0xFC, // '5'
28+
0x3C,0x60,0xC0,0xFC,0xC6,0xC6,0xC6,0x46,0x3C, // '6'
29+
0xFE,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60, // '7'
30+
0x7C,0xC6,0xC6,0xC6,0x38,0xC6,0xC6,0xC6,0x7C, // '8'
31+
0x78,0xC4,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0x78, // '9'
32+
0xD8,0x01,0xB0, // ':'
33+
0x66,0x00,0x06,0x64,0x80, // ';'
34+
0x01,0x07,0x9E,0x18,0x07,0x80,0x78,0x04, // '<'
35+
0xFF,0x00,0x3F,0xC0, // '='
36+
0x80,0x78,0x07,0x80,0x61,0xE7,0x82,0x00, // '>'
37+
0xF0,0x61,0x8C,0x61,0x80,0x18,0x60, // '?'
38+
0x1E,0x04,0x31,0x02,0x47,0x29,0x25,0x24,0xA4,0xB4,0x7C,0x40,0x04,0x20,0x7E,0x00, // '@'
39+
0x1C,0x07,0x03,0x60,0xD8,0x36,0x18,0xC7,0xF1,0x8C,0xC1,0x80, // 'A'
40+
0xFC,0xC6,0xC6,0xC6,0xFC,0xC6,0xC6,0xC6,0xFC, // 'B'
41+
0x3E,0x62,0xC0,0xC0,0xC0,0xC0,0xC0,0x62,0x3E, // 'C'
42+
0xFC,0x63,0x30,0xD8,0x6C,0x36,0x1B,0x0D,0x8C,0xFC,0x00, // 'D'
43+
0xFD,0x83,0x06,0x0F,0xD8,0x30,0x60,0xFC, // 'E'
44+
0xFD,0x83,0x06,0x0F,0xD8,0x30,0x60,0xC0, // 'F'
45+
0x3F,0x30,0xB0,0x18,0x0C,0x76,0x1B,0x0C,0xC6,0x3F,0x00, // 'G'
46+
0xC3,0x61,0xB0,0xD8,0x6F,0xF6,0x1B,0x0D,0x86,0xC3,0x00, // 'H'
47+
0xDB,0x6D,0xB6,0xC0, // 'I'
48+
0x31,0x8C,0x63,0x18,0xC6,0x31,0xB8, // 'J'
49+
0xC3,0x31,0x8C,0xC3,0x60,0xF0,0x36,0x0C,0xC3,0x18,0xC3,0x00, // 'K'
50+
0xC1,0x83,0x06,0x0C,0x18,0x30,0x60,0xFC, // 'L'
51+
0xE1,0xDC,0x3B,0xCF,0x69,0x6D,0xED,0x99,0xB3,0x36,0x06,0xC0,0xC0, // 'M'
52+
0xE3,0x71,0xBC,0xDA,0x6D,0xB6,0x5B,0x3D,0x8E,0xC7,0x00, // 'N'
53+
0x3E,0x18,0xCC,0x1B,0x06,0xC1,0xB0,0x6C,0x19,0x8C,0x3E,0x00, // 'O'
54+
0xFC,0xC6,0xC6,0xC6,0xC6,0xFC,0xC0,0xC0,0xC0, // 'P'
55+
0x3E,0x18,0xCC,0x1B,0x06,0xC1,0xB0,0x6C,0x19,0x8C,0x3E,0x01,0x80,0x30, // 'Q'
56+
0xFC,0x63,0x31,0x98,0xCF,0xC6,0x63,0x19,0x8C,0xC3,0x00, // 'R'
57+
0x7C,0xC4,0xC0,0xF0,0x7C,0x0E,0x06,0x86,0xFC, // 'S'
58+
0xFF,0x0C,0x06,0x03,0x01,0x80,0xC0,0x60,0x30,0x18,0x00, // 'T'
59+
0xC3,0x61,0xB0,0xD8,0x6C,0x36,0x1B,0x0D,0x86,0x7E,0x00, // 'U'
60+
0xC1,0x98,0xC6,0x31,0x8C,0x36,0x0D,0x83,0x60,0x70,0x1C,0x00, // 'V'
61+
0xC6,0x36,0x31,0x9B,0xD8,0xDE,0xC6,0x96,0x3C,0xF0,0xE7,0x06,0x18,0x30,0xC0, // 'W'
62+
0xC1,0x98,0xC3,0x60,0xD8,0x1C,0x0D,0x83,0x61,0x8C,0xC1,0x80, // 'X'
63+
0xC3,0x33,0x19,0x87,0x81,0x80,0xC0,0x60,0x30,0x18,0x00, // 'Y'
64+
0xFF,0x01,0x81,0x81,0x81,0x81,0x81,0x81,0x80,0xFF,0x00, // 'Z'
65+
0xF6,0x31,0x8C,0x63,0x18,0xC6,0x3C, // '['
66+
0x86,0x10,0x84,0x10,0x84,0x30,0x80, // '\'
67+
0xF1,0x8C,0x63,0x18,0xC6,0x31,0xBC, // ']'
68+
0x18,0x1E,0x10,0x80, // '^'
69+
0xFC, // '_'
70+
0xC6, // '`'
71+
0x3C,0x46,0x06,0x7E,0xC6,0xC6,0x7E, // 'a'
72+
0xC0,0xC0,0xC0,0xFC,0xC6,0xC6,0xC6,0xC6,0xC6,0xFC, // 'b'
73+
0x38,0xCB,0x06,0x0C,0x0C,0x8E,0x00, // 'c'
74+
0x06,0x06,0x06,0x7E,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E, // 'd'
75+
0x3C,0x64,0xC6,0xFE,0xC0,0x62,0x3C, // 'e'
76+
0x39,0x86,0x3E,0x61,0x86,0x18,0x61,0x80, // 'f'
77+
0x7E,0xEE,0xC6,0xC6,0xC6,0xCE,0x7E,0x06,0x46,0x3C, // 'g'
78+
0xC0,0xC0,0xC0,0xFC,0xE6,0xC6,0xC6,0xC6,0xC6,0xC6, // 'h'
79+
0xD8,0x6D,0xB6,0xD8, // 'i'
80+
0x66,0x06,0x66,0x66,0x66,0x66,0xC0, // 'j'
81+
0xC0,0xC0,0xC0,0xCC,0xD8,0xF0,0xF0,0xD8,0xCC,0xC6, // 'k'
82+
0xDB,0x6D,0xB6,0xD8, // 'l'
83+
0xFF,0x99,0x9B,0x33,0x66,0x6C,0xCD,0x99,0xB3,0x30, // 'm'
84+
0xFC,0xE6,0xC6,0xC6,0xC6,0xC6,0xC6, // 'n'
85+
0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C, // 'o'
86+
0xFC,0xC6,0xC6,0xC6,0xC6,0xC6,0xFC,0xC0,0xC0,0xC0, // 'p'
87+
0x7E,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x06,0x06, // 'q'
88+
0xFB,0x8C,0x30,0xC3,0x0C,0x00, // 'r'
89+
0x79,0x8B,0x03,0xC0,0xD1,0x9E,0x00, // 's'
90+
0x61,0x8F,0x98,0x61,0x86,0x18,0x78, // 't'
91+
0xC6,0xC6,0xC6,0xC6,0xC6,0xCE,0x7E, // 'u'
92+
0xC6,0xC6,0x6C,0x6C,0x6C,0x38,0x38, // 'v'
93+
0xCC,0xD9,0x9B,0x7B,0x2F,0x47,0x38,0xE7,0x0C,0xC0, // 'w'
94+
0xC6,0x6C,0x38,0x38,0x38,0x6C,0xC6, // 'x'
95+
0xC6,0xC6,0x6C,0x6C,0x3C,0x38,0x18,0x18,0x30,0x60, // 'y'
96+
0xFC,0x18,0x61,0x86,0x18,0x3F,0x00, // 'z'
97+
0x1C,0x60,0xC1,0x83,0x1C,0x0C,0x18,0x30,0x60,0x70, // '{'
98+
0xAA,0xAA,0xAA, // '|'
99+
0xE0,0x60,0xC1,0x83,0x03,0x8C,0x18,0x30,0x63,0x80 // '}'
100+
};
101+
const GFXglyph Dialog_bold_12Glyphs[] PROGMEM = {
102+
// bitmapOffset, width, height, xAdvance, xOffset, yOffset
103+
{ 0, 2, 1, 5, 0, -1 }, // ' '
104+
{ 1, 3, 9, 6, 2, -9 }, // '!'
105+
{ 5, 4, 3, 7, 1, -9 }, // '"'
106+
{ 7, 9, 9, 11, 1, -9 }, // '#'
107+
{ 18, 8, 11, 9, 1, -9 }, // '$'
108+
{ 29, 12, 9, 13, 1, -9 }, // '%'
109+
{ 43, 10, 9, 11, 1, -9 }, // '&'
110+
{ 55, 2, 3, 5, 1, -9 }, // '''
111+
{ 56, 5, 11, 6, 1, -10 }, // '('
112+
{ 63, 5, 11, 6, 0, -10 }, // ')'
113+
{ 70, 6, 6, 7, 1, -9 }, // '*'
114+
{ 75, 8, 7, 11, 1, -7 }, // '+'
115+
{ 82, 4, 4, 6, 0, -2 }, // ','
116+
{ 84, 5, 2, 6, 1, -4 }, // '-'
117+
{ 86, 3, 2, 6, 1, -2 }, // '.'
118+
{ 87, 5, 10, 5, 0, -9 }, // '/'
119+
{ 94, 8, 9, 9, 1, -9 }, // '0'
120+
{ 103, 7, 9, 9, 1, -9 }, // '1'
121+
{ 111, 8, 9, 9, 1, -9 }, // '2'
122+
{ 120, 8, 9, 9, 1, -9 }, // '3'
123+
{ 129, 8, 9, 9, 1, -9 }, // '4'
124+
{ 138, 8, 9, 9, 1, -9 }, // '5'
125+
{ 147, 8, 9, 9, 1, -9 }, // '6'
126+
{ 156, 8, 9, 9, 1, -9 }, // '7'
127+
{ 165, 8, 9, 9, 1, -9 }, // '8'
128+
{ 174, 8, 9, 9, 1, -9 }, // '9'
129+
{ 183, 3, 7, 6, 1, -7 }, // ':'
130+
{ 186, 4, 9, 6, 0, -7 }, // ';'
131+
{ 191, 9, 7, 11, 1, -7 }, // '<'
132+
{ 199, 9, 3, 11, 1, -5 }, // '='
133+
{ 203, 9, 7, 11, 1, -7 }, // '>'
134+
{ 211, 6, 9, 8, 1, -9 }, // '?'
135+
{ 218, 11, 11, 13, 1, -9 }, // '@'
136+
{ 234, 10, 9, 10, 0, -9 }, // 'A'
137+
{ 246, 8, 9, 10, 1, -9 }, // 'B'
138+
{ 255, 8, 9, 10, 1, -9 }, // 'C'
139+
{ 264, 9, 9, 11, 1, -9 }, // 'D'
140+
{ 275, 7, 9, 9, 1, -9 }, // 'E'
141+
{ 283, 7, 9, 9, 1, -9 }, // 'F'
142+
{ 291, 9, 9, 11, 1, -9 }, // 'G'
143+
{ 302, 9, 9, 11, 1, -9 }, // 'H'
144+
{ 313, 3, 9, 5, 1, -9 }, // 'I'
145+
{ 317, 5, 11, 5, -1, -9 }, // 'J'
146+
{ 324, 10, 9, 10, 1, -9 }, // 'K'
147+
{ 336, 7, 9, 9, 1, -9 }, // 'L'
148+
{ 344, 11, 9, 13, 1, -9 }, // 'M'
149+
{ 357, 9, 9, 11, 1, -9 }, // 'N'
150+
{ 368, 10, 9, 12, 1, -9 }, // 'O'
151+
{ 380, 8, 9, 10, 1, -9 }, // 'P'
152+
{ 389, 10, 11, 11, 1, -9 }, // 'Q'
153+
{ 403, 9, 9, 10, 1, -9 }, // 'R'
154+
{ 414, 8, 9, 10, 1, -9 }, // 'S'
155+
{ 423, 9, 9, 9, 0, -9 }, // 'T'
156+
{ 434, 9, 9, 11, 1, -9 }, // 'U'
157+
{ 445, 10, 9, 10, 0, -9 }, // 'V'
158+
{ 457, 13, 9, 15, 1, -9 }, // 'W'
159+
{ 472, 10, 9, 10, 0, -9 }, // 'X'
160+
{ 484, 9, 9, 9, 0, -9 }, // 'Y'
161+
{ 495, 9, 9, 11, 1, -9 }, // 'Z'
162+
{ 506, 5, 11, 6, 1, -10 }, // '['
163+
{ 513, 5, 10, 5, 0, -9 }, // '\'
164+
{ 520, 5, 11, 6, 0, -10 }, // ']'
165+
{ 527, 9, 3, 11, 1, -9 }, // '^'
166+
{ 531, 7, 1, 7, 0, 2 }, // '_'
167+
{ 532, 4, 2, 7, 1, -10 }, // '`'
168+
{ 533, 8, 7, 10, 1, -7 }, // 'a'
169+
{ 540, 8, 10, 10, 1, -10 }, // 'b'
170+
{ 550, 7, 7, 8, 1, -7 }, // 'c'
171+
{ 557, 8, 10, 10, 1, -10 }, // 'd'
172+
{ 567, 8, 7, 10, 1, -7 }, // 'e'
173+
{ 574, 6, 10, 6, 0, -10 }, // 'f'
174+
{ 582, 8, 10, 10, 1, -7 }, // 'g'
175+
{ 592, 8, 10, 10, 1, -10 }, // 'h'
176+
{ 602, 3, 10, 5, 1, -10 }, // 'i'
177+
{ 606, 4, 13, 5, 0, -10 }, // 'j'
178+
{ 613, 8, 10, 9, 1, -10 }, // 'k'
179+
{ 623, 3, 10, 5, 1, -10 }, // 'l'
180+
{ 627, 11, 7, 13, 1, -7 }, // 'm'
181+
{ 637, 8, 7, 10, 1, -7 }, // 'n'
182+
{ 644, 8, 7, 10, 1, -7 }, // 'o'
183+
{ 651, 8, 10, 10, 1, -7 }, // 'p'
184+
{ 661, 8, 10, 10, 1, -7 }, // 'q'
185+
{ 671, 6, 7, 7, 1, -7 }, // 'r'
186+
{ 677, 7, 7, 9, 1, -7 }, // 's'
187+
{ 684, 6, 9, 7, 0, -9 }, // 't'
188+
{ 691, 8, 7, 10, 1, -7 }, // 'u'
189+
{ 698, 8, 7, 8, 0, -7 }, // 'v'
190+
{ 705, 11, 7, 13, 1, -7 }, // 'w'
191+
{ 715, 8, 7, 8, 0, -7 }, // 'x'
192+
{ 722, 8, 10, 9, 0, -7 }, // 'y'
193+
{ 732, 7, 7, 9, 1, -7 }, // 'z'
194+
{ 739, 7, 11, 10, 1, -10 }, // '{'
195+
{ 749, 2, 12, 5, 2, -9 }, // '|'
196+
{ 752, 7, 11, 10, 1, -10 } // '}'
197+
};
198+
const GFXfont Dialog_bold_12 PROGMEM = {
199+
(uint8_t *)Dialog_bold_12Bitmaps,(GFXglyph *)Dialog_bold_12Glyphs,0x20, 0x7E, 15};

0 commit comments

Comments
 (0)