def get_accelerometer_data(self):
        # Sort the data
        all_data = sorted(LogEntry.select(), key=lambda row: datetime.strptime(row.timestamp, self.time_stamp_format))
        accelerometer_data = [{"timestamp": row.timestamp, "light": row.light_reading, "proximity": row.proximity_reading,
            "x": row.x_reading, "y": row.y_reading, "z": row.z_reading} for row in all_data]

        return accelerometer_data
    def get_accelerometer_data(self):
        # Sort the data
        all_data = sorted(LogEntry.select(),
                          key=lambda row: datetime.strptime(
                              row.timestamp, self.time_stamp_format))
        accelerometer_data = [{
            "timestamp": row.timestamp,
            "light": row.light_reading,
            "proximity": row.proximity_reading,
            "x": row.x_reading,
            "y": row.y_reading,
            "z": row.z_reading
        } for row in all_data]

        return accelerometer_data
def plot_data():
    format_string = '%H:%M:%S %m/%d/%Y'

    log_data = LogEntry.select().order_by(LogEntry.timestamp)
    # log_data = [row for row in log_data]
    log_data = sorted(log_data, key=lambda row: datetime.strptime(row.timestamp, format_string))

    light_readings = [row.light_reading for row in log_data]
    light_readings = [min(reading, 100.0) for reading in light_readings]
    timestamps = [datetime.strptime(row.timestamp, format_string) for row in log_data]

    fig = plt.figure()
    # plt.figure(1, figsize=(10, 6))
    plt.clf()
    plt.cla()

    plt.plot_date(timestamps, light_readings, 'b')
    fig.autofmt_xdate()
    plt.show()
def load_light():
    light_data = LogEntry.select()
    return sorted(
        light_data,
        key=lambda row: datetime.strptime(row.timestamp, format_string))
def load_light():
    light_data = LogEntry.select()
    return sorted(light_data, key=lambda row: datetime.strptime(row.timestamp, format_string))
def get_light_data():
    light_data = LogEntry.select()

    return light_data