/*
 * Copyright (c) 2016, Natacha Porté
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <pebble.h>

#include "global.h"

struct __attribute__((__packed__)) entry {
	time_t time;
	uint8_t id;
};

#define PAGE_LENGTH (PERSIST_DATA_MAX_LENGTH / sizeof(struct entry))

struct entry page[PAGE_LENGTH];
uint16_t next_index = 0;


void
record_event(uint8_t id) {
	if (!id) return;
	page[next_index].time = time(0);
	page[next_index].id = id;
	next_index = (next_index + 1) % PAGE_LENGTH;
}

Add a skeleton for a unit to manipulate and display the event log
Add a skeleton for a unit to manipulate and display the event log