Example #1
0
def main():
    cursor = db.cursor()
    cursor.execute("SELECT * from Products")
    data = cursor.fetchone()
    if data is None:
        print("Logged in wrong")
    else:
        print(str(data))
    target = 15
    maxTemp = 20
    LEDColour.setup(target, maxTemp, True)
    while True:
        temp = round(temperature.getTemperature(), 1)  # get temperature
        doorOpen = doorStatus.getDoorStatus()
        changeLED.changeLED(LEDColour.getLEDColour(temp))
        time.sleep(1)
        updateTime = strftime("%Y-%m-%d %H:%M:%S", gmtime())
        with open("../data.json", "w") as outfile:
            json.dump(
                {
                    "time": updateTime,
                    "temp": temp,
                    "target": target,
                    "doorOpen": doorOpen,
                    "products": [
                        {"pid": 1, "name": "sandwich", "date": "14-01-2016"},
                        {"pid": 2, "name": "cucumber", "date": "15-01-2016"},
                    ],
                },
                outfile,
                sort_keys=True,
                indent=4,
                separators=(",", ": "),
            )
Example #2
0
def main():
    LEDColour.test()
    LEDColour.setup(15, 20, True)
    while (True):
        #temp = temp + 0.01 # test value as get temperature doesnt work
        temp = round(temperature.getTemperature(), 1)
        RGB = LEDColour.getLEDColour(temp)
        changeLED.changeLED(RGB)
        time.sleep(0.2)
Example #3
0
def main():
    cursor = db.cursor()
    cursor.execute("SELECT * from Products")
    data = cursor.fetchone()
    if data is None:
        print("Logged in wrong")
    else:
        print(str(data))
    target = 15
    maxTemp = 20
    LEDColour.setup(target, maxTemp, True)
    while (True):
        temp = round(temperature.getTemperature(), 1)  #get temperature
        doorOpen = doorStatus.getDoorStatus()
        changeLED.changeLED(LEDColour.getLEDColour(temp))
        time.sleep(1)
        updateTime = strftime("%Y-%m-%d %H:%M:%S", gmtime())
        with open('../data.json', 'w') as outfile:
            json.dump(
                {
                    'time':
                    updateTime,
                    'temp':
                    temp,
                    'target':
                    target,
                    'doorOpen':
                    doorOpen,
                    'products': [
                        {
                            'pid': 1,
                            'name': "sandwich",
                            'date': "14-01-2016"
                        },
                        {
                            'pid': 2,
                            'name': "cucumber",
                            'date': "15-01-2016"
                        },
                    ]
                },
                outfile,
                sort_keys=True,
                indent=4,
                separators=(',', ': '))