#!/usr/bin/env python3
import time
import datetime
import board

import adafruit_veml7700
import adafruit_bh1750

i2c = board.I2C()

veml7700=adafruit_veml7700.VEML7700(i2c)
bh1750=adafruit_bh1750.BH1750(i2c)


logFile=open('lightLog.txt','w')
while True:
    tH=time.strftime('%H', time.localtime())
    time.sleep(1)
    while int(tH) <= 7:
        ti=datetime.datetime.now()
        logFile.write("Ambient Light: %d lux\n" % veml7700.light)
        logFile.write("Light: %d lux\n" % bh1750.lux)
        logFile.write(ti.strftime("%I:%M %p %d/%m/%y\n"))
        logFile.flush()
        print("Ambient Light: %d lux" % veml7700.light) # print statements are for debugging
        print("Light: %d lux" % bh1750.lux)
        print(ti.strftime("%I:%M %p %d/%m/%y\n"))
        time.sleep(60.0)
    else:
        logFile.close()
        print("out of time")
        quit("after 7 am")