Created
June 6, 2018 17:29
-
-
Save vwillcox/29998c56533928fb7f43ca5f2b831a19 to your computer and use it in GitHub Desktop.
Python script to show Charge of attached PiJuice module on a SchollPhat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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