Add a battery check and minor refactoring of main.cpp. - #145
Open
Charles-Mahoudeau wants to merge 6 commits into
Open
Add a battery check and minor refactoring of main.cpp.#145Charles-Mahoudeau wants to merge 6 commits into
Charles-Mahoudeau wants to merge 6 commits into
Conversation
…rganize it for better program flow.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the startup sequence into modular functions, upgrades logging with distinct levels, and improves battery error handling/display.
- Modularized
initintoinitGraphics,checkBattery,initStorage,initLibSystem, andregisterEventHandlers - Replaced the generic
logfunction withinfo,warn, anderror, and deprecated the old API - Changed battery API to return
-1.0on error and show “X” in the UI when level is invalid
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.cpp | Broke init into smaller functions and added battery checks |
| lib/system/libsystem.hpp | Deprecated log, added info, warn, error declarations |
| lib/system/libsystem.cpp | Implemented new logging methods and updated registerBootError |
| lib/gsm/src/gsm2.cpp | Return -1.0 for invalid battery voltage |
| lib/applications/src/launcher.cpp | Display “X” when battery level is invalid |
Member
Author
|
This is not working due to the fact that the GSM module is taking up to 15 seconds to initialize, making the use of battery level invalid before that. |
paxo-rch
approved these changes
Jul 12, 2025
paxo-rch
reviewed
Jul 17, 2025
| libsystem::info("Battery check skipped by HOME button press."); | ||
| return true; | ||
| } | ||
| if (Gsm::getBatteryLevel() < 0.0) { |
Contributor
There was a problem hiding this comment.
Il faudrait enlever le check de la batterie pour valider la PR, tu peux corriger ça?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the initialization process, improves logging capabilities, and enhances battery management logic. Key changes include splitting the
initfunction into modular components, introducing new logging methods, and refining battery level handling.Refactoring Initialization Process:
src/main.cpp: Split theinitfunction into modular components (initGraphics,checkBattery,initStorage,initLibSystem, andregisterEventHandlers) for better readability and maintainability. Added conditional checks to handle initialization errors gracefully. [1] [2]Logging Enhancements:
lib/system/libsystem.cpp: Introduced new logging methods (info,warn,error) to replace the genericlogfunction. Updated existing calls to use these methods for better log categorization.lib/system/libsystem.hpp: Deprecated thelogfunction and added documentation for the new logging methods.Battery Management Improvements:
lib/applications/src/launcher.cpp: Enhanced battery label logic to display "X" when the battery level is invalid (negative). [1] [2]lib/gsm/src/gsm2.cpp: Updated thegetBatteryLevelfunction to return-1.0when the battery voltage is invalid, signaling an error state.Minor Fixes and Code Cleanup:
lib/system/libsystem.cpp: Added aFIXMEcomment ingetSystemConfigregarding potential shared pointer copying.lib/system/libsystem.hpp: Removed an unused#include <cstdint>directive.