From aa517e7a9788c1788d3d3aaa0bfb340c8047cdc9 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Sun, 15 Nov 2026 12:25:32 +0100 Subject: [PATCH] Extract playBleep usages into dedicated functions with unified positive/negative confirmation --- src/netdeck/NetDeck.ino | 122 +++++++++++++++++++++++++++++++--------- 1 file changed, 96 insertions(+), 26 deletions(-) diff --git a/src/netdeck/NetDeck.ino b/src/netdeck/NetDeck.ino index 7062421..1a2f465 100644 --- a/src/netdeck/NetDeck.ino +++ b/src/netdeck/NetDeck.ino @@ -236,6 +236,89 @@ static void playBleep(uint16_t freq, uint16_t durMs = 50, uint16_t amp = 16000) sound.play(e); } +// ── Positive confirmations ────────────────────────────────────── + +static void playNodeSelect() +{ + // Node selection click + playBleep(800, 20); +} + +static void playBeaconSelect() +{ + // Beacon placed on tile + playBleep(1000, 30); +} + +static void playViewCameras() +{ + // View mode → CAMERAS + playBleep(600, 20); +} + +static void playViewNetwork() +{ + // View mode → NETWORK + playBleep(400, 20); +} + +static void playFrenzy() +{ + // Frenzy activated + playBleep(800, 30); +} + +static void playBlind() +{ + // Blind optics activated + playBleep(1200, 30); +} + +static void playReset() +{ + // Scenario reset + playBleep(600, 30); +} + +// ── Negative / blocked confirmations ──────────────────────────── + +static void playBlocked() +{ + // Tile blocked / action unavailable + playBleep(200, 30); +} + +static void playNoNode() +{ + // No node available + playBleep(200, 30); +} + +static void playNoLink() +{ + // No link present at cursor + playBleep(200, 30); +} + +static void playLinkSevered() +{ + // Link severed + playBleep(300, 30); +} + +// ── Tactical feedback ──────────────────────────────────────────── + +static void playFreezeEngage() +{ + // Freeze/tactical feedback + playBleep(500, 20); +} + +static void playResume() +{ + // Resume from paused state + playBleep(500, 20); +} static void playLaser() { // Quick laser beam sound - rising sweep @@ -292,12 +375,6 @@ static void playDoorClose() sound.play(e); } -static void playNodeSelect() -{ - // Node selection click - playBleep(800, 20); -} - static void playLinkBuild() { // Link building confirmation @@ -312,13 +389,6 @@ static void playLinkActive() sound.play(e); } -static void playLinkSevered() -{ - // Link cut - short burst - SndEvent e = {SND_NOISE, 0, 0, 40, 8000}; - sound.play(e); -} - static void playIceCrack() { // ICE cracking progress - ascending tone @@ -1048,10 +1118,10 @@ static void registerClick() if (walkable(tx, ty)) { beaconTX = tx; beaconTY = ty; - playBleep(1000, 30); + playBeaconSelect(); Serial.printf("[click] beacon -> tile %d,%d\n", tx, ty); } else { - playBleep(200, 30); // blocked + playBlocked(); Serial.println("[click] blocked tile: beacon ignored"); } } else { @@ -1063,7 +1133,7 @@ static void registerClick() int d = dx * dx + dy * dy; if (d < bestD) { bestD = d; best = i; } } - if (bestD > 24 * 24) { flashMsg("NO NODE"); playBleep(200, 30); return; } + if (bestD > 24 * 24) { flashMsg("NO NODE"); playNoNode(); return; } playNodeSelect(); tryLink(best); } @@ -1077,32 +1147,32 @@ static void handleKey(char c) switch (c) { case ' ': paused = !paused; - if (paused) playBleep(500, 20); // freeze engage - else playBleep(500, 20); // resume + if (paused) playFreezeEngage(); + else playResume(); Serial.printf("[key] tactical freeze %s\n", paused ? "ON" : "OFF"); break; case 'p': case '\t': viewMode = (viewMode == VM_CAMERAS) ? VM_NETWORK : VM_CAMERAS; viewFlashUntil = millis() + 350; - if (viewMode == VM_CAMERAS) playBleep(600, 20); - else playBleep(400, 20); + if (viewMode == VM_CAMERAS) playViewCameras(); + else playViewNetwork(); Serial.printf("[key] view -> %s\n", viewMode == VM_CAMERAS ? "CAMERAS" : "NETWORK"); break; case '1': case '2': if (heatT > 0) { flashMsg("OVERHEAT"); break; } - if (!nodeOnline[N_HIVE]) { flashMsg("NO HIVE LINK"); playBleep(200, 30); break; } + if (!nodeOnline[N_HIVE]) { flashMsg("NO HIVE LINK"); playNoLink(); break; } // FRENZY.EXE (1) or BLIND_OPTICS.SH (2) — land in Milestone 4 if (c == '1') { // FRENZY: droids attack everyone within sphere of influence frenzyT = 300; // 6 seconds @ 50 ms tick - if (frenzyT > 0) playBleep(800, 30); // FRENZY + if (frenzyT > 0) playFrenzy(); Serial.printf("[key] frenzy armed (effect lands in M4)\n", c); flashMsg("FRENZY ACTIVE"); } else { // BLIND_OPTICS.SH: enemies cannot target marines for a short time blindT = 300; // 6 seconds @ 50 ms tick - playBleep(1200, 30); // BLIND + playBlind(); Serial.printf("[key] blind armed (effect lands in M4)\n", c); flashMsg("BLIND ACTIVE"); } @@ -1112,16 +1182,16 @@ static void handleKey(char c) int li = hoverLink(); if (li >= 0) { severLink(li); - playBleep(300, 30); // link severed + playLinkSevered(); } else { flashMsg("NO LINK HERE"); - playBleep(200, 30); // no link + playNoLink(); } break; } case 'r': Serial.println("[key] RESET"); - playBleep(600, 30); // reset + playReset(); resetScenario(); Serial.println("[reset] scenario re-armed (paused)"); break;