laurivosandi / sumochip

Sumorobot platform on top of CHIP board
MIT License
17 stars 13 forks source link

Statistics storage and web interface #18

Open laurivosandi opened 7 years ago

laurivosandi commented 7 years ago

We could store some significant information and make it accessible in the web interface eg as a SVG image. Here's an example for logging battery stats in an Excel file:

from datetime import datetime
from openpyxl import Workbook
from axp209 import AXP209
pmu = AXP209()
wb = Workbook()
ws = wb.active
from time import sleep

while True:
  try:
    row = datetime.now(), pmu.battery_voltage, pmu.battery_discharge_current, pmu.internal_temperature, pmu.battery_gauge
    print row
    ws.append(row)
    sleep(1)
  except KeyboardInterrupt:
    break
wb.save("samples.xlsx")