Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New app: Battery monitor #1147

Merged
merged 6 commits into from Dec 12, 2023
Merged

New app: Battery monitor #1147

merged 6 commits into from Dec 12, 2023

Conversation

Sichroteph
Copy link
Member

@Sichroteph Sichroteph commented Sep 11, 2023

Video demonstration with pauses can be found at this link: https://www.youtube.com/watch?v=LN0TsBMzrZU.

This tool enables to track and monitor historical battery charge while also providing an estimate of the remaining gaming time.

Key points to note:

  • It remains device-independent, even if you switch SD cards to another device. It also continue to monitor if the user switch profile.
  • The log database only adds/update a new entry only when a significant battery increment is detected. It employs a "duration" integer to record the time spent in a specific battery state. It performs a final update upon detecting a SIGTERM or a change in the charging state.
  • The log database follows a FILO (First-In, Last-Out) management strategy to limit its size.
  • It has been tested to ensure there are no memory leaks.

Limitations:

  • Due to the battery-friendly nature of batmon, there may be up to a 5-minute delay in the graph compared to the real battery state. It is not really noticeable.

Important considerations:

  • The blueprint background is likely under a license.
  • A full distro compilation is yet to be done is order to check if the automatic compilation/placement is done right.

Ideas for future enhancements:

  • Batmon could now easily detect the number of battery cycles.
  • By adding the removed elements values by the FILO logic, batmon could also record the total device runtime.
  • Including the rom_id in the database could enable tracking and comparing core consumption, resulting also in a cool graph.
  • The graph engine could be modified to display a straight or curved line instead of stairs. The code already contains a working line drawing function for this purpose. Additionally, a fully transparent background could enhance the graph, although it may slow down rendering.

Testing files available:

  • For viewing the same graph as shown in the video (recommended for immediate UI testing):
    View_test.zip
    Usage: Copy the contents of the zip file to the SD card and place the deviceSN file in the /tmp/ folder just before launching the app.

  • Fully functional feature:
    Fully_functional_test.zip
    Usage: Copy these files to your SD card. Please note that there won't be any graph to view yet, be patient :)

In the .h files, several parameters can be adjusted, such as:

  • The threshold to trigger an update.
  • The maximum size of the FILO list.
  • The maximum duration before an update (not typically used but may be relevant if the device stays at 0% before shutting down for a long time).

In the battery monitor UI app, here are the parameters worth mentioning :

  • GRAPH_LINE_WIDTH: Set the line width for the graph.
  • GRAPH_BACKGROUND_OPACITY: Adjust the opacity of the graph background.
  • GRAPH_MAX_FULL_PAGES: Specify the size of the canvas.
  • GRAPH_DISPLAY_DURATION: Define the duration of the visible graph area.
  • GRAPH_PAGE_SCROLL_SMOOTHNESS: Control the page increments during graph scrolling.
  • GRAPH_MIN_SESSION_FOR_ESTIMATION: Specify the minimum duration of unplugged sessions required for initial estimations (20 minutes).
  • GRAPH_MAX_PLAUSIBLE_ESTIMATION: Set the maximum plausible estimation duration.

@Aemiii91 Aemiii91 modified the milestones: v4.2, v4.3 Sep 25, 2023
@Aemiii91 Aemiii91 changed the title FEAT : Battery monitor FEAT: Battery monitor Sep 25, 2023
@Aemiii91 Aemiii91 added the enhancement New or improved feature label Oct 3, 2023
clang-format changed order of 2 includes
nake requires tabs instead of spaces
Copy link
Member

@tGecko tGecko left a comment

Choose a reason for hiding this comment

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

works perfectly from a fresh build!

static/build/.tmp_update/runtime.sh Outdated Show resolved Hide resolved
Co-authored-by: tGecko <tGecko@proton.me>
@schmurtzm schmurtzm added this pull request to the merge queue Dec 12, 2023
Merged via the queue into main with commit b36a5f6 Dec 12, 2023
3 checks passed
@schmurtzm schmurtzm deleted the Feat-battery-monitor branch December 12, 2023 00:32
@edmunek
Copy link
Contributor

edmunek commented Jan 8, 2024

is it really working for anyone. updated to onion os 4.3 beta. app is showing the blue background but it is never showing any results

@Sichroteph
Copy link
Member Author

is it really working for anyone. updated to onion os 4.3 beta. app is showing the blue background but it is never showing any results

Can you zip and send us the saves/common folder?

@edmunek
Copy link
Contributor

edmunek commented Jan 9, 2024

Can you zip and send us the saves/common folder?

Common.zip

the battery log (well, the sqlite to be more precise) seems empty to me.

Checking what is in yours fully_functional_test.zip and comparing the files on my Miyoo, so far I can't find the difference.
The runtime.sh on the console in line 35 has the batmon starting point.

Thinking if my console is any different to any other ones, I am using BetterWifi, Syncthing and LogoTweak v3.0.4
Don't know if it would affect the batterymon app (was thinking that maybe syncthing can have an affect as it boots with the system but so far haven't found any confirmation of that loose theory)

edit:
hmm.. ok..
just to test. went to package manager, unselected the battery monitor tool.
saved the changes. restarted the console, PackageManager no longer opens and the console is stuck (frozen).
microSD card checked, no errors (it is a genuine, normal proper microSD card).
Well... that sucks... :/

edit (couple of hours later).
Took a full backup of my sd card. Reinstalled the onionos 4.3 beta update. The package manager is working again.
From PackageManager selected the BatteryMonitor and it is still the same. can see the diagram but with no values. There isn't anything in SESSION: or CURRENT
(even after waiting for 20 minutes)

Screenshot attached:
BatteryMonitorUI_000

@bteamfox
Copy link

bteamfox commented Jan 20, 2024

I updated from 4.2.3 to the Beta 4.3. (8ae761f), When I run the Battery App there is no data. Does not matter how long I leave the MM+ running. I tried using package manager to uninstall and reinstall the Battery App but it made no difference.

This is the first time using the Battery App so I have not downloaded any test files etc as I assumed installing the Battery App would just work?
PS I had installed the first Beta 4.3(can not remember first version number) and installed the Battery Monitor but every time I launched the Battery app the app did not start it just returned to the ui. Then you launched 4.3. (8ae761f) which allowed the app to run but no data. Maybe the first beta broke something?
Common.zip

@Aemiii91 Aemiii91 changed the title FEAT: Battery monitor New app: Battery monitor Jan 24, 2024
@bteamfox
Copy link

Battery Monitor possible Fix.
1.Updated to version 4.3.0 RC-b66469de
battery_logs.sqlite remained empty.

  1. I deleted the file SDCARD/Saves/Common/battery_logs.sqlite
  2. I ran the Battery monitor app. (This recreated the battery_logs.sqlite file)
    When I opened the battery log File it had one line in it. “SQLite format 3”
    I was not sure at this point if the problem was fixed so. I went to package manager.
  3. I uninstalled Activity Tracker and reinstalled.
    Since doing this the Battery Monitor now has a graph.
    BatteryMonitorUI_000
    batter_logs.sqlite.zip

I wonder if anyone with this issue could try to rename your current battery_log.sqlite then run Battery Monitor and see if it starts working.

I’m interested to see if that is the fix. Or was it Uninstalling and reinstalling Activity Tracker.
Maybe 4.3.RC update?

Thanks hope this helps someone.

@Sichroteph
Copy link
Member Author

Sichroteph commented Jan 25, 2024

@bteamfox Thanks for your feedbacks. Maybe your SQLite file was corrupted and deleting forced the system to create a fresh new one. Not sure what is causing this, maybe a table update from a previous onion version.

@edmunek
Copy link
Contributor

edmunek commented Jan 25, 2024

I wonder if anyone with this issue could try to rename your current battery_log.sqlite then run Battery Monitor and see if it starts working.

So. I deleted the whole folder, uninstalled Activity Tracker, Installed it again and opened BatteryMonitor
No change.

Opened the battery monitor log and confirmed that it contains the same line.
Uninstalled activity tracker. Restarted MiyooMiniPlus, opened battery monitor, found that graph is working, installed Activity Tracker, checked Battery Monitor again - graph is still there.

Seems I am not the only one who has this issue and I wouldn't be surprised if there is many, many more like us but they wouldn't have a clue that they have this app now and definitely wouldn't know how to report that it isn't working for them.
(in short words, I doubt only 2-3 users had the same issue and somehow the same weird fix resolved the problem).

BatteryMonitorUI_003

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New or improved feature
Projects
Status: Done / Ready for release
Development

Successfully merging this pull request may close these issues.

None yet

6 participants