mmatyas / pegasus-frontend

A cross platform, customizable graphical frontend for launching emulators and managing your game collection.

Home Page:http://pegasus-frontend.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android battery percentage bugs out around 50-60% and displays many digits

HollyCeuin opened this issue · comments

The issue

Using the battery percentage api, if the battery percentage drops below around 59%, it will become 59.xxxxxxxxxxxxx%. This only seems to occur between 50 and 60 percent, give or take 1/2.

System info

Android 10, AYN Odin Pro (SD845)

Pegasus version

alpha16-50-g4996c0e8, 2023-05-10

Pegasus log

attached
lastrun.log

image
This is how the bug looks (it's going off-screen)

image
This is how it's supposed to look, and does once charged to a point out of the bug's range

The code used for the battery % indicator (from the Library theme but this occurs in any theme that displays a battery percentage)

Text {
	/* Lists the battery, not much more.
	 */
	id: battery

	width: contentWidth
	height: parent.height

	anchors.left: currentTime.left
	anchors.leftMargin: currentTime.contentWidth + parent.width * 0.74

	horizontalAlignment: Text.AlignLeft
	verticalAlignment: Text.AlignVCenter

	text: isNaN(api.device.batteryPercent) ? "" : api.device.batteryPercent.toFixed(2)*100 + "%"
	color: colors["text"]
	font.family: gilroyExtraBold.name
	font.pixelSize: height / 2
}

fixed by changing text to

isNaN(api.device.batteryPercent) ? "" : Math.round(api.device.batteryPercent*100) + "%"