Skip to content

Commit b9b6489

Browse files
committed
working on arduino gui
1 parent 6fd22b6 commit b9b6489

File tree

8 files changed

+1147
-26
lines changed

8 files changed

+1147
-26
lines changed

arduino/hwtest/hwtest1/hwtest1.ino

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,26 @@
77
#include <TouchyTouch.h>
88
#include <Smooth.h>
99

10-
const int sw_pin = 28;
11-
const int knobB_pin = 27;
12-
const int knobA_pin = 26;
13-
const int led_pin = 25; // regular LED, not neopixel
14-
const int pico_pwr_pin = 23; // HIGH = improved ripple (lower noise) but less efficient
15-
const int i2s_data_pin = 22;
16-
const int i2s_lclk_pin = 21;
17-
const int i2s_bclk_pin = 20;
18-
const int i2c_scl_pin = 19;
19-
const int i2c_sda_pin = 18;
20-
const int uart_rx_pin = 17;
21-
const int uart_tx_pin = 16;
10+
#define sw_pin 28
11+
#define knobB_pin 27
12+
#define knobA_pin 26
13+
#define led_pin 25 // regular LED, not neopixel
14+
#define pico_pwr_pin 23 // HIGH = improved ripple (lower noise) but less efficient
15+
#define i2s_data_pin 22
16+
#define i2s_lclk_pin 21
17+
#define i2s_bclk_pin 20
18+
#define i2c_scl_pin 19
19+
#define i2c_sda_pin 18
20+
#define uart_rx_pin 17
21+
#define uart_tx_pin 16
22+
2223
const int touch_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
23-
const int touch_count = sizeof(touch_pins) / sizeof(int);
24-
const int touch_threshold_adjust = 100;
24+
#define touch_count = sizeof(touch_pins) / sizeof(int);
25+
#define touch_threshold_adjust = 100;
2526
// display parameters
26-
const int oled_i2c_addr = 0x3C;
27-
const int dw = 128;
28-
const int dh = 64;
27+
#define oled_i2c_addr = 0x3C;
28+
#define dw = 128;
29+
#define dh = 64;
2930

3031
TouchyTouch touches[touch_count];
3132
Bounce2::Button button;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#ifndef SYNTHUI_H
2+
#define SYNTHUI_H
3+
4+
#include <Adafruit_GFX.h>
5+
6+
#define KEY_NONE 0 // No key presses are detected
7+
#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)
8+
#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)
9+
#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)
10+
#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)
11+
#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)
12+
#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)
13+
14+
class Param {
15+
public:
16+
Param(const char* aname, float aval, float aminval = 0, float amaxval = 255, const char* afmt = "%.0f") {
17+
name = aname;
18+
val = aval;
19+
minval = aminval;
20+
maxval = amaxval;
21+
fmt = afmt;
22+
}
23+
float percent() {
24+
return (val - minval) / (maxval - minval);
25+
}
26+
void set_percent(float pct) {
27+
val = pct * (maxval - minval) + minval;
28+
}
29+
30+
const char* name;
31+
float val;
32+
float minval;
33+
float maxval;
34+
const char* fmt;
35+
};
36+
37+
class SynthUI {
38+
public:
39+
SynthUI(Adafruit_GFX* adisplay) {
40+
display = adisplay;
41+
}
42+
43+
44+
void print_text(int x, int y, const char* str, const GFXfont *fnt = NULL) {
45+
if(fnt!=NULL) { display->setFont(fnt); }
46+
display->setTextColor(WHITE, 0);
47+
display->setCursor(x, y);
48+
display->print(str);
49+
}
50+
51+
/**
52+
* Draw vertical slider with a "thumb" position identifying value
53+
* thumpos ranges 0.0-1.0
54+
*/
55+
void draw_vertical_slider(int x, int y, float thumbpos, int w = 5, int h = 63, int thumbw = 5, int thumbh = 10) {
56+
int ypos = thumbpos * h;
57+
display->drawRect(x, y, w, h, WHITE); // right side scroll bar
58+
display->fillRect(x, y + ypos, thumbw, thumbh, WHITE); // FIXME
59+
}
60+
61+
62+
Adafruit_GFX* display;
63+
};
64+
65+
#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_10Bitmaps[] PROGMEM = {
4+
5+
// Bitmap Data:
6+
0x00, // ' '
7+
0xDB,0x61,0xB0, // '!'
8+
0xAA,0xA0, // '"'
9+
0x14,0x24,0x7E,0x28,0xFC,0x48,0x50, // '#'
10+
0x21,0xEA,0x3C,0x78,0xAF,0x08, // '$'
11+
0x62,0x25,0x09,0x41,0xAC,0x14,0x85,0x22,0x30, // '%'
12+
0x38,0x30,0x18,0x0E,0x2D,0xF6,0x71,0xEC, // '&'
13+
0xA8, // '''
14+
0x64,0xCC,0xCC,0xC4,0x60, // '('
15+
0xC4,0x66,0x66,0x64,0xC0, // ')'
16+
0x22,0xA7,0x1C,0xA8,0x80, // '*'
17+
0x10,0x10,0x10,0xFE,0x10,0x10,0x10, // '+'
18+
0xDA,0x00, // ','
19+
0xE0, // '-'
20+
0xD8, // '.'
21+
0x11,0x08,0x44,0x21,0x10, // '/'
22+
0x79,0x9B,0x36,0x6C,0xD9,0x9E,0x00, // '0'
23+
0xF0,0x60,0xC1,0x83,0x06,0x3F,0x00, // '1'
24+
0xF8,0x18,0x30,0xC3,0x0C,0x3F,0x00, // '2'
25+
0xF8,0x18,0x33,0xC0,0xC1,0xBE,0x00, // '3'
26+
0x18,0x71,0x64,0xCF,0xC3,0x06,0x00, // '4'
27+
0xF9,0x83,0xE0,0x60,0xC1,0xBE,0x00, // '5'
28+
0x3C,0x83,0xE6,0x6C,0xD9,0x9E,0x00, // '6'
29+
0xFC,0x18,0x60,0xC3,0x06,0x18,0x00, // '7'
30+
0x79,0x9B,0x31,0x8C,0xD9,0x9E,0x00, // '8'
31+
0x79,0x9B,0x36,0x67,0xC1,0x3C,0x00, // '9'
32+
0xD8,0x6C, // ':'
33+
0xD8,0x6D,0x00, // ';'
34+
0x04,0x73,0x87,0x03,0x80,0x80, // '<'
35+
0xFC,0x03,0xF0, // '='
36+
0x80,0xE0,0x70,0xE7,0x10,0x00, // '>'
37+
0xF1,0x9C,0xC0,0x31,0x80, // '?'
38+
0x3E,0x18,0x4D,0xEA,0x8A,0xA2,0xA8,0xAD,0xF1,0x88,0x3C,0x00, // '@'
39+
0x18,0x1E,0x0F,0x0C,0xC7,0xE3,0x33,0x0C, // 'A'
40+
0xF9,0x9B,0x37,0xCC,0xD9,0xBE,0x00, // 'B'
41+
0x3C,0xCB,0x06,0x0C,0x0C,0x8F,0x00, // 'C'
42+
0xF8,0xCC,0xC6,0xC6,0xC6,0xCC,0xF8, // 'D'
43+
0xFB,0x0C,0x3E,0xC3,0x0F,0x80, // 'E'
44+
0xFB,0x0C,0x3E,0xC3,0x0C,0x00, // 'F'
45+
0x3E,0x62,0xC0,0xCE,0xC6,0x66,0x3E, // 'G'
46+
0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6, // 'H'
47+
0xDB,0x6D,0xB0, // 'I'
48+
0x66,0x66,0x66,0x66,0xC0, // 'J'
49+
0xCC,0xD8,0xF0,0xE0,0xF0,0xD8,0xCC, // 'K'
50+
0xC3,0x0C,0x30,0xC3,0x0F,0x80, // 'L'
51+
0xC3,0x73,0xB9,0xDB,0x6D,0xB6,0x1B,0x0C, // 'M'
52+
0xE6,0xE6,0xD6,0xD6,0xCE,0xCE,0xC6, // 'N'
53+
0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C, // 'O'
54+
0xF9,0x9B,0x36,0x6F,0x98,0x30,0x00, // 'P'
55+
0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x0C, // 'Q'
56+
0xF8,0xCC,0xCC,0xCC,0xF8,0xCC,0xC6, // 'R'
57+
0x7D,0x8B,0x03,0xC0,0xD1,0xBE,0x00, // 'S'
58+
0xFC,0x60,0xC1,0x83,0x06,0x0C,0x00, // 'T'
59+
0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C, // 'U'
60+
0xC3,0x33,0x19,0x8C,0xC3,0xC1,0xE0,0x60, // 'V'
61+
0xCC,0xD9,0x99,0x32,0x3F,0xC7,0x38,0x66,0x0C,0xC0, // 'W'
62+
0xC6,0x6C,0x28,0x38,0x28,0x6C,0xC6, // 'X'
63+
0xC3,0x33,0x0F,0x03,0x01,0x80,0xC0,0x60, // 'Y'
64+
0xFC,0x18,0x61,0x86,0x18,0x3F,0x00, // 'Z'
65+
0xEC,0xCC,0xCC,0xCC,0xE0, // '['
66+
0x82,0x10,0x82,0x10,0x82, // '\'
67+
0xE6,0x66,0x66,0x66,0xE0, // ']'
68+
0x30,0xF3,0x30, // '^'
69+
0xF8, // '_'
70+
0x42, // '`'
71+
0xF8,0x19,0xF6,0x6F,0xC0, // 'a'
72+
0xC1,0x83,0x07,0xCC,0xD9,0xB3,0x7C, // 'b'
73+
0x7B,0x0C,0x30,0x78, // 'c'
74+
0x0C,0x18,0x33,0xEC,0xD9,0xB3,0x3E, // 'd'
75+
0x79,0x9B,0xF6,0x07,0xC0, // 'e'
76+
0x39,0x86,0x3E,0x61,0x86,0x18, // 'f'
77+
0x7D,0x9B,0x36,0x67,0xC1,0x9E,0x00, // 'g'
78+
0xC1,0x83,0x07,0xCC,0xD9,0xB3,0x66, // 'h'
79+
0xD8,0x6D,0xB6, // 'i'
80+
0x66,0x06,0x66,0x66,0x6C, // 'j'
81+
0xC1,0x83,0x06,0x6D,0x9E,0x36,0x66, // 'k'
82+
0xDB,0x6D,0xB6, // 'l'
83+
0xFF,0x99,0x9B,0x33,0x66,0x6C,0xCC, // 'm'
84+
0xF9,0x9B,0x36,0x6C,0xC0, // 'n'
85+
0x79,0x9B,0x36,0x67,0x80, // 'o'
86+
0xF9,0x9B,0x36,0x6F,0x98,0x30,0x00, // 'p'
87+
0x7D,0x9B,0x36,0x67,0xC1,0x83,0x00, // 'q'
88+
0xF6,0x31,0x8C,0x00, // 'r'
89+
0xFB,0x0F,0x86,0xF0, // 's'
90+
0x61,0x8F,0x98,0x61,0x87,0x80, // 't'
91+
0xCD,0x9B,0x36,0x67,0xC0, // 'u'
92+
0xCD,0x99,0x23,0xC3,0x00, // 'v'
93+
0xDB,0x6D,0x9F,0x8C,0xC6,0x60, // 'w'
94+
0xCC,0xF0,0xC3,0xCC,0xC0, // 'x'
95+
0xCC,0x91,0xE1,0x83,0x04,0x18,0x00, // 'y'
96+
0xF1,0x99,0x8F,0x00, // 'z'
97+
0x38,0xC3,0x0C,0xE0,0xC3,0x0C,0x38, // '{'
98+
0xAA,0xAA,0xA0, // '|'
99+
0xE1,0x86,0x18,0x39,0x86,0x18,0xE0 // '}'
100+
};
101+
const GFXglyph Dialog_bold_10Glyphs[] PROGMEM = {
102+
// bitmapOffset, width, height, xAdvance, xOffset, yOffset
103+
{ 0, 2, 1, 4, 0, -1 }, // ' '
104+
{ 1, 3, 7, 6, 1, -7 }, // '!'
105+
{ 4, 4, 3, 6, 1, -7 }, // '"'
106+
{ 6, 8, 7, 9, 1, -7 }, // '#'
107+
{ 13, 6, 8, 8, 1, -7 }, // '$'
108+
{ 19, 10, 7, 11, 1, -7 }, // '%'
109+
{ 28, 9, 7, 10, 1, -7 }, // '&'
110+
{ 36, 2, 3, 4, 1, -7 }, // '''
111+
{ 37, 4, 9, 6, 1, -8 }, // '('
112+
{ 42, 4, 9, 6, 1, -8 }, // ')'
113+
{ 47, 6, 6, 6, 0, -7 }, // '*'
114+
{ 52, 8, 7, 9, 1, -7 }, // '+'
115+
{ 59, 3, 3, 5, 1, -2 }, // ','
116+
{ 61, 4, 1, 5, 1, -4 }, // '-'
117+
{ 62, 3, 2, 5, 1, -2 }, // '.'
118+
{ 63, 5, 8, 5, 0, -7 }, // '/'
119+
{ 68, 7, 7, 8, 1, -7 }, // '0'
120+
{ 75, 7, 7, 8, 1, -7 }, // '1'
121+
{ 82, 7, 7, 8, 1, -7 }, // '2'
122+
{ 89, 7, 7, 8, 1, -7 }, // '3'
123+
{ 96, 7, 7, 8, 1, -7 }, // '4'
124+
{ 103, 7, 7, 8, 1, -7 }, // '5'
125+
{ 110, 7, 7, 8, 1, -7 }, // '6'
126+
{ 117, 7, 7, 8, 1, -7 }, // '7'
127+
{ 124, 7, 7, 8, 1, -7 }, // '8'
128+
{ 131, 7, 7, 8, 1, -7 }, // '9'
129+
{ 138, 3, 5, 5, 1, -5 }, // ':'
130+
{ 140, 3, 6, 5, 1, -5 }, // ';'
131+
{ 143, 7, 6, 9, 1, -6 }, // '<'
132+
{ 149, 7, 3, 9, 1, -5 }, // '='
133+
{ 152, 7, 6, 9, 1, -6 }, // '>'
134+
{ 158, 5, 7, 7, 1, -7 }, // '?'
135+
{ 163, 10, 9, 11, 1, -7 }, // '@'
136+
{ 175, 9, 7, 10, 1, -7 }, // 'A'
137+
{ 183, 7, 7, 8, 1, -7 }, // 'B'
138+
{ 190, 7, 7, 8, 1, -7 }, // 'C'
139+
{ 197, 8, 7, 9, 1, -7 }, // 'D'
140+
{ 204, 6, 7, 7, 1, -7 }, // 'E'
141+
{ 210, 6, 7, 7, 1, -7 }, // 'F'
142+
{ 216, 8, 7, 9, 1, -7 }, // 'G'
143+
{ 223, 8, 7, 9, 1, -7 }, // 'H'
144+
{ 230, 3, 7, 4, 1, -7 }, // 'I'
145+
{ 233, 4, 9, 4, 0, -7 }, // 'J'
146+
{ 238, 8, 7, 8, 1, -7 }, // 'K'
147+
{ 245, 6, 7, 7, 1, -7 }, // 'L'
148+
{ 251, 9, 7, 10, 1, -7 }, // 'M'
149+
{ 259, 8, 7, 9, 1, -7 }, // 'N'
150+
{ 266, 8, 7, 9, 1, -7 }, // 'O'
151+
{ 273, 7, 7, 8, 1, -7 }, // 'P'
152+
{ 280, 8, 8, 9, 1, -7 }, // 'Q'
153+
{ 288, 8, 7, 9, 1, -7 }, // 'R'
154+
{ 295, 7, 7, 8, 1, -7 }, // 'S'
155+
{ 302, 7, 7, 8, 1, -7 }, // 'T'
156+
{ 309, 8, 7, 9, 1, -7 }, // 'U'
157+
{ 316, 9, 7, 10, 1, -7 }, // 'V'
158+
{ 324, 11, 7, 12, 1, -7 }, // 'W'
159+
{ 334, 8, 7, 9, 1, -7 }, // 'X'
160+
{ 341, 9, 7, 8, 0, -7 }, // 'Y'
161+
{ 349, 7, 7, 8, 1, -7 }, // 'Z'
162+
{ 356, 4, 9, 6, 1, -8 }, // '['
163+
{ 361, 5, 8, 5, 0, -7 }, // '\'
164+
{ 366, 4, 9, 6, 1, -8 }, // ']'
165+
{ 371, 7, 3, 9, 1, -7 }, // '^'
166+
{ 374, 6, 1, 6, 0, 1 }, // '_'
167+
{ 375, 4, 2, 6, 0, -8 }, // '`'
168+
{ 376, 7, 5, 8, 1, -5 }, // 'a'
169+
{ 381, 7, 8, 8, 1, -8 }, // 'b'
170+
{ 388, 6, 5, 7, 1, -5 }, // 'c'
171+
{ 392, 7, 8, 8, 1, -8 }, // 'd'
172+
{ 399, 7, 5, 8, 1, -5 }, // 'e'
173+
{ 404, 6, 8, 5, 0, -8 }, // 'f'
174+
{ 410, 7, 7, 8, 1, -5 }, // 'g'
175+
{ 417, 7, 8, 8, 1, -8 }, // 'h'
176+
{ 424, 3, 8, 4, 1, -8 }, // 'i'
177+
{ 427, 4, 10, 4, 0, -8 }, // 'j'
178+
{ 432, 7, 8, 8, 1, -8 }, // 'k'
179+
{ 439, 3, 8, 4, 1, -8 }, // 'l'
180+
{ 442, 11, 5, 12, 1, -5 }, // 'm'
181+
{ 449, 7, 5, 8, 1, -5 }, // 'n'
182+
{ 454, 7, 5, 8, 1, -5 }, // 'o'
183+
{ 459, 7, 7, 8, 1, -5 }, // 'p'
184+
{ 466, 7, 7, 8, 1, -5 }, // 'q'
185+
{ 473, 5, 5, 6, 1, -5 }, // 'r'
186+
{ 477, 6, 5, 7, 1, -5 }, // 's'
187+
{ 481, 6, 7, 6, 0, -7 }, // 't'
188+
{ 487, 7, 5, 8, 1, -5 }, // 'u'
189+
{ 492, 7, 5, 8, 1, -5 }, // 'v'
190+
{ 497, 9, 5, 10, 1, -5 }, // 'w'
191+
{ 503, 7, 5, 8, 1, -5 }, // 'x'
192+
{ 508, 7, 7, 8, 1, -5 }, // 'y'
193+
{ 515, 5, 5, 6, 1, -5 }, // 'z'
194+
{ 519, 6, 9, 8, 1, -8 }, // '{'
195+
{ 526, 2, 10, 5, 1, -8 }, // '|'
196+
{ 529, 6, 9, 8, 2, -8 } // '}'
197+
};
198+
const GFXfont Dialog_bold_10 PROGMEM = {
199+
(uint8_t *)Dialog_bold_10Bitmaps,(GFXglyph *)Dialog_bold_10Glyphs,0x20, 0x7E, 13};

0 commit comments

Comments
 (0)