Skip to content

Commit 1073170

Browse files
committed
fix: add sustained LED test (2s + individual cycle) and runtime logging
1 parent 2b14589 commit 1073170

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

Common Files/LogitechLED.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,24 @@ bool LogitechLED::Init()
308308
{
309309
m_available = true;
310310
Log("");
311-
Log("=== LED CONTROL ACTIVE ===");
311+
Log("=== LED CONTROL ACTIVE - SUSTAINED TEST ===");
312+
Log("Turning ALL LEDs on for 2 seconds...");
313+
314+
// Sustained test: all LEDs on for 2s
315+
SetLEDs(0x1F);
316+
Sleep(2000);
317+
318+
// Then cycle each LED individually
319+
for (int led = 0; led < 5; led++)
320+
{
321+
BYTE mask = (BYTE)(1 << led);
322+
Log(" LED %d (mask=0x%02X)", led + 1, mask);
323+
SetLEDs(mask);
324+
Sleep(500);
325+
}
326+
327+
ClearLEDs();
328+
Log("LED test complete.");
312329
return true;
313330
}
314331
}
@@ -321,6 +338,8 @@ bool LogitechLED::Init()
321338

322339
// --- Runtime LED control ---
323340

341+
static int g_setLedsCallCount = 0;
342+
324343
bool LogitechLED::SetLEDs(BYTE ledMask)
325344
{
326345
if (!m_available || m_handle == INVALID_HANDLE_VALUE)
@@ -332,7 +351,16 @@ bool LogitechLED::SetLEDs(BYTE ledMask)
332351
rpt[2] = 0x12;
333352
rpt[3] = ledMask & 0x1F;
334353

335-
return SendReport(m_handle, rpt, m_reportLen);
354+
bool ok = SendReport(m_handle, rpt, m_reportLen);
355+
356+
g_setLedsCallCount++;
357+
if (g_setLedsCallCount <= 20 || !ok)
358+
{
359+
Log("SetLEDs(0x%02X) -> %s (call #%d)", ledMask, ok ? "OK" : "FAIL", g_setLedsCallCount);
360+
if (!ok) Log(" err=%lu", GetLastError());
361+
}
362+
363+
return ok;
336364
}
337365

338366
bool LogitechLED::SetLEDsFromPercent(double percent)

0 commit comments

Comments
 (0)