Low battery light

Post Reply
Tremont
Posts: 11
Joined: Sat Feb 15, 2020 9:12 am
languages_spoken: English
ODROIDs: Odroid Go Advance
Has thanked: 6 times
Been thanked: 3 times
Contact:

Low battery light

Post by Tremont »

Since I got my OGA, I have always had the same issue: the battery gets low and it dies without warning. Most other handheld devices that I've used give some sort of indication when the battery is low. (I've tried most of the OS images available, but I am not aware of any that do this.) So I made this python script that I have set to run when I turn on the OGA:

Code: Select all

import os
import psutil
import threading

def percent():
	threading.Timer(5.0, percent).start()
	
	if psutil.sensors_battery().percent < 11:
		os.system("echo heartbeat > /sys/bus/platform/drivers/leds-gpio/gpio_leds/leds/blue:heartbeat/trigger")
	elif psutil.sensors_battery().percent > 10:
		os.system("echo none > /sys/bus/platform/drivers/leds-gpio/gpio_leds/leds/blue:heartbeat/trigger")
    
percent()
Every five seconds it checks if the battery is lower than 11% and if it is, it turns on the "heartbeat" LED.
I am using RRVL. I am not sure if this is the best way to handle it, but it seems to work. I couldn't figure out any other way to control the LEDs.
I thought I would share it in case anyone else wanted a low battery light.
These users thanked the author Tremont for the post (total 3):
odroid (Mon Nov 30, 2020 11:28 am) • Josh86 (Tue Dec 01, 2020 4:03 am) • meveric (Mon Dec 14, 2020 9:34 pm)

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 37 times
Been thanked: 94 times
Contact:

Re: Low battery light

Post by valadaa48 »

Thanks for sharing this. I thought I had ported this feature over to RRVL from RR (RetroRoller ArchLinux) but perhaps not since you ended up building this out for good reason.

Here is the original "battery check" package for RR: https://github.com/valadaa48/retrorolle ... tery-check which appears to do the same as what you wrote except that it restores the default mmc0 indicator (blue light will blink on disk activity) instead of 'none'. I'm happy to integrate either version into RRVL proper so all users will get it next upgrade.
These users thanked the author valadaa48 for the post:
Tremont (Sat Dec 05, 2020 2:17 pm)

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest