Announcement of Remaining Laptop Battery Charge Time - B3P15/CSC-403-nvda-project GitHub Wiki

Author: Kieran Gilpin

Description

Referenced Issue: Here

  • This feature adds the announcement of time remaining to charge a laptop until the battery reaches 100% when charging. Currently within NVDA, the keyboard shortcut "NVDA+shift+b" reads the current battery percentage, and if it is charging or not. If the battery is not charging, NVDA will also announce the amount of time the battery has remaining until it dies. If the battery is charging, all that is announced is the current battery percentage and that the battery is charging.

General Approach

  • This feature was structured as a source code change. That is, the main NVDA files were modified and build into a developer instance that is built from scratch on the local machine and compiled into the running application.
  • To implement this feature, I had to utilize WMI classes that constantly monitor aspects of different hardware and software components. Depending on what drivers are installed, varied information is available within these classes. Using the WMI classes of BatteryStatus and BatteryStaticData, the current charge rate(mW), max charge capacity(mWh), and remaining capacity(mWh) of the laptop battery can be gathered. Using this information, the time remaining in minutes was calculatable. (full - remaining) [mWh] / rate [mW] = hours * 60 = minutes

What Went Right

  • Documentation surrounding the WMI classes are plentiful, and testing in powershell to determine what properties each class has was simple.
  • Once the relevant information to my issue was located, writing a query within NVDA to fetch the current system information was easy.

What Went Wrong

  • Evidently, not all drivers are created equal. There exists a property of one of the battery classes called TimeToFullCharge. This property is exactly the information my feature is attempting to announce. However, a lot of modern hardware do not support this property, my laptop included, and simply holds a None value for the property.
  • Rather than writing code that works on some devices but not on others, I had to scour different classes to determine what baseline information would be available on all devices running NVDA.

Next Steps

  • I plan to continue contributing to the NVDA project next quarter and beyond. Working on this project has allowed me to gain valuable research skills in regard to a very large codebase. I also know to utilize every resource available to me from the start, and to build general knowledge of all areas before delving too deep into one topic.