Skip to content

Instantly share code, notes, and snippets.

@vwillcox
Created June 6, 2018 17:29
Show Gist options
  • Save vwillcox/29998c56533928fb7f43ca5f2b831a19 to your computer and use it in GitHub Desktop.
Save vwillcox/29998c56533928fb7f43ca5f2b831a19 to your computer and use it in GitHub Desktop.
Python script to show Charge of attached PiJuice module on a SchollPhat
#!/usr/bin/env python
import math
import sys
import time
import scrollphat
import json
from pijuice import PiJuice # Import pijuice module
pijuice = PiJuice(1, 0x14) # Instantiate PiJuice interface object
def millis():
return int(round(time.time() * 1000))
scrollphat.set_brightness(1)
def getcharge():
charge =pijuice.status.GetChargeLevel()
chrge = (charge['data'])
scrollphat.clear()
scrollphat.write_string(str(chrge) + "%")
scrollphat.update()
time.sleep(10)
while(True):
try:
pause_time = 0.06
getcharge()
except KeyboardInterrupt:
scrollphat.clear()
sys.exit(-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment