Extract playBleep usages into dedicated functions with unified positive/negative confirmation

This commit is contained in:
Dejvino
2026-11-15 12:25:32 +01:00
parent 7df1a2d785
commit aa517e7a97
+96 -26
View File
@@ -236,6 +236,89 @@ static void playBleep(uint16_t freq, uint16_t durMs = 50, uint16_t amp = 16000)
sound.play(e); 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() static void playLaser()
{ {
// Quick laser beam sound - rising sweep // Quick laser beam sound - rising sweep
@@ -292,12 +375,6 @@ static void playDoorClose()
sound.play(e); sound.play(e);
} }
static void playNodeSelect()
{
// Node selection click
playBleep(800, 20);
}
static void playLinkBuild() static void playLinkBuild()
{ {
// Link building confirmation // Link building confirmation
@@ -312,13 +389,6 @@ static void playLinkActive()
sound.play(e); sound.play(e);
} }
static void playLinkSevered()
{
// Link cut - short burst
SndEvent e = {SND_NOISE, 0, 0, 40, 8000};
sound.play(e);
}
static void playIceCrack() static void playIceCrack()
{ {
// ICE cracking progress - ascending tone // ICE cracking progress - ascending tone
@@ -1048,10 +1118,10 @@ static void registerClick()
if (walkable(tx, ty)) { if (walkable(tx, ty)) {
beaconTX = tx; beaconTX = tx;
beaconTY = ty; beaconTY = ty;
playBleep(1000, 30); playBeaconSelect();
Serial.printf("[click] beacon -> tile %d,%d\n", tx, ty); Serial.printf("[click] beacon -> tile %d,%d\n", tx, ty);
} else { } else {
playBleep(200, 30); // blocked playBlocked();
Serial.println("[click] blocked tile: beacon ignored"); Serial.println("[click] blocked tile: beacon ignored");
} }
} else { } else {
@@ -1063,7 +1133,7 @@ static void registerClick()
int d = dx * dx + dy * dy; int d = dx * dx + dy * dy;
if (d < bestD) { bestD = d; best = i; } 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(); playNodeSelect();
tryLink(best); tryLink(best);
} }
@@ -1077,32 +1147,32 @@ static void handleKey(char c)
switch (c) { switch (c) {
case ' ': case ' ':
paused = !paused; paused = !paused;
if (paused) playBleep(500, 20); // freeze engage if (paused) playFreezeEngage();
else playBleep(500, 20); // resume else playResume();
Serial.printf("[key] tactical freeze %s\n", paused ? "ON" : "OFF"); Serial.printf("[key] tactical freeze %s\n", paused ? "ON" : "OFF");
break; break;
case 'p': case '\t': case 'p': case '\t':
viewMode = (viewMode == VM_CAMERAS) ? VM_NETWORK : VM_CAMERAS; viewMode = (viewMode == VM_CAMERAS) ? VM_NETWORK : VM_CAMERAS;
viewFlashUntil = millis() + 350; viewFlashUntil = millis() + 350;
if (viewMode == VM_CAMERAS) playBleep(600, 20); if (viewMode == VM_CAMERAS) playViewCameras();
else playBleep(400, 20); else playViewNetwork();
Serial.printf("[key] view -> %s\n", Serial.printf("[key] view -> %s\n",
viewMode == VM_CAMERAS ? "CAMERAS" : "NETWORK"); viewMode == VM_CAMERAS ? "CAMERAS" : "NETWORK");
break; break;
case '1': case '2': case '1': case '2':
if (heatT > 0) { flashMsg("OVERHEAT"); break; } 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 // FRENZY.EXE (1) or BLIND_OPTICS.SH (2) — land in Milestone 4
if (c == '1') { if (c == '1') {
// FRENZY: droids attack everyone within sphere of influence // FRENZY: droids attack everyone within sphere of influence
frenzyT = 300; // 6 seconds @ 50 ms tick 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); Serial.printf("[key] frenzy armed (effect lands in M4)\n", c);
flashMsg("FRENZY ACTIVE"); flashMsg("FRENZY ACTIVE");
} else { } else {
// BLIND_OPTICS.SH: enemies cannot target marines for a short time // BLIND_OPTICS.SH: enemies cannot target marines for a short time
blindT = 300; // 6 seconds @ 50 ms tick blindT = 300; // 6 seconds @ 50 ms tick
playBleep(1200, 30); // BLIND playBlind();
Serial.printf("[key] blind armed (effect lands in M4)\n", c); Serial.printf("[key] blind armed (effect lands in M4)\n", c);
flashMsg("BLIND ACTIVE"); flashMsg("BLIND ACTIVE");
} }
@@ -1112,16 +1182,16 @@ static void handleKey(char c)
int li = hoverLink(); int li = hoverLink();
if (li >= 0) { if (li >= 0) {
severLink(li); severLink(li);
playBleep(300, 30); // link severed playLinkSevered();
} else { } else {
flashMsg("NO LINK HERE"); flashMsg("NO LINK HERE");
playBleep(200, 30); // no link playNoLink();
} }
break; break;
} }
case 'r': case 'r':
Serial.println("[key] RESET"); Serial.println("[key] RESET");
playBleep(600, 30); // reset playReset();
resetScenario(); resetScenario();
Serial.println("[reset] scenario re-armed (paused)"); Serial.println("[reset] scenario re-armed (paused)");
break; break;