Skip to content

Conversation

derekhe
Copy link

@derekhe derekhe commented Oct 5, 2025

Why?

My ampere values is jumping fast and that makes me very hard to know the current ampere to calibrate battery.

So having 5s and 10s average makes everything easier.

Summary by CodeRabbit

  • New Features
    • Display 5s and 10s average amperage for Motors and Power/Battery, updated live alongside current readings.
  • UI
    • Added new labels and value fields on Motors and Power tabs to show averaged amperage metrics.
  • Localization
    • Added English and Simplified Chinese translations for new average amperage labels and values.

@Copilot Copilot AI review requested due to automatic review settings October 5, 2025 11:34
Copy link
Contributor

coderabbitai bot commented Oct 5, 2025

Walkthrough

Adds 5s/10s amperage average telemetry to Motors and Power tabs. Introduces history buffers and average computations in JS, new UI elements in HTML, and corresponding i18n strings in English and Chinese. No existing keys removed; history pruned to 10s window; averages updated during existing data pull cycles.

Changes

Cohort / File(s) Summary
Localization (EN, ZH_CN)
locales/en/messages.json, locales/zh_CN/messages.json
Added strings for 5s/10s amperage averages and their value formats for Motors and Power/Battery sections.
Motors logic
src/js/tabs/motors.js
Added amperageHistory buffer; on data pull, append reading, prune >10s, compute 5s/10s averages, update new UI fields. Reset history on init.
Power logic
src/js/tabs/power.js
Added amperageHistory; on slow pull, append reading, prune >10s, compute/display 5s/10s averages in new UI hooks. Reset on init.
Motors UI
src/tabs/motors.html
Inserted two display rows/elements for 5s and 10s amperage averages with i18n labels and value spans.
Power UI
src/tabs/power.html
Added two rows after amperage row to show 5s/10s average amperage with label/value cells.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Telemetry as Telemetry Source
  participant MotorsJS as motors.js
  participant MotorsUI as motors.html

  rect rgb(245,248,255)
  note over Telemetry, MotorsUI: Motors tab data update
  Telemetry->>MotorsJS: power data (amperage, timestamp)
  MotorsJS->>MotorsJS: push reading to amperageHistory
  MotorsJS->>MotorsJS: prune readings older than 10s
  MotorsJS->>MotorsJS: compute avg(5s), avg(10s)
  MotorsJS->>MotorsUI: update 5s/10s average fields
  end
Loading
sequenceDiagram
  autonumber
  participant Telemetry as Telemetry Source
  participant PowerJS as power.js
  participant PowerUI as power.html

  rect rgb(245,255,245)
  note over Telemetry, PowerUI: Power tab slow data pull
  Telemetry->>PowerJS: amperage reading + timestamp
  PowerJS->>PowerJS: push to amperageHistory
  PowerJS->>PowerJS: prune >10s
  PowerJS->>PowerJS: compute avg(5s), avg(10s)
  PowerJS->>PowerUI: render 5s/10s average cells
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description only includes a brief “Why?” explanation and lacks all required sections from the repository’s pull request template, such as the important considerations checklist, a detailed summary of changes, testing and CI status, and branch or issue references. Please update the PR description to follow the repository template by removing the placeholder instructions and adding the necessary sections, including the important considerations checklist, a concise summary of changes, testing and CI results, branch details, and any related issue references.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely summarizes the main change of adding 5-second and 10-second ampere averaging and clearly conveys its purpose of aiding sensor calibration without extraneous detail.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e65dc56 and 027bbd1.

📒 Files selected for processing (6)
  • locales/en/messages.json (3 hunks)
  • locales/zh_CN/messages.json (3 hunks)
  • src/js/tabs/motors.js (4 hunks)
  • src/js/tabs/power.js (3 hunks)
  • src/tabs/motors.html (1 hunks)
  • src/tabs/power.html (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/js/tabs/motors.js (3)
src/js/fc.js (1)
  • FC (132-1006)
src/js/gui.js (1)
  • TABS (8-8)
src/js/localization.js (1)
  • i18n (7-7)
src/js/tabs/power.js (2)
src/js/fc.js (1)
  • FC (132-1006)
src/js/localization.js (1)
  • i18n (7-7)
🔇 Additional comments (2)
locales/en/messages.json (2)

3133-3153: New motors amperage average strings look good.

Keys and copy follow the established naming and wording pattern for the motors tab.


5349-5353: Power tab average amperage labels read well.

Labels align with adjacent entries and keep the phrasing consistent for the table.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds 5-second and 10-second rolling averages for amperage readings to help with battery sensor calibration. The amperage values currently jump rapidly, making it difficult to determine accurate current readings for calibration purposes.

  • Adds amperage history tracking with timestamp-based calculations for 5s and 10s averages
  • Updates UI in both power and motors tabs to display the averaged values
  • Adds internationalization support for the new labels in English and Chinese

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tabs/power.html Adds table rows for 5s and 10s amperage averages in the power tab
src/tabs/motors.html Adds display elements for amperage averages in the motors tab
src/js/tabs/power.js Implements amperage history tracking and average calculations for power tab
src/js/tabs/motors.js Implements amperage history tracking and average calculations for motors tab
locales/zh_CN/messages.json Adds Chinese translations for amperage average labels
locales/en/messages.json Adds English translations for amperage average labels

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +654 to +657
TABS.motors.amperageHistory.push({
value: currentAmperage,
timestamp: currentTimestamp,
});
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The amperage history array could grow indefinitely if the data collection runs for extended periods. Consider adding a maximum array size limit to prevent memory issues.

Copilot uses AI. Check for mistakes.

Copy link

sonarqubecloud bot commented Oct 5, 2025

Copy link
Contributor

github-actions bot commented Oct 5, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant