diff --git a/src/motor.cpp b/src/motor.cpp index 8bc3066..41ff8d1 100644 --- a/src/motor.cpp +++ b/src/motor.cpp @@ -70,6 +70,10 @@ void MotorController::stop() { void MotorController::update() { #if CURRENT_SENSING_ENABLED static unsigned long lastPrintTime = 0; + static bool lastWasIdle = false; + static int idleDotCount = 0; + const int dotsPerLine = 50; // Print newline after this many dots + const int dotInterval = 5; // Print dot every N idle readings // Read current sensors _currentRight = readCurrentSense(R_IS_PIN); @@ -79,8 +83,37 @@ void MotorController::update() { unsigned long now = millis(); if (now - lastPrintTime >= CURRENT_LOG_INTERVAL_MS) { lastPrintTime = now; - Serial.printf("CURRENT: R=%.2fA L=%.2fA dir=%d spd=%d\n", - _currentRight, _currentLeft, _direction, _speed); + + // Check if this is an idle reading (all zeros) + bool isIdle = (_currentRight < 0.01f && _currentLeft < 0.01f && _direction == 0); + + if (isIdle) { + if (!lastWasIdle) { + // First idle after non-idle: print full line once + Serial.printf("CURRENT: R=%.2fA L=%.2fA dir=%d spd=%d\n", + _currentRight, _currentLeft, _direction, _speed); + idleDotCount = 0; + } else { + // Subsequent idle: print dot every N readings + idleDotCount++; + if (idleDotCount % dotInterval == 0) { + Serial.print("."); + if ((idleDotCount / dotInterval) % dotsPerLine == 0) { + Serial.println(); // Newline after dotsPerLine dots + } + } + } + lastWasIdle = true; + } else { + // Non-idle reading: always print full line + if (lastWasIdle && idleDotCount > 0) { + Serial.println(); // Newline after dots before full reading + } + Serial.printf("CURRENT: R=%.2fA L=%.2fA dir=%d spd=%d\n", + _currentRight, _currentLeft, _direction, _speed); + lastWasIdle = false; + idleDotCount = 0; + } } // Check for stall condition