mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 04:44:33 +01:00
V10.18: PROX finds the RSSI reading that moves
On the hardware (V10.17) the PROX page showed no movement: the one word V10.14 read (CB->rssi[2 + buffer], unverified) does not follow the distance, or its reading does not. Now: - the stack's hook hands all four RSSI words of each good packet (RSSI2 / 3 by the buffer first, the other, RSSI0, RSSI1); bt_seg.c keeps 16 packets x 4. - src/bt.c bt_prox_feed: twelve readings of a packet (each word as V10.14's level, its low byte / 2, its high byte / 2), their ranges on this link; the widest is used (another must pass it by 6; the level starts again), kept once FAR or NEAR is stored (bp.lock); a new link forgets the ranges. - the PROX page shows the four words (to read off the screen) and the reading used after RAW (word and W / L / H). Tests: ui_test (the moving reading found among still ones, kept once locked, forgotten with the link); ui_render's PROX page with the words (0 lint findings). App 568,668 B (15,668 B free); segment 47,592 B; pool spare 9,440 B. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
8 files changed
+1963
-1882
No files matched your search
@@ -945,7 +945,7 @@ static void hw_rx_service(void)
|
||||
#ifdef BLE_HW_RX_RSSI
|
||||
if ((st & 0xFu) == 1u) /* (JIANT V10.14) a good packet's RSSI word (HW §3 0x138:
|
||||
* RSSI2 / RSSI3 by the buffer, unverified) */
|
||||
BLE_HW_RX_RSSI(CB->rssi[2u + b]);
|
||||
BLE_HW_RX_RSSI(CB->rssi, b); /* (V10.18: the four words, the app finds the one that moves) */
|
||||
#endif
|
||||
if (!hwd.first_rx) { /* (diagnostics) the first packet of this connection */
|
||||
hwd.first_rx = 1;
|
||||
|
||||
+15
-7
@@ -43,15 +43,21 @@
|
||||
#include "fm1_guard.h"
|
||||
/* (V10.14) PROX: the RSSI word of every good packet on the link (ble_hw_wl82.c hw_rx_service, the RX interrupt: one a
|
||||
* connection event, 89..133 a second), kept in a ring the app reads (bt_seg_rssi; src/bt.c filters it) */
|
||||
static volatile uint16_t bs_rq[16];
|
||||
static volatile uint16_t bs_rq[16][4];
|
||||
static volatile uint32_t bs_rw;
|
||||
static void bs_rssi(uint16_t w)
|
||||
/* (V10.18) all four RSSI words of the packet (RSSI2 / RSSI3 by the buffer first, as V10.14 read it, then the other, then
|
||||
* RSSI0, RSSI1): which one follows the distance is found by the app (src/bt.c bt_prox_tick) */
|
||||
static void bs_rssi(const volatile uint16_t *r, uint32_t b)
|
||||
{
|
||||
bs_rq[bs_rw & 15u] = w;
|
||||
volatile uint16_t *q = bs_rq[bs_rw & 15u];
|
||||
q[0] = r[2u + (b & 1u)];
|
||||
q[1] = r[3u - (b & 1u)];
|
||||
q[2] = r[0];
|
||||
q[3] = r[1];
|
||||
RING_PUBLISH();
|
||||
bs_rw++;
|
||||
}
|
||||
#define BLE_HW_RX_RSSI(w) bs_rssi(w)
|
||||
#define BLE_HW_RX_RSSI(r, b) bs_rssi(r, b)
|
||||
#include "ble/ble_stack.c"
|
||||
|
||||
/* the segment's header, first in it (app.ld .bt_head): magic, payload length, CRC-32 of the payload (zlib), filled by
|
||||
@@ -138,15 +144,17 @@ uint32_t bt_seg_status(void)
|
||||
return (uint32_t)ble_connected() | (uint32_t)ble_midi_ready() << 1 | (uint32_t)bs_conns << 8;
|
||||
}
|
||||
|
||||
/* (V10.14) the RSSI words since *rd (the newest 16 at most: a main loop held up by a flash write loses the older) */
|
||||
/* (V10.14) the RSSI words since *rd (the newest 16 packets at most: a main loop held up by a flash write loses the
|
||||
* older); (V10.18) four words a packet, w[4 * i .. 4 * i + 3] */
|
||||
uint32_t bt_seg_rssi(uint16_t *w, uint32_t *rd)
|
||||
{
|
||||
uint32_t e = bs_rw, n = e - *rd, i;
|
||||
uint32_t e = bs_rw, n = e - *rd, i, j;
|
||||
RING_PUBLISH();
|
||||
if (n > 16u)
|
||||
n = 16u;
|
||||
for (i = 0; i < n; i++)
|
||||
w[i] = bs_rq[(e - n + i) & 15u];
|
||||
for (j = 0; j < 4u; j++)
|
||||
w[4u * i + j] = bs_rq[(e - n + i) & 15u][j];
|
||||
*rd = e;
|
||||
return n;
|
||||
}
|
||||
+45
-2
@@ -152,6 +152,9 @@ static struct {
|
||||
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 */
|
||||
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 */
|
||||
} bp;
|
||||
BTAPP_FN static int32_t bt_prox_map(int32_t lvl)
|
||||
{
|
||||
@@ -188,11 +191,51 @@ 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) */
|
||||
BTAPP_FN static uint32_t bt_prox_rd(const uint16_t *q, uint32_t c)
|
||||
{
|
||||
uint32_t w = q[c / 3u];
|
||||
return c % 3u == 0u ? (w & 63u) + (w >> 8 & 63u) : c % 3u == 1u ? (w & 255u) >> 1 : w >> 9; /* (0..127) */
|
||||
}
|
||||
BTAPP_FN static void bt_prox_feed(const uint16_t *w, uint32_t n, uint32_t conn, uint32_t now) /* n packets of 4 */
|
||||
{
|
||||
uint16_t v[16];
|
||||
uint32_t i, c, best;
|
||||
n = n > 16u ? 16u : n;
|
||||
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;
|
||||
}
|
||||
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);
|
||||
for (c = 0; c < 4u; c++)
|
||||
bp.w4[c] = w[4u * i + c];
|
||||
}
|
||||
bt_prox_step(v, conn ? n : 0u, conn, now);
|
||||
if (n && conn)
|
||||
bp.raw = bp.w4[bp.src / 3u];
|
||||
}
|
||||
BTAPP_FN static void bt_prox_tick(void)
|
||||
{
|
||||
uint16_t w[16];
|
||||
uint16_t w[64];
|
||||
uint32_t n = bt_hw_rssi(w, &bp.rd);
|
||||
bt_prox_step(w, n, bt_get() && (bt_hw_status() & 1u), fm1_ms);
|
||||
bt_prox_feed(w, n, bt_get() && (bt_hw_status() & 1u), fm1_ms);
|
||||
}
|
||||
static uint32_t bt_prox_ok(void) { return bt_up == BT_RUN && bt_get(); } /* (the PROX page opens: ui_menu.c) */
|
||||
static void bt_tick(void) /* main loop: the saved ON, once the music is stopped */
|
||||
|
||||
@@ -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.17" /* (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.18" /* (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"
|
||||
|
||||
+11
-1
@@ -409,9 +409,18 @@ BTAPP_FN static void bt_prox_panel(const aafont_t *fx, const aafont_t *fm, const
|
||||
str_cpy(b + str_len(b), BP_S[10], 10);
|
||||
for (k = 0; k < 4u; k++)
|
||||
b[str_len(b) + 1u] = 0, b[str_len(b)] = "0123456789ABCDEF"[bp.raw >> (12u - 4u * k) & 15u];
|
||||
b[str_len(b) + 3u] = 0; /* (V10.18) the reading used: "R" its word, its kind */
|
||||
k = str_len(b);
|
||||
b[k] = ' '; b[k + 1u] = (char)('0' + bp.src / 3u); b[k + 2u] = "WLH"[bp.src % 3u];
|
||||
} else
|
||||
str_cpy(b, BP_S[2], sizeof b);
|
||||
cv_text(10, 64 - AF_S_CAP_Y, fs, b, T_TEXT);
|
||||
if (bp.conn && bp.have) { /* (V10.18) the four words, to read off the screen */
|
||||
for (k = 0; k < 16u; k++)
|
||||
b[k + k / 4u] = "0123456789ABCDEF"[bp.w4[k / 4u] >> (12u - 4u * (k & 3u)) & 15u];
|
||||
b[4] = b[9] = b[14] = ' '; b[19] = 0;
|
||||
cv_text_r(228, 44 - AF_X_CAP_Y, fx, b, T_DIM, T_SURF);
|
||||
}
|
||||
if (BT_CAL[0] != BT_CAL[1]) {
|
||||
str_cpy(b, BP_S[11], sizeof b);
|
||||
fmt_fix(b + str_len(b), BT_CAL[0] * 5, 1);
|
||||
@@ -434,10 +443,11 @@ 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 */
|
||||
ui_message(BP_S[7u + up]);
|
||||
}
|
||||
}
|
||||
static uint32_t bt_prox_sig(void) { return ui.menu == 3 ? (uint32_t)mod_prox * 31u + bp.raw * 977u + bp.conn * 5u + BT_CAL[0] * 3u + BT_CAL[1] * 7u : 0u; }
|
||||
static uint32_t bt_prox_sig(void) { return ui.menu == 3 ? (uint32_t)mod_prox * 31u + bp.raw * 977u + bp.w4[0] * 13u + bp.w4[1] * 17u + bp.w4[2] * 19u + bp.w4[3] * 23u + bp.src * 29u + bp.conn * 5u + BT_CAL[0] * 3u + BT_CAL[1] * 7u : 0u; }
|
||||
|
||||
static void confirm_open(uint32_t kind, uint32_t trk); /* (0.6.58) INIT SYSTEM: ui_input.c */
|
||||
static void draw_menu(void)
|
||||
|
||||
+1
-1
@@ -1418,7 +1418,7 @@ static void setup(int s)
|
||||
case S_MENU_SLIDE: ui.menu = 1; ui.menu_sel = MI_ACCEL; ui_prefs |= PREF_LATCH; break;
|
||||
/* (V10.14) BLUETOOTH > PROX: connected, calibrated, a hand half way (the widest numbers); not connected, not
|
||||
* calibrated */
|
||||
case S_MENU_PROX: ui.menu = 3; ui.mlv = 1; ui.menu_sel = MI_BT; bp.conn = bp.have = 1; bp.lvl = 125 * 256 + 230; bp.raw = 0xBC3F;
|
||||
case S_MENU_PROX: ui.menu = 3; ui.mlv = 1; ui.menu_sel = MI_BT; bp.conn = bp.have = 1; bp.lvl = 125 * 256 + 230; bp.raw = 0xBC3F; bp.w4[0] = 0xBC3F; bp.w4[1] = 0x8888; bp.w4[2] = 0xFFFF; bp.w4[3] = 0x0A0B; bp.src = 11;
|
||||
favorites.factory[6][22] = 252; favorites.factory[6][23] = 188; mod_prox = 23456; break;
|
||||
case S_MENU_PROX_OFF: ui.menu = 3; ui.mlv = 1; ui.menu_sel = MI_BT; bp.conn = bp.have = 0; mod_prox = 0;
|
||||
favorites.factory[6][22] = favorites.factory[6][23] = 0; break;
|
||||
|
||||
@@ -2828,6 +2828,26 @@ 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 */
|
||||
uint16_t q[64];
|
||||
uint32_t j, ok2;
|
||||
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;
|
||||
}
|
||||
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);
|
||||
memset(&bp, 0, sizeof bp);
|
||||
}
|
||||
bt_up = 0;
|
||||
mod_prox = 0;
|
||||
#undef LV
|
||||
|
||||
+1869
-1869
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user