mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 12:54:29 +01:00
The open items of the MENU's review, decided: - SYSTEM > SYSTEM: RESTORE LAST, CPU CORES, CPU CLOCK (what a power-on does, all from the next start), ABOUT; CALIBRATION to SYSTEM > CONTROLS (the controls it teaches; KNOB 4). The crash message: MENU > SYSTEM > CORES. - BPM LOCK leaves CLICK for AUDIO (SPEAKER EQ, TRACKS, LOAD, BPM LOCK); CLICK keeps the metronome's three. - With that, eight pages cannot hold the 29 rows (CLICK was the only home left for a fourth card), so SCREEN gets a third page, LEDS: LED GLOW and SCALE LEDS together; SCREEN 2 is SCOPE, ANIMATION, SCREEN SLEEP. Nine pages, every one of up to four knobs and opening on a value (never on an action). - The footer does not repeat a page named as its tab: MENU . SCREEN, MENU . SCREEN 2, MENU . AUDIO, MENU . SYSTEM; MENU . AUDIO . CLICK, MENU . SCREEN . LEDS, MENU . SYSTEM . CONTROLS as before. n/9. - Card labels: CALIB, CPU MHZ, USB AUD; no two alike on a page (tests/ui_test.c checks it); no card mark in the MENU (the two LEVEL cards had the level icon, no other setting a mark). - Nothing stored changes (ids, values, defaults); the editor's tabs: SCALE LEDS SCREEN, CPU CORES SYSTEM. - tests: ui_test (pages, crumbs, labels, knobs), editor_test, cpu_safe_test; ui_render MENU > SCREEN 2 scene (menu_screen2). README, MANUAL EN / ES, EDITOR_PROTOCOL, the web manual and its shots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
622 lines
31 KiB
C
622 lines
31 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only
|
|
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
|
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
|
|
/* Felucca menu (HOME held): its rows in tabs (1.0.5: DISPLAY CONTROL AUDIO SYSTEM; JIANT 0.9.12: MIDI before SYSTEM;
|
|
* ALGORITHM between them, PRESETS within one; no scrolling), the rows in menu_items.c (the settings, shared with the editor's MENU_DESC / MENU_SET).
|
|
* No BACK row: HOME closes it (ui_input.c). The two-valued rows are bits of ui_prefs (MENU_FLAGS). PRESETS scrolls from
|
|
* ABOUT through all credits (OCT- back to the tabs). ui.menu: 1 the tabs, 2 information. */
|
|
/* ------------------------------------------------------------ menu --- */
|
|
/* (the rows, their values and names, usb_serial_apply: menu_items.c) */
|
|
|
|
/* https://github.com/juanjiant-bit/JIANT, QR version 3, correction M, generated by segno (python).
|
|
* One row per word, leftmost module in bit 0; the constant matrix needs no encoder or RAM. */
|
|
static const uint32_t ABOUT_QR[29] = {
|
|
0x1FC4C67Fu, 0x10536541u, 0x1744955Du, 0x17531B5Du, 0x175FD65Du, 0x10575C41u,
|
|
0x1FD5557Fu, 0x00140300u, 0x0E721141u, 0x0DAE4A31u, 0x01049B58u, 0x02288C33u,
|
|
0x10D17AF2u, 0x19DD2702u, 0x0735EEEBu, 0x1588EE0Bu, 0x06AA4DD6u, 0x1DCE9F33u,
|
|
0x1309F7E3u, 0x00554009u, 0x1DFB8A75u, 0x0310B300u, 0x0759E87Fu, 0x111C3241u,
|
|
0x13FD305Du, 0x163F9A5Du, 0x0FF8865Du, 0x16C18641u, 0x05CAD17Fu,
|
|
};
|
|
|
|
static void draw_about_qr(int32_t x, int32_t y)
|
|
{
|
|
uint32_t row, col;
|
|
cv_rect(x, y, 74, 74, UI_QR_LIGHT); /* fixed light / dark, independent of the palette */
|
|
for (row = 0; row < 29u; row++)
|
|
for (col = 0; col < 29u; col++)
|
|
if ((ABOUT_QR[row] >> col) & 1u)
|
|
cv_rect(x + 8 + (int32_t)col * 2, y + 8 + (int32_t)row * 2, 2, 2, UI_QR_DARK);
|
|
}
|
|
|
|
/* All notices are in flash. Wrap at the font's actual width, without dropping URL
|
|
* characters; the same layout computes the scroll limit and draws clipped bands.
|
|
* Mixed case here (long text); S throughout, the title in L. */
|
|
#define MENU_DOC_H 196 /* the document: screen rows 24..220 */
|
|
enum { MC_TEXT, MC_TITLE, MC_URL };
|
|
typedef struct { const char *text; uint8_t kind; } menu_credit_t;
|
|
static const menu_credit_t MENU_CREDITS[] = {
|
|
{"FELUCCA", MC_TITLE}, /* (0.9.12) the base; MIDI LEARN from its 1.5 (midi_learn.c) */
|
|
{"Leo Kuroshita, Hugelton Instruments: the firmware JIANT builds on, MIDI LEARN: GPL-3.0", MC_TEXT},
|
|
{"https://github.com/hugelton/Felucca", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"SKIFF", MC_TITLE}, /* (0.9.12) designs after it: 12 voices on two cores, the sound types */
|
|
{"illuminus5: 12 voices with two cores, sound types: GPL-3.0", MC_TEXT},
|
|
{"https://github.com/illuminus5/skiff", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"SOUNDS + FONTS", MC_TITLE},
|
|
{"CrispyZebra (PHASE waveforms), the DRUM voices, the Sample Pack: GPL-3.0", MC_TEXT},
|
|
{"Fukiai icon font: MIT", MC_TEXT},
|
|
{"", MC_TEXT},
|
|
{"DUAL CORE", MC_TITLE}, /* (JIANT 0.6.71) hal/fm1_multicore.h */
|
|
{"Melodee (keremimo), fm1-x0x (Charles Vestal): GPL-3.0", MC_TEXT},
|
|
{"https://github.com/keremimo/melodee", MC_URL},
|
|
{"https://github.com/charlesvestal/fm1-x0x", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"TESTING, CPU", MC_TITLE}, /* (JIANT 0.6.79) on a real FM-1: the load, the dual core, the RAM code */
|
|
{"praztalfractal", MC_TEXT},
|
|
{"https://github.com/gospodindilly-ops", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"KLATTSCH", MC_TITLE},
|
|
{"Tony Gies / MIT", MC_TEXT},
|
|
{"https://github.com/tgies/klattsch", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"DEXED + MSFA", MC_TITLE},
|
|
{"Pascal Gauthier, Google Inc.", MC_TEXT},
|
|
{"msfa: Apache-2.0, Dexed: GPL-3.0", MC_TEXT},
|
|
{"https://github.com/asb2m10/dexed", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"INTER TIGHT", MC_TITLE},
|
|
{"The Inter Project Authors", MC_TEXT},
|
|
{"SIL Open Font License 1.1", MC_TEXT},
|
|
{"https://github.com/rsms/inter-tight", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"VSCO-2 CE + VCSL", MC_TITLE},
|
|
{"Versilian Studios / CC0 1.0", MC_TEXT},
|
|
{"https://github.com/sgossner/VSCO-2-CE", MC_URL},
|
|
{"https://github.com/sgossner/VCSL", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"VOICE", MC_TITLE},
|
|
{"Dennis H. Klatt (1980)", MC_TEXT},
|
|
{"https://doi.org/10.1121/1.383940", MC_URL},
|
|
{"Hillenbrand, Getty, Clark and Wheeler (1995)", MC_TEXT},
|
|
{"https://doi.org/10.1121/1.411872", MC_URL},
|
|
{"", MC_TEXT},
|
|
{"CMU DICT", MC_TITLE}, /* (JIANT 0.8.5) VOICE's English words (sing.c) */
|
|
{"Carnegie Mellon University / BSD-2-Clause", MC_TEXT},
|
|
{"https://github.com/cmusphinx/cmudict", MC_URL},
|
|
};
|
|
|
|
static int32_t menu_text(const char *s, int32_t y, uint16_t col, int draw)
|
|
{
|
|
while (*s) {
|
|
char line[64];
|
|
uint32_t n = 0, space = 0, take, prev = 0;
|
|
int32_t pen = 0; /* 1/16 px, as text_w adds it up */
|
|
while (s[n] && n < sizeof line - 1u) {
|
|
uint32_t c = (uint8_t)s[n];
|
|
line[n] = s[n];
|
|
line[n + 1u] = 0;
|
|
pen += (prev ? kern(&AF_S, prev, c) : 0) + AF_S.gh[glyph(&AF_S, c) >> AF_S.psh].adv;
|
|
prev = c;
|
|
if ((pen + 8) >> 4 > 226)
|
|
break;
|
|
if (s[n] == ' ')
|
|
space = n;
|
|
n++;
|
|
}
|
|
take = s[n] && space ? space : n;
|
|
if (!take) take = 1; /* progress even for an unusually wide glyph */
|
|
line[take] = 0;
|
|
if (draw && y + AF_S.h > 0 && y < MENU_DOC_H)
|
|
cv_text(6, y, &AF_S, line, col);
|
|
y += 18;
|
|
s += take;
|
|
while (*s == ' ') s++;
|
|
}
|
|
return y;
|
|
}
|
|
|
|
/* (0.9.14) SAVE > TOOLS 6 CPU TEST measured: its song played 10 s or more, its mean AUDIO LOAD from 2 s on kept in the
|
|
* settings with the cores it ran on (cpt_res %, cpt_cores; 0 = not run): ABOUT, PROFILE, and GEN's EXPLORE budget
|
|
* (gen.c gc_dev: the host's model holds the song at ~63 % of a half with two cores, ~77 % with one) */
|
|
#define cpt_res (favorites.factory[15][16]) /* (bytes no engine uses: engine 15) */
|
|
#define cpt_cores (favorites.factory[15][15])
|
|
#define cpt_arm (prf.cpt_arm) /* the CPU TEST song built, TRACKS 6 (song_dice.c cpu_test_song) */
|
|
static __attribute__((noinline)) void cpt_poll(void) /* (ui_input: every pass) */
|
|
{
|
|
uint32_t t = fm1_ms - prf.cpt_ms;
|
|
if (!cpt_arm)
|
|
return;
|
|
if (song.playing) {
|
|
if (!prf.cpt_ms)
|
|
prf.cpt_ms = fm1_ms | 1u;
|
|
else if (t > 2000u)
|
|
prf.cpt_sum += song.cpu_q8, prf.cpt_n++;
|
|
return;
|
|
}
|
|
if (prf.cpt_ms && t > 12000u && prf.cpt_n) { /* stopped after 10 s of it: kept */
|
|
cpt_res = (uint8_t)clamp((int32_t)(prf.cpt_sum / prf.cpt_n * 100u >> 8), 1, 250);
|
|
cpt_cores = (uint8_t)(mc_two() ? 2u : 1u);
|
|
settings_save();
|
|
}
|
|
cpt_arm = (uint8_t)!prf.cpt_ms; /* (played and stopped: done either way) */
|
|
prf.cpt_ms = prf.cpt_sum = prf.cpt_n = 0;
|
|
}
|
|
static void cpt_line(char *b) /* "CPU TEST 98 % (2 CORES)", "CPU TEST: TOOLS 6" */
|
|
{
|
|
str_cpy(b, cpt_res ? "CPU TEST " : "CPU TEST: SAVE > TOOLS 6", 40);
|
|
if (cpt_res) {
|
|
fmt_int(b + 9, cpt_res);
|
|
str_cpy(b + str_len(b), cpt_cores == 1u ? " % (1 CORE)" : " % (2 CORES)", 14);
|
|
}
|
|
}
|
|
|
|
/* (0.9.14) MENU > ABOUT > PROFILE (OCT+ on ABOUT): where the audio's time went (prof.c), in % of a block (725 us; the
|
|
* load meter's halves are 4 of them): the last second playing, its mean and its worst block, then the same for the last
|
|
* second stopped (grey). SELECT scrolls, OCT- back to ABOUT. The rows: the sequencer, each part (its engine; C1: mostly
|
|
* on the second core), the buses (of them the reverb, the rest the delay and chorus), core 0 waiting for core 1, the FX
|
|
* layer to CLIP, the master, USB and the output, core 1 busy, TIMER5 within the render, the whole half (= AUDIO LOAD);
|
|
* then (means only) TIMER5 in all, the audio interrupt's latest start (us), the late halves, the blocks the buses
|
|
* rested (%), the UI's frames */
|
|
enum { PRV_DC = PRF_N, PRV_T5, PRV_LAT, PRV_LATE, PRV_REST, PRV_FPS };
|
|
static int prf_val(const prf_win_t *w, uint32_t k, uint32_t mx, int32_t *v) /* 1: tenths, 2: whole, 0: none */
|
|
{
|
|
uint32_t bt = w->blocks * (PRF_BLK / 8u) / 125u + 1u, x; /* (a second's ticks / 1000: no 64-bit divide) */
|
|
if (k < PRF_N) {
|
|
*v = (int32_t)(mx ? w->max[k] * (k >= PRF_NB ? 250u : 1000u) / PRF_BLK : w->sum[k] / bt);
|
|
return 1;
|
|
}
|
|
if (mx)
|
|
return 0;
|
|
x = k == PRV_DC ? w->sum[PRF_FX] - w->sum[PRF_REV] : k == PRV_T5 ? w->t5 : k == PRV_LAT ? w->lat / 24u :
|
|
k == PRV_LATE ? w->late : k == PRV_REST ? w->fxrest * 100u / (w->blocks + 1u) : w->frames;
|
|
*v = (int32_t)(k <= PRV_T5 ? x / bt : x);
|
|
return k <= PRV_T5 ? 1 : 2;
|
|
}
|
|
static int32_t prf_row(int32_t y, int draw, const char *name, uint32_t k)
|
|
{
|
|
uint32_t c;
|
|
if (draw && y + AF_S.h > 0 && y < MENU_DOC_H) {
|
|
cv_text(6, y, &AF_S, name, T_TEXT);
|
|
for (c = 0; c < 4u; c++) {
|
|
char b[12];
|
|
int32_t v = 0;
|
|
int f = (prf_have >> (1u - c / 2u)) & 1u ? prf_val(&prf_win[1u - c / 2u], k, c & 1u, &v) : 0;
|
|
b[0] = '0'; /* ("0.5", not ".5") */
|
|
if (f) fmt_fix(b + (f == 1 && v < 10), v, f == 1); else str_cpy(b, "-", 2);
|
|
cv_text_r(136 + (int32_t)c * 31, y, &AF_S, b, c / 2u ? T_MID : T_TEXT, T_BG);
|
|
}
|
|
}
|
|
return y + 18;
|
|
}
|
|
static int32_t prof_document(int32_t y, int draw)
|
|
{
|
|
static const char *const NM[] = {"SEQUENCER", "FX BUSES", "REVERB ", "DELAY+CHORUS", "CORE 0 WAITS", "FX LAYER..CLIP",
|
|
"MASTER", "USB+OUTPUT", "CORE 1 BUSY", "TIMER5 IN IT", "WHOLE HALF", "TIMER5 ALL",
|
|
"IRQ LATE US", "LATE HALVES", "FX REST %", "UI FRAMES"};
|
|
static const uint8_t KS[] = {PRF_SEQ, PRF_FX, PRF_REV, PRV_DC, PRF_WAIT, PRF_POST, PRF_MST, PRF_IO, PRF_C1, PRF_IRQ,
|
|
PRF_HALF, PRV_T5, PRV_LAT, PRV_LATE, PRV_REST, PRV_FPS};
|
|
const prf_win_t *w = &prf_win[prf_have >> 1];
|
|
char b[40];
|
|
uint32_t k, i;
|
|
y = menu_text("% OF A BLOCK: PLAY AVG MAX, STOP AVG MAX", y + 4, T_THEME, draw);
|
|
for (i = 0; i < NELEM(KS); i++) {
|
|
str_cpy(b, NM[i], sizeof b);
|
|
if (KS[i] == PRF_REV)
|
|
str_cpy(b + 7, N_RTYPE[REV_LITE[LOAD_EFF() % 3u][clamp(song.g[G_RTYPE], 0, 4)]], 8);
|
|
y = prf_row(y, draw, b, KS[i]);
|
|
for (k = 0; !i && k < NPART; k++) { /* (the parts after the sequencer; C1: mostly on core 1) */
|
|
b[0] = 'T'; b[1] = (char)('1' + k); b[2] = ' ';
|
|
str_cpy(b + 3, k < trk_live ? ENGINES[trk[k].engine]->name : "-", 10);
|
|
if (w->c1[k] * 2u > w->blocks && w->blocks)
|
|
str_cpy(b + str_len(b), " C1", 4);
|
|
y = prf_row(y, draw, b, PRF_T1 + k);
|
|
}
|
|
}
|
|
str_cpy(b, "VOICES ", sizeof b);
|
|
fmt_int(b + 7, (int32_t)voices_busy());
|
|
str_cpy(b + str_len(b), " CAP ", 6);
|
|
fmt_int(b + str_len(b), (int32_t)voice_cap());
|
|
str_cpy(b + str_len(b), LOAD_EFF() == LOAD_ECO ? " ECO" : LOAD_EFF() ? " LITE" : " FULL", 6);
|
|
y = menu_text(b, y + 4, T_TEXT, draw);
|
|
y = menu_text(cpu_status(), y, T_TEXT, draw);
|
|
cpt_line(b);
|
|
y = menu_text(b, y, T_TEXT, draw);
|
|
return menu_text(FELUCCA_VERSION, y, T_MID, draw) + 4;
|
|
}
|
|
|
|
static int32_t menu_document(int32_t y, int draw)
|
|
{
|
|
uint32_t i;
|
|
if (ui.menu == 3)
|
|
return prof_document(y, draw);
|
|
if (draw) {
|
|
cv_text(6, y + 2, &AF_L, "JIANT FM", T_THEME);
|
|
cv_text(6, y + 38, &AF_S, "Firmware for the MVAVE FM-1", T_TEXT);
|
|
cv_text(6, y + 58, &AF_M, FELUCCA_VERSION, T_THEME);
|
|
cv_text_r(232, y + 61, &AF_S, __DATE__, T_MID, T_BG);
|
|
cv_text(6, y + 82, &AF_S, "by Juan Jiant, Argentina", T_TEXT); /* (0.6.96: the project's own) */
|
|
cv_text(6, y + 100, &AF_S, "Free, GPL-3.0-only, no warranty", T_TEXT);
|
|
cv_text(6, y + 118, &AF_S, "Made in Argentina", T_TEXT);
|
|
cv_text(6, y + 138, &AF_S, "github.com", T_MID);
|
|
cv_text(6, y + 156, &AF_S, "/juanjiant-bit", T_MID);
|
|
cv_text(6, y + 174, &AF_S, "/JIANT", T_MID);
|
|
draw_about_qr(158, y + 122);
|
|
}
|
|
y = menu_text("THE PROJECT", y + 216, T_THEME, draw);
|
|
y = menu_text("Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant)", y, T_TEXT, draw); /* (0.9.12) */
|
|
y = menu_text("Made in Argentina by Juan Jiant, visual artist and musician, a dad of two: an independent project, free for everyone.", y, T_TEXT, draw);
|
|
y = menu_text("Manual, emulator, installer, editor:", y + 4, T_TEXT, draw);
|
|
y = menu_text("juanjiant-bit.github.io/JIANT", y, T_MID, draw);
|
|
y = menu_text("Videos: youtube.com/@JUANJIANT", y, T_MID, draw);
|
|
y = menu_text("Support the work:", y + 4, T_TEXT, draw);
|
|
y = menu_text("ko-fi.com/juanjiant", y, T_MID, draw);
|
|
y = menu_text("cafecito.app/juanjiant (Argentina)", y, T_MID, draw);
|
|
y = menu_text("Free software, GPL-3.0-only: the full notices and the sources it builds on travel with the source.", y + 4, T_TEXT, draw);
|
|
y -= 216;
|
|
{ /* (0.6.17) the audio's load since power-on (voice.c load_diag): to tell what happened when it clicked */
|
|
char b[40], n[12];
|
|
y = menu_text("AUDIO LOAD", y + 216, T_THEME, draw);
|
|
str_cpy(b, "NOW ", sizeof b); fmt_int(n, (int32_t)((song.cpu_q8 * 100u) >> 8)); str_cpy(b + str_len(b), n, 8);
|
|
str_cpy(b + str_len(b), "% PEAK ", 10); fmt_int(n, (int32_t)load_diag.peak); str_cpy(b + str_len(b), n, 8);
|
|
str_cpy(b + str_len(b), "%", 2);
|
|
y = menu_text(b, y, T_TEXT, draw);
|
|
str_cpy(b, "LATE ", sizeof b); fmt_int(n, (int32_t)load_diag.late); str_cpy(b + str_len(b), n, 12);
|
|
str_cpy(b + str_len(b), " SHED ", 8); fmt_int(n, (int32_t)load_diag.shed); str_cpy(b + str_len(b), n, 12);
|
|
y = menu_text(b, y, T_TEXT, draw);
|
|
y = menu_text(cpu_status(), y, T_TEXT, draw); /* (0.6.71) the second core (fx.c; 0.9.12: cpu_safe.c) */
|
|
y = menu_text(cpu_is_320() ? "CPU 320 MHZ" : "CPU 360 MHZ", y, T_TEXT, draw); /* (0.9.12) the clock now */
|
|
cpt_line(b); /* (0.9.14) */
|
|
y = menu_text(b, y, T_TEXT, draw);
|
|
y = menu_text("OCT+: PROFILE", y, T_MID, draw);
|
|
}
|
|
{ /* (0.9.12) the last crash kept (cpu_safe.c crash_log; MANUAL: Troubleshooting) */
|
|
char b[CRASH_LOG_N + 1u];
|
|
y = menu_text("LAST CRASH", y + 4, T_THEME, draw);
|
|
y = menu_text(crash_log_get(b) ? b : "NONE", y, T_TEXT, draw) - 216 + 8;
|
|
}
|
|
y = menu_text("CREDITS", y + 216, T_THEME, draw) + 8;
|
|
for (i = 0; i < NELEM(MENU_CREDITS); i++) {
|
|
const menu_credit_t *c = &MENU_CREDITS[i];
|
|
const char *text = c->text;
|
|
/* Display host/path once; the full source URL stays in the flash table. */
|
|
if (c->kind == MC_URL && str_len(text) >= 8u && !memcmp(text, "https://", 8))
|
|
text += 8;
|
|
if (!text[0]) y += 8;
|
|
else y = menu_text(text, y, c->kind == MC_TITLE ? T_THEME : c->kind == MC_URL ? T_MID : T_TEXT, draw);
|
|
}
|
|
y = menu_text("LICENSES + SOURCE", y + 12, T_THEME, draw);
|
|
y = menu_text("DRUM + own samples: GPL-3.0-only", y, T_TEXT, draw);
|
|
y = menu_text("Fonts and icons: their licences travel with the source and the release files.", y, T_TEXT, draw);
|
|
y = menu_text("NO WARRANTY", y, T_TEXT, draw);
|
|
y = menu_text("Full notices in source:", y + 8, T_TEXT, draw);
|
|
y = menu_text("github.com/juanjiant-bit/JIANT", y, T_MID, draw);
|
|
return y + 4;
|
|
}
|
|
static int32_t menu_scroll_max(void)
|
|
{
|
|
int32_t h = menu_document(0, 0);
|
|
return h > MENU_DOC_H ? h - MENU_DOC_H : 0;
|
|
}
|
|
|
|
/* (0.9.18) The MENU's settings as the rest of the system's pages (until 0.9.17 a list of rows, any knob the row's value,
|
|
* SELECT a row): the header "MENU . SCREEN", the tabs the groups (SCREEN AUDIO MIDI USB SYSTEM, a dot a page), the
|
|
* page's four settings as the four cards (KNOB n the card n's value, each value in its heat as every card's), the panel
|
|
* their rows (the knob's number, the full name, the value, one plain line on what it does: the value's own where the
|
|
* values differ in kind), the footer MENU . TAB . page n/9 (MENU . page where the page is named as its tab). SELECT walks the pages (no wrap), ALGORITHM jumps to the next
|
|
* / previous tab's first page, PRESETS does nothing (rule 3). The last setting turned (ui.menu_sel, a row) is framed in
|
|
* the panel; OCT+ / OCT- step it too (the LEDs breathe where it can go). An action (LEARN CLEAR, CALIBRATION, ABOUT):
|
|
* its knob arms it (its card TINT, OCT+ its value, as every action card), OCT+ does it. Messages: the toast pill. The
|
|
* drawing redone whole on a change (menu_sig) */
|
|
static uint32_t menu_page(void) { return menu_page_of(ui.menu_sel % MI_COUNT); }
|
|
static uint32_t menu_tab(void) { return MPAGE[menu_page()].tab; }
|
|
static uint32_t menu_pos(uint32_t row) /* a value's place in the menu's steps (ON / OFF rows: ON up) */
|
|
{
|
|
const menu_flag_t *f = menu_flag(row);
|
|
uint32_t v = menu_get(row);
|
|
return f && str_eq(f->name[0], "ON") ? !v : v;
|
|
}
|
|
static int32_t menu_ratio(uint32_t row) /* a card's gauge and heat, 0..1000; -1 none */
|
|
{
|
|
uint32_t n = menu_n(row);
|
|
return menu_valued(row) && n > 1u ? (int32_t)(menu_pos(row) * 1000u / (n - 1u)) : -1;
|
|
}
|
|
static void menu_val(uint32_t row, char *b) /* the row's value as it reads ("0.4 s"; LEARN CLEAR "3 CC") */
|
|
{
|
|
if (row == MI_LCLEAR) { /* (0.9.12) LEARN CLEAR: how many CCs are learned, "NONE" */
|
|
uint32_t n = ml_count();
|
|
str_cpy(b, "NONE", 16);
|
|
if (n) {
|
|
fmt_int(b, (int32_t)n);
|
|
str_cpy(b + str_len(b), " CC", 4);
|
|
}
|
|
return;
|
|
}
|
|
str_cpy(b, menu_valued(row) ? menu_vname(row, menu_get(row)) : "", 16);
|
|
}
|
|
static const char *menu_short(uint32_t row) /* a card's label: a whole word of the row's name (8 characters) */
|
|
{
|
|
static const struct { uint8_t row; char s[9]; } SH[] = {
|
|
{MI_LOWCUT, "SPEAKER"}, {MI_CPU, "CORES"}, {MI_CLKLVL, "LEVEL"}, {MI_USB, "LEVEL"}, {MI_SERIAL, "USB AUD"},
|
|
{MI_ANIM, "ANIMATE"}, {MI_SCROFF, "SLEEP"}, {MI_HOLD, "HOLD"}, {MI_ACCEL, "SPEEDUP"}, {MI_SCLLED, "SCALE"},
|
|
{MI_RESTORE, "RESTORE"}, {MI_CLOCK, "CPU MHZ"}, {MI_PANEL, "CALIB"}, {MI_LCLEAR, "CLEAR"}}; /* (no two alike on a
|
|
* page: tests/ui_test.c) */
|
|
uint32_t k;
|
|
for (k = 0; k < NELEM(SH); k++)
|
|
if (SH[k].row == row)
|
|
return SH[k].s;
|
|
return MI_NAME[row];
|
|
}
|
|
/* the panel's line under a row: what it does, in plain words; a value's own (v) where the values differ in kind */
|
|
static const struct { uint8_t row, v; const char *s; } MI_HELP[] = {
|
|
{MI_COLOR, 255, "THE SCREEN'S COLOURS"},
|
|
{MI_SKIN, 0, "VALUES ON TOP, THE PICTURE BELOW"},
|
|
{MI_SKIN, 1, "CARDS AND A PANEL, AS 0.6"},
|
|
{MI_SKIN, 2, "PICTURE FULL, VALUES AT THE FOOT"},
|
|
{MI_STYLE, 255, "FILLED CARDS, OR LINES"},
|
|
{MI_LARGE, 255, "BIG LABELS AND VALUES"},
|
|
{MI_SCOPE, 255, "EDIT PAGES: A SCOPE BY THE BEING"},
|
|
{MI_ANIM, 255, "OFF: VALUES SNAP, NOTHING ROLLS"},
|
|
{MI_LEDS, 255, "HOW IDLE KEYS AND BUTTONS GLOW"},
|
|
{MI_SCROFF, 255, "SCREEN DARK AFTER THIS LONG IDLE"},
|
|
{MI_LOWCUT, 255, "EQ FOR THE BUILT-IN SPEAKER"},
|
|
{MI_TRACKS, 0, "T5 AND T6 ASLEEP, LESS CPU"},
|
|
{MI_TRACKS, 1, "ALL SIX TRACKS PLAY"},
|
|
{MI_LOAD, 0, "LIGHTEST: NO SLICER, NO CHORUS"},
|
|
{MI_LOAD, 1, "LIGHTER REVERBS AND DELAY"},
|
|
{MI_LOAD, 2, "EVERYTHING AS SET"},
|
|
{MI_CPU, 255, "2 CORES: MORE VOICES (RESTART)"},
|
|
{MI_CLICK, 0, "NO METRONOME"},
|
|
{MI_CLICK, 1, "METRONOME WHILE RECORDING"},
|
|
{MI_CLICK, 2, "METRONOME WHILE PLAYING"},
|
|
{MI_CLKLVL, 255, "THE METRONOME'S VOLUME"},
|
|
{MI_COUNTIN, 255, "BARS BEFORE RECORDING STARTS"},
|
|
{MI_BPMLOCK, 255, "DICE ALL KEEPS THE TEMPO"},
|
|
{MI_MIDIOUT, 0, "USB MIDI OUT: THE KEYS' NOTES"},
|
|
{MI_MIDIOUT, 1, "THE KEYS + CLOCK, START, STOP"},
|
|
{MI_MIDIOUT, 2, "EVERY NOTE PLAYED + CLOCK"},
|
|
{MI_MIDIOUT, 3, "NOTHING GOES OUT"},
|
|
{MI_LEARN, 255, "ON: TURN A KNOB, THEN SEND A CC"},
|
|
{MI_LCLEAR, 255, "OCT+ FORGETS EVERY LEARNED CC"},
|
|
{MI_SERIAL, 0, "STEREO + THE SERIAL CONSOLE"},
|
|
{MI_SERIAL, 1, "STEREO AND MIDI ONLY (MACOS)"},
|
|
{MI_SERIAL, 2, "8 CHANNELS: EVERY TRACK + FX"},
|
|
{MI_SERIAL, 3, "STEREO BOTH WAYS"},
|
|
{MI_SERIAL, 4, "THE STEMS + THE COMPUTER'S AUDIO"},
|
|
{MI_USB, 0, "USB FOLLOWS THE MASTER KNOB"},
|
|
{MI_USB, 255, "USB AT A FIXED LEVEL"},
|
|
{MI_HOLD, 255, "HOLD THIS LONG FOR ITS LAYER"},
|
|
{MI_ACCEL, 255, "FAST TURNS TAKE BIGGER STEPS"},
|
|
{MI_LATCH, 255, "PUNCH-IN FX STAY ON WHEN LET GO"},
|
|
{MI_SCLLED, 255, "THE KEYS OF THE SCALE GLOW"},
|
|
{MI_RESTORE, 255, "ON: THE LAST SESSION AT POWER-ON"},
|
|
{MI_CLOCK, 255, "320 MHZ IF IT CRASHES (RESTART)"},
|
|
{MI_PANEL, 255, "OCT+: TEACH EACH BUTTON AND KNOB"},
|
|
{MI_ABOUT, 255, "OCT+: VERSION, LOAD, CREDITS"},
|
|
};
|
|
static const char *menu_help(uint32_t row)
|
|
{
|
|
uint32_t k, v = menu_valued(row) ? menu_get(row) : 255u;
|
|
for (k = 0; k < NELEM(MI_HELP); k++)
|
|
if (MI_HELP[k].row == row && (MI_HELP[k].v == v || MI_HELP[k].v == 255u))
|
|
return MI_HELP[k].s;
|
|
return "";
|
|
}
|
|
static uint16_t menu_vcol(uint32_t c, uint32_t row) /* a value's colour, as its card's (knob_col, the heat) */
|
|
{
|
|
int32_t r = menu_ratio(row);
|
|
uint16_t k = knob_col(c, r, 0);
|
|
return r < 0 ? T_MID : heat_on(r) ? ux_mix(k, T_TEXT, 20) : k;
|
|
}
|
|
static void menu_cards(void)
|
|
{
|
|
uint32_t p = menu_page(), c, r;
|
|
char v[16];
|
|
for (c = 0; c < 4u; c++) {
|
|
r = MPAGE[p].row[c];
|
|
if (r == MI_NONE) {
|
|
draw_column(c, "", "", "", T_DIM, -1, ICON_NONE);
|
|
continue;
|
|
}
|
|
menu_val(r, v);
|
|
if (!menu_valued(r)) { /* an action: armed by its knob (TINT, OCT+ its value) */
|
|
int arm = r == ui.menu_sel;
|
|
card_arm_next = (uint8_t)arm;
|
|
draw_column(c, menu_short(r), arm ? "OCT+" : v, "", arm ? (r == MI_LCLEAR && !ml_count() ? T_DIM : T_TEXT) : T_MID,
|
|
-1, ICON_NONE);
|
|
continue;
|
|
}
|
|
draw_column(c, menu_short(r), v, "", VAL(c), menu_ratio(r), ICON_NONE);
|
|
}
|
|
}
|
|
#define MROW_H 34 /* a row of the panel: 32 px and a gap; four in 136 */
|
|
static void menu_panel(void)
|
|
{
|
|
uint32_t p = menu_page(), c, r;
|
|
char v[16], kn[2] = {0, 0};
|
|
for (c = 0; c < 4u; c++) {
|
|
int32_t y = 2 + (int32_t)c * MROW_H;
|
|
int sel;
|
|
uint16_t bg;
|
|
r = MPAGE[p].row[c];
|
|
if (r == MI_NONE)
|
|
continue;
|
|
sel = r == ui.menu_sel;
|
|
bg = sel ? T_TINT : T_RAISE;
|
|
cv_rect(8, y, 224, MROW_H - 2, bg);
|
|
if (sel)
|
|
cv_rect(8, y, 3, MROW_H - 2, T_ACCENT);
|
|
kn[0] = (char)('1' + c);
|
|
GFX_HOOK_ALIGN(0, y + 3, 0, y + 16, AL_V, "menu row name centred up/down");
|
|
cv_text(16, y + 3 + CAP_IN(X, 13), &AF_X, kn, T_THEME);
|
|
GFX_HOOK_ALIGN(0, y + 3, 0, y + 16, AL_V, "menu row name centred up/down");
|
|
cv_text_on(26, y + 3 + CAP_IN(S, 13), &AF_S, MI_NAME[r], sel ? T_TEXT : T_MID, bg);
|
|
menu_val(r, v);
|
|
if (v[0]) {
|
|
GFX_HOOK_ALIGN(0, y + 3, 0, y + 16, AL_V, "menu row name centred up/down");
|
|
cv_text_r(226, y + 3 + CAP_IN(S, 13), &AF_S, v, menu_vcol(c, r), bg);
|
|
}
|
|
cv_free_text(26, y + 20 - AF_X_CAP_Y, &AF_X, menu_help(r), T_DIM, bg, 202);
|
|
}
|
|
}
|
|
static void draw_menu(void)
|
|
{
|
|
uint32_t sig;
|
|
if (ui.menu == 1) { /* (the message's and the knob's timers: the page path's lz_frame_end) */
|
|
if (ui.msg_t && !--ui.msg_t && ui.msg2[0]) {
|
|
str_cpy(ui.msg, ui.msg2, sizeof ui.msg);
|
|
ui.msg2[0] = 0;
|
|
ui.msg_t = 60;
|
|
}
|
|
if (ui.hot_t)
|
|
ui.hot_t--;
|
|
}
|
|
sig = ui.menu * 7u + ui.menu_sel * 131u + settings.palette * 1009u + settings.lowcut * 7919u + settings_hold * 3511u +
|
|
settings_leds * 6151u + ui_prefs * 4099u + ui_style * 257u + ui_skin * 1543u + song.rec * 65537u + song.sel * 13u +
|
|
ui_rec_prefs * 92821u + ui_scr * 131071u + (ui.hot_t ? ui.hot_col + 1u : 0u) * 0x9E3779B1u +
|
|
(ui.menu == 1 && ui.msg_t ? str_hash(0x70A57u, ui.msg) : 0u) + ml_count() * 977u + ml.on * 3u + usb_out * 61u +
|
|
midi_out_mode * 89u + cpu_cfg * 197u + ui_load * 433u + ui_scope * 71u +
|
|
(ui.menu >= 2 ? ui.menu_scroll * 48611u : 0u) + (ui.menu == 3 ? prf_seq * 2971u + 1u : 0u) +
|
|
(ui.menu == 2 ? (song.cpu_q8 >> 3) * 7741u + load_diag.peak * 3329u + load_diag.late * 1931u +
|
|
load_diag.shed * 2671u : 0u); /* (0.6.19) ABOUT's AUDIO LOAD: live (NOW in ~3 % steps) */
|
|
draw_head(); /* (0.8.5: the pages' header, "MENU . SCREEN") */
|
|
if (!ui.force && sig == ui.menu_sig)
|
|
return;
|
|
ui.menu_sig = sig;
|
|
if (ui.menu >= 2) {
|
|
uint32_t pass;
|
|
int32_t scroll = ui.menu_scroll, max = menu_scroll_max();
|
|
int32_t thumb = MENU_DOC_H * MENU_DOC_H / (max + MENU_DOC_H);
|
|
if (thumb < 12) thumb = 12;
|
|
for (pass = 0; pass < 2u; pass++) {
|
|
cv_begin(240, pass ? MENU_DOC_H - 124u : 124u, T_BG);
|
|
cv_oy = pass ? -124 : 0;
|
|
cv_scroll = 1;
|
|
menu_document(-scroll, 1);
|
|
cv_scroll = 0;
|
|
cv_rrect(235, 2, 3, MENU_DOC_H - 4, 1, T_LINE, T_BG); /* the scroll bar */
|
|
cv_rrect(235, 2 + (max ? scroll * (MENU_DOC_H - 4 - thumb) / max : 0), 3, thumb, 1, T_MID, T_LINE);
|
|
cv_oy = 0;
|
|
cv_blit(0, H_HEAD + pass * 124u);
|
|
}
|
|
cv_begin(240, 240 - (H_HEAD + MENU_DOC_H), T_BG);
|
|
{
|
|
static const khint_t KH[2] = {{KC_SELECT, "SCROLL"}, {KC_OCTDN, "BACK"}};
|
|
cv_key_row(8, 232, 4, KH, 2, 3u, T_BG);
|
|
}
|
|
cv_blit(0, H_HEAD + MENU_DOC_H);
|
|
return;
|
|
}
|
|
if (ui.force) { /* (0.9.0) round its tabs, cards, panel and footer, not under them */
|
|
int16_t R[7][4] = {{0, LT_Y, 240, (int16_t)(lz_low() ? LB_TAB_H : LT_H)}, {0, (int16_t)graph_y(), 240, (int16_t)graph_h()},
|
|
{0, (int16_t)foot_y(), 240, (int16_t)foot_h()}};
|
|
uint32_t c;
|
|
for (c = 0; c < 4u; c++) {
|
|
R[3u + c][0] = (int16_t)CARD_X(c);
|
|
R[3u + c][1] = (int16_t)card_y();
|
|
R[3u + c][2] = CARD_W;
|
|
R[3u + c][3] = (int16_t)card_h();
|
|
}
|
|
fill_around((const int16_t (*)[4])R, 7);
|
|
}
|
|
draw_tabs();
|
|
menu_cards();
|
|
cv_begin(240, graph_h(), T_BG); /* (the panel as draw_graph's: COLORS its box, AIR / HUD none) */
|
|
if (!lz_low())
|
|
cv_rrect(4, 0, 232, (int32_t)graph_h(), 6, T_SURF, T_BG);
|
|
cv_bg = T_SURF;
|
|
menu_panel();
|
|
cv_oy = 0;
|
|
if (ui.msg_t && ui.msg[0]) /* a message: the toast pill, as on every page */
|
|
toast_pill();
|
|
else
|
|
toast_at[0] = toast_at[2] = 0;
|
|
cv_blit(0, graph_y());
|
|
draw_foot();
|
|
}
|
|
static void enc_drop(void) /* knob turns nobody takes */
|
|
{
|
|
uint32_t k;
|
|
for (k = 0; k < NE; k++)
|
|
panel_enc(k);
|
|
}
|
|
|
|
static void menu_close(void)
|
|
{
|
|
settings_save(); /* palette / panel table, if changed */
|
|
ui.menu = 0;
|
|
ui.force = 1;
|
|
go_home();
|
|
}
|
|
|
|
/* (0.9.18) SELECT: the next / previous page (no wrap), its first setting; ALGORITHM: the next / previous tab's first
|
|
* page; KNOB n: the page's setting n (menu_items.c menu_step; an action: armed right, back to the page's first setting
|
|
* left); OCT+ / OCT-: the last setting turned a step (an action: OCT+ does it); PRESETS nothing (rule 3). In ABOUT SELECT
|
|
* scrolls, OCT- goes back. HOME closes it, from ABOUT too (ui_input.c). (0.9.2 .. 0.9.17: SELECT every row, any knob the
|
|
* row's value; until 0.9.1 SELECT zoomed MENU . TAB . ROW, PRESETS the row, ALGORITHM the tab round.) */
|
|
static void menu_page_go(uint32_t p)
|
|
{
|
|
if (p >= MP_COUNT || p == menu_page())
|
|
return;
|
|
ui.menu_sel = MPAGE[p].row[0];
|
|
ui.hot_t = 0;
|
|
}
|
|
static void menu_input(uint32_t oct) /* oct: ui_input.c oct_taps */
|
|
{
|
|
int32_t s;
|
|
uint32_t k, up = (oct >> 1) & 1u, dn = oct & 1u;
|
|
if (ui.menu >= 2) { /* ABOUT: SELECT scrolls (bounded), OCT- back to the tabs; (0.9.14)
|
|
* OCT+ PROFILE (its OCT- back to ABOUT) */
|
|
if (dn)
|
|
ui.menu = (uint8_t)(ui.menu - 1), ui.menu_scroll = 0, ui.force = 1;
|
|
else if (up && ui.menu == 2) {
|
|
if (!prf_on)
|
|
memset(&prf_cur, 0, sizeof prf_cur);
|
|
ui.menu = 3, ui.menu_scroll = 0, prf_on = 1, ui.force = 1;
|
|
}
|
|
else if ((s = panel_enc(EN_SELECT)) != 0)
|
|
ui.menu_scroll = (uint16_t)clamp((int32_t)ui.menu_scroll + clamp(s, -128, 128) * 18, 0, menu_scroll_max());
|
|
enc_drop();
|
|
return;
|
|
}
|
|
ui.mlv = 1;
|
|
if ((s = panel_enc(EN_SELECT)) != 0) /* SELECT: the pages, one a detent */
|
|
menu_page_go((uint32_t)clamp((int32_t)menu_page() + s, 0, MP_COUNT - 1));
|
|
if ((s = panel_enc(EN_ALGO)) != 0) /* ALGORITHM: a tab a detent, its first page */
|
|
menu_page_go(mtab_page((uint32_t)clamp((int32_t)menu_tab() + s, 0, MTAB_COUNT - 1)));
|
|
for (k = 0; k < 4u; k++) { /* KNOB n: the page's setting n */
|
|
uint32_t r = MPAGE[menu_page()].row[k];
|
|
if ((s = panel_enc(EN_K1 + k)) == 0 || r == MI_NONE)
|
|
continue;
|
|
ui.hot_col = (uint8_t)k;
|
|
ui.hot_t = 40;
|
|
if (menu_valued(r)) {
|
|
ui.menu_sel = (uint8_t)r;
|
|
menu_put(r, menu_step(r, s));
|
|
} else
|
|
ui.menu_sel = (uint8_t)(s > 0 ? r : MPAGE[menu_page()].row[0]); /* (an action: armed, or let go) */
|
|
}
|
|
if (menu_valued(ui.menu_sel)) {
|
|
/* OCT+ the next value, OCT- the previous, of the setting turned last; COLOR previews the palette, STYLE is drawn
|
|
* so from the next frame (FX LATCH: the latched effects are off while the menu is up) */
|
|
s = (int32_t)up - (int32_t)dn;
|
|
if (s)
|
|
menu_put(ui.menu_sel, menu_step(ui.menu_sel, s));
|
|
} else if (up) {
|
|
if (ui.menu_sel == MI_LCLEAR) { /* (0.9.12) LEARN CLEAR: every learned CC (no dialog: LEARN again
|
|
* brings one back) */
|
|
ui_message(ml_clear_all() ? "LEARN CLEARED" : "NOTHING LEARNED");
|
|
ui.force = 1;
|
|
} else if (ui.menu_sel == MI_PANEL) {
|
|
panel_setup();
|
|
scrn.idle = fm1_ms; /* (SCREEN OFF: its own loop had the input) */
|
|
ui.force = 1;
|
|
} else { /* MI_ABOUT */
|
|
ui.menu = 2;
|
|
ui.menu_scroll = 0;
|
|
ui.force = 1;
|
|
}
|
|
}
|
|
enc_drop(); /* swallow the rest while the menu is up */
|
|
}
|