Hi there,
I’ve been hunting high and low, quite possibly in the wrong places, for a python script that will display the battery level on my pitop laptop 3. Unfortunately I still haven’t found one, what I have found seems to just display 255 over and over.
Any assistance on this would be greatly appreciated, or maybe point me in the right direction where i can find the necessary details, like anything really? I understand the battery is an i2c device, but that’s about it…
#!/usr/bin/env python
from smbus import SMBus
import time
def main():
'''
Main program function
'''
# Define registers values from datasheet
GPIOA = 0x12 # Data port A
GPIOB = 0x13 # Data port B
i2cbus = SMBus(1) # Create a new I2C bus
i2caddress = 0x10 # Address of battery?
while (True):
porta = i2cbus.read_byte_data(i2caddress, GPIOA) # Read the value of Port A
print("Port A = " + str(porta)) # print the value of Port A
portb = i2cbus.read_byte_data(i2caddress, GPIOB) # Read the value of Port B
print("Port B = " + str(portb)) # print the value of Port B
time.sleep(2)
if __name__ == "__main__":
main()