diff --git a/firmware/src/bt.c b/firmware/src/bt.c index bf5b8948..ca30e043 100644 --- a/firmware/src/bt.c +++ b/firmware/src/bt.c @@ -153,7 +153,7 @@ static struct { uint32_t rd, t; /* the segment's ring read so far; the last 10 ms step */ int32_t lvl; /* the level, Q8 */ uint16_t raw; /* the last RSSI word */ - uint8_t win[5], wn, have, conn; /* the median's last five (wn 0..9); a level; a central */ + uint8_t win[9], wn, have, conn; /* the median's last nine (wn 0..17); a level; a central */ uint16_t w4[4]; /* (V10.18) the packet's four RSSI words, last */ uint8_t mn[12], mx[12], src, lock, seen; /* (V10.18) each reading's range on this link; the one used; kept * (a point stored); a link seen */ @@ -165,22 +165,24 @@ BTAPP_FN static int32_t bt_prox_map(int32_t lvl) } BTAPP_FN static void bt_prox_step(const uint16_t *w, uint32_t n, uint32_t conn, uint32_t now) { - uint32_t i, j, k, m[5]; + uint32_t i, j, k, m[9]; if (!conn) bp.have = bp.wn = 0; bp.conn = (uint8_t)conn; for (i = 0; conn && i < n; i++) { bp.raw = w[i]; - bp.win[bp.wn % 5u] = (uint8_t)((w[i] & 63u) + (w[i] >> 8 & 63u)); - bp.wn = (uint8_t)(bp.wn < 9u ? bp.wn + 1u : 5u); - k = bp.wn < 5u ? bp.wn : 5u; + bp.win[bp.wn % 9u] = (uint8_t)((w[i] & 63u) + (w[i] >> 8 & 63u)); + bp.wn = (uint8_t)(bp.wn < 17u ? bp.wn + 1u : 9u); + k = bp.wn < 9u ? bp.wn : 9u; for (j = 0; j < k; j++) { /* (sorted in) */ uint32_t x = bp.win[j], q = j; for (; q && m[q - 1u] > x; q--) m[q] = m[q - 1u]; m[q] = x; } - bp.lvl = bp.have ? bp.lvl + ((int32_t)(m[k / 2u] << 8) - bp.lvl) / 6 : (int32_t)(m[k / 2u] << 8); + bp.lvl = bp.have ? bp.lvl + ((int32_t)(m[k / 2u] << 8) - bp.lvl) / 32 : (int32_t)(m[k / 2u] << 8); /* (V10.20: + * the median of nine, ~32 packets: ~0.3 s; was five, ~6: on + * the hardware a random sample and hold, the channels' hops) */ bp.have = 1; } if (conn && bp.have) { @@ -193,10 +195,11 @@ BTAPP_FN static void bt_prox_step(const uint16_t *w, uint32_t n, uint32_t conn, for (; now - bp.t >= 10u; bp.t += 10u) mod_prox = (int16_t)(mod_prox - (mod_prox + 31) / 32); } -/* (V10.18) which reading follows the distance is not known (V10.14 read one word that, on the hardware, did not move): - * twelve readings of a packet, each of its four words as V10.14's level ((w & 63) + (w >> 8 & 63)), its low byte / 2, its - * high byte / 2; on each link the one whose range grew the widest is used (another must pass it by 6 to take over: no - * flicker; the level starts again then), until FAR or NEAR is stored (bp.lock: the points belong to that reading) */ +/* (V10.18) twelve readings of a packet: each of its four words as V10.14's level ((w & 63) + (w >> 8 & 63)), its low + * byte / 2, its high byte / 2. (V10.20) The one used is fixed again: word 0 (RSSI2 / 3 by the buffer) as the level, the + * gain index and the raw value together. V10.18 took the reading whose range grew widest, which on the hardware was a + * lone byte jumping at random (the noisiest, not the one that follows the distance); V10.17's still page was only the + * redraw (V10.19). The four words stay on the page */ BTAPP_FN static uint32_t bt_prox_rd(const uint16_t *q, uint32_t c) { uint32_t w = q[c / 3u]; @@ -210,19 +213,8 @@ BTAPP_FN static void bt_prox_feed(const uint16_t *w, uint32_t n, uint32_t conn, if (!conn) bp.seen = 0; for (i = 0; conn && i < n; i++) { - best = bp.src % 12u; - for (c = 0; c < 12u; c++) { - uint32_t x = bt_prox_rd(&w[4u * i], c); - if (!bp.seen || x < bp.mn[c]) bp.mn[c] = (uint8_t)x; - if (!bp.seen || x > bp.mx[c]) bp.mx[c] = (uint8_t)x; - if (!bp.lock && bp.mx[c] - bp.mn[c] > bp.mx[best] - bp.mn[best] + 6) - best = c; - } + (void)best; /* (V10.20: the reading fixed, see above) */ bp.seen = 1; - if (best != bp.src) { /* (another reading: its own level from here) */ - bp.src = (uint8_t)best; - bp.have = bp.wn = 0; - } c = bt_prox_rd(&w[4u * i], bp.src); c = c > 126u ? 126u : c; /* (as bt_prox_step reads it: two halves of 0..63) */ v[i] = (uint16_t)(c / 2u | (c - c / 2u) << 8); diff --git a/firmware/src/felucca.c b/firmware/src/felucca.c index b6ee9278..5c015710 100644 --- a/firmware/src/felucca.c +++ b/firmware/src/felucca.c @@ -41,7 +41,7 @@ #define FELUCCA_ID "FM-1_900" /* package identity (build.py: the .fwsc marker string) */ #endif #ifndef FELUCCA_VERSION -#define FELUCCA_VERSION "V10.19" /* (2026-10-31) V10.19: the PROX page redraws when a reading arrives (all-zero words left it on NOT CONNECTED) and shows the link as seen: L (link), the RSSI hook's packets / the good packets. (2026-10-31) V10.18: PROX finds the RSSI reading that moves (the four RSSI words of each packet, twelve readings, the widest range on the link; kept once FAR / NEAR is stored), the page shows the four words. (2026-10-31) V10.17: SAVE > SECTIONS KNOB 2 ERASE (the section empty again, RAM and flash; the music stays). (2026-10-31) V10.16: SEQ > EUCLID's VARY in four turns (A A' A'' B, each moved anew, the motif answered); SEQ > MUTATE (EVERY 1..16 bars, AMOUNT, MODE ORBIT / DRIFT / PULSE, WHAT GROOVE / RHYTHM / FEEL / ALL; OCT+ a mutation now, OCT- back to the anchor). (2026-10-31) V10.15: VOICE's English dictionary in the Bluetooth segment (without it: the letter rules). (2026-10-31) V10.14: PROX, a modulation source from the Bluetooth signal (a hand near the antenna), calibrated on MENU > SYSTEM > BLUETOOTH ON + OCT+ (OCT- FAR, OCT+ NEAR). (2026-10-31) V10.13: BLE-MIDI in and out (what a central sends plays as USB-MIDI, MIDI OUT goes to it too); ABOUT's credits in the Bluetooth segment (the app slot had 128 B free). (2026-10-31) V10.12: MENU > SYSTEM > BLUETOOTH OFF / ON: a BLE-MIDI peripheral "JIANT FM-1" (advertising, connectable; MIDI not routed yet), Optimist's stack in the Bluetooth segment at 0xEA000 (written by the update loader from the package's bt.bin), live RF calibration, a boot guard. (2026-10-31) V10.11: the supplies set up as stock V15 does (the DC-DC on, hal/fm1_power.h from Melodee), the radio's prerequisite; 0xEA000..0xFBFFF reserved for the Bluetooth segment. (2026-10-31) V10.10: the radio's calibration kept: the update loader keeps the stock VM sector (0xE8000: RF trims, BT address) but its record's 256 B; VM_READ (editor 80) reads that area for web/btcheck. (2026-10-31) V10.9: MENU > LARGE shows the animations (HOME: the six tracks' creatures in the strip; EDIT: the engine's). (2026-10-31) V10.8: testers' fixes: GEN parts set OFF stay off; GEN keeps its GENRE between visits; SEQ > STEP KNOB 4 VEL (1..127, then ACC SLD A+S); delay 1/4D 1/8D 1/16D; less pitch wobble from the generators (no macro on PITCH, pitched delay seldom, octaves); STOP TO EDIT says SONG PLAYS. (2026-10-31) V10.7: SEQ > EUCLID on a kit: LANE ALL first (DENSITY: a whole usable kit), a lane picked writes that lane alone; EDIT + PRESETS jumps between engines; the kit's SEQ dice plays in every genre; EUCLID's HITS exact (VARY moved them only); REC held alone and let go: UNDO (again: REDO). (2026-10-31) V10.6: SEQ > EUCLID and MODES (a euclidean pattern generator, melodies in the key) in MUTATE's place; MUTATE and SEQ TOOLS' RANDOM COOK BEAT gone. (2026-10-31) V10.5: automation thinned (a recording at the stop, the 64 when full) into holds and RAMPs. (2026-10-31) V10.4: ARRANGE / TIMELINE: OCT- deletes the row picked (DELETE ROW?). (2026-10-31) V10.3: TIMELINE: the lines between lanes soft (the block's colour, darker), the rows' edges stronger. (2026-10-31) V10.2: TIMELINE keeps the black line between lanes (only the rows touch); SAVE composes first: TIMELINE SECTIONS PROJECTS ARRANGE TOOLS USER PRESETS. (2026-10-30) V10.1: TIMELINE blocks fill the lanes (no black gaps between rows or tracks). (2026-10-30) JIANT FM V10: add15-beta6 as the new base (TIMELINE, VAR, ADD, official V16 both ways); the version history before it: the git log of the add15 line (codex/add15-private) */ +#define FELUCCA_VERSION "V10.20" /* (2026-11-01) V10.20: PROX smooth: the RSSI reading fixed on word 0 as the level (V10.18's widest range picked a noisy byte: a random sample and hold), the median of nine and ~0.3 s; FAR and NEAR too close (under 4 levels) refused. (2026-10-31) V10.19: the PROX page redraws when a reading arrives (all-zero words left it on NOT CONNECTED) and shows the link as seen: L (link), the RSSI hook's packets / the good packets. (2026-10-31) V10.18: PROX finds the RSSI reading that moves (the four RSSI words of each packet, twelve readings, the widest range on the link; kept once FAR / NEAR is stored), the page shows the four words. (2026-10-31) V10.17: SAVE > SECTIONS KNOB 2 ERASE (the section empty again, RAM and flash; the music stays). (2026-10-31) V10.16: SEQ > EUCLID's VARY in four turns (A A' A'' B, each moved anew, the motif answered); SEQ > MUTATE (EVERY 1..16 bars, AMOUNT, MODE ORBIT / DRIFT / PULSE, WHAT GROOVE / RHYTHM / FEEL / ALL; OCT+ a mutation now, OCT- back to the anchor). (2026-10-31) V10.15: VOICE's English dictionary in the Bluetooth segment (without it: the letter rules). (2026-10-31) V10.14: PROX, a modulation source from the Bluetooth signal (a hand near the antenna), calibrated on MENU > SYSTEM > BLUETOOTH ON + OCT+ (OCT- FAR, OCT+ NEAR). (2026-10-31) V10.13: BLE-MIDI in and out (what a central sends plays as USB-MIDI, MIDI OUT goes to it too); ABOUT's credits in the Bluetooth segment (the app slot had 128 B free). (2026-10-31) V10.12: MENU > SYSTEM > BLUETOOTH OFF / ON: a BLE-MIDI peripheral "JIANT FM-1" (advertising, connectable; MIDI not routed yet), Optimist's stack in the Bluetooth segment at 0xEA000 (written by the update loader from the package's bt.bin), live RF calibration, a boot guard. (2026-10-31) V10.11: the supplies set up as stock V15 does (the DC-DC on, hal/fm1_power.h from Melodee), the radio's prerequisite; 0xEA000..0xFBFFF reserved for the Bluetooth segment. (2026-10-31) V10.10: the radio's calibration kept: the update loader keeps the stock VM sector (0xE8000: RF trims, BT address) but its record's 256 B; VM_READ (editor 80) reads that area for web/btcheck. (2026-10-31) V10.9: MENU > LARGE shows the animations (HOME: the six tracks' creatures in the strip; EDIT: the engine's). (2026-10-31) V10.8: testers' fixes: GEN parts set OFF stay off; GEN keeps its GENRE between visits; SEQ > STEP KNOB 4 VEL (1..127, then ACC SLD A+S); delay 1/4D 1/8D 1/16D; less pitch wobble from the generators (no macro on PITCH, pitched delay seldom, octaves); STOP TO EDIT says SONG PLAYS. (2026-10-31) V10.7: SEQ > EUCLID on a kit: LANE ALL first (DENSITY: a whole usable kit), a lane picked writes that lane alone; EDIT + PRESETS jumps between engines; the kit's SEQ dice plays in every genre; EUCLID's HITS exact (VARY moved them only); REC held alone and let go: UNDO (again: REDO). (2026-10-31) V10.6: SEQ > EUCLID and MODES (a euclidean pattern generator, melodies in the key) in MUTATE's place; MUTATE and SEQ TOOLS' RANDOM COOK BEAT gone. (2026-10-31) V10.5: automation thinned (a recording at the stop, the 64 when full) into holds and RAMPs. (2026-10-31) V10.4: ARRANGE / TIMELINE: OCT- deletes the row picked (DELETE ROW?). (2026-10-31) V10.3: TIMELINE: the lines between lanes soft (the block's colour, darker), the rows' edges stronger. (2026-10-31) V10.2: TIMELINE keeps the black line between lanes (only the rows touch); SAVE composes first: TIMELINE SECTIONS PROJECTS ARRANGE TOOLS USER PRESETS. (2026-10-30) V10.1: TIMELINE blocks fill the lanes (no black gaps between rows or tracks). (2026-10-30) JIANT FM V10: add15-beta6 as the new base (TIMELINE, VAR, ADD, official V16 both ways); the version history before it: the git log of the add15 line (codex/add15-private) */ #endif #if FELUCCA_OTA && !FELUCCA_FLASH #error "FELUCCA_OTA needs FELUCCA_FLASH" diff --git a/firmware/src/ui_menu.c b/firmware/src/ui_menu.c index 200a9da3..bdef6510 100644 --- a/firmware/src/ui_menu.c +++ b/firmware/src/ui_menu.c @@ -452,7 +452,10 @@ BTAPP_FN static void bt_prox_input(uint32_t up, uint32_t dn) return; } BT_CAL[up] = (uint8_t)clamp((bp.lvl + 64) >> 7, 0, 252); - bp.lock = 1; /* (V10.18) the reading the points belong to: kept */ + if (BT_CAL[0] && BT_CAL[1] && (BT_CAL[0] > BT_CAL[1] ? BT_CAL[0] - BT_CAL[1] : BT_CAL[1] - BT_CAL[0]) < 8u) { + ui_message("FAR AND NEAR TOO CLOSE"); /* (V10.20) under 4 levels apart: noise, not distance */ + return; + } ui_message(BP_S[7u + up]); } } diff --git a/tests/ui_test.c b/tests/ui_test.c index 2475baee..eb23bbc3 100644 --- a/tests/ui_test.c +++ b/tests/ui_test.c @@ -2795,13 +2795,13 @@ static int test_menu_tabs(void) ok &= ui.menu == 3u && favorites.factory[6][22] == 160u && msg_is("PROX FAR SET") && menu_get(MI_BT) == 1u; for (k = 0; k < 40u; k++) w[k] = LV(40u); - bt_prox_step(w, 40, 1, t += 400u); + { uint32_t r_; for (r_ = 0; r_ < 8u; r_++) bt_prox_step(w, 40, 1, t += 400u); } press(B_OCTUP); /* NEAR: the hand on the antenna, level 40 */ bt_prox_step(w, 0, 1, t += 10u); ok &= favorites.factory[6][23] == 80u && msg_is("PROX NEAR SET") && mod_prox > 32600; for (k = 0; k < 40u; k++) w[k] = LV(60u); - bt_prox_step(w, 40, 1, t += 400u); + { uint32_t r_; for (r_ = 0; r_ < 8u; r_++) bt_prox_step(w, 40, 1, t += 400u); } ok &= mod_prox > 16200 && mod_prox < 16600; /* (half way) */ w[0] = LV(0u); before = mod_prox; @@ -2812,11 +2812,11 @@ static int test_menu_tabs(void) ok &= mod_prox == before; /* (no packets: held) */ for (k = 0; k < 40u; k++) w[k] = LV(100u); - bt_prox_step(w, 40, 1, t += 400u); + { uint32_t r_; for (r_ = 0; r_ < 8u; r_++) bt_prox_step(w, 40, 1, t += 400u); } ok &= mod_prox == 0; /* (farther than FAR: clamped) */ for (k = 0; k < 40u; k++) w[k] = LV(50u); - bt_prox_step(w, 40, 1, t += 400u); + { uint32_t r_; for (r_ = 0; r_ < 8u; r_++) bt_prox_step(w, 40, 1, t += 400u); } before = mod_prox; bt_prox_step(w, 0, 0, t += 100u); /* the central gone */ ok &= before > 20000 && mod_prox < before && mod_prox > before / 2 && !bp.have; @@ -2828,24 +2828,22 @@ static int test_menu_tabs(void) menu_close(); memset(&favorites.factory[6][22], 0, 10); memset(&bp, 0, sizeof bp); - { /* (V10.18) the reading that moves is found: word 2's high byte here, the others still; the points lock it */ + { /* (V10.20) the reading is word 0 as the level, whatever the others do (V10.18's widest range was the noisiest) */ uint16_t q[64]; - uint32_t j, ok2; + uint32_t j, ok2, r; memset(&bp, 0, sizeof bp); - for (j = 0; j < 16u; j++) { - q[4u * j] = 0x2020; q[4u * j + 1u] = 0x1111; - q[4u * j + 2u] = (uint16_t)(((j < 8u ? 40u : 200u) << 8) | 0x55u); q[4u * j + 3u] = 0; + for (r = 0; r < 4u; r++) { + for (j = 0; j < 16u; j++) { + q[4u * j] = (uint16_t)(20u | 20u << 8); /* (level 40) */ + q[4u * j + 1u] = (uint16_t)(j & 1u ? 0xFFFF : 0); q[4u * j + 2u] = (uint16_t)(j * 4099u); q[4u * j + 3u] = 0; + } + bt_prox_feed(q, 16, 1, t += 100u); } - bt_prox_feed(q, 16, 1, t += 100u); - ok2 = bp.src == 8u && bp.have && bp.raw == q[60u + 2u]; - ok2 &= (bp.lvl >> 8) > 80 && (bp.lvl >> 8) <= 100; /* (200 / 2) */ - bp.lock = 1; - for (j = 0; j < 16u; j++) q[4u * j] = (uint16_t)(j & 1u ? 0x3F3F : 0); /* (word 0 swings wider: kept) */ - bt_prox_feed(q, 16, 1, t += 100u); - ok2 &= bp.src == 8u; - bt_prox_feed(q, 0, 0, t += 100u); /* (the link gone: its ranges forgotten) */ - ok2 &= !bp.seen; - bad += check("V10.18 PROX: the RSSI reading that follows the distance is found (12 readings), kept once a point is stored", ok2); + ok2 = bp.src == 0u && bp.have && (bp.lvl >> 8) == 40 && bp.raw == q[60]; + q[0] = (uint16_t)(60u | 60u << 8); /* (one packet far off: a step of ~1/32 at most) */ + bt_prox_feed(q, 1, 1, t += 100u); + ok2 &= (bp.lvl >> 8) <= 41; + bad += check("V10.20 PROX: word 0 as the level, the others ignored; the median of nine and ~32 packets smooth it", ok2); memset(&bp, 0, sizeof bp); } bt_up = 0;