#ifndef _history_h_ #define _history_h_ #include #define HISTORY_SIZE 20000 typedef struct HistoryEntry { uint8_t sensor; int error; } HistoryEntry; typedef struct { HistoryEntry data[HISTORY_SIZE]; int errors[HISTORY_SIZE]; int front; int rear; int size; } HistoryBuffer; void hisbuf_init(HistoryBuffer *sb); int hisbuf_is_full(HistoryBuffer *sb); int hisbuf_push(HistoryBuffer *sb, HistoryEntry entry); int hisbuf_pop(HistoryBuffer *sb); int hisbuf_pop_data(HistoryBuffer *sb, HistoryEntry *out); void hisbuf_get(HistoryBuffer *sb, HistoryEntry *out, int lookahead); #endif