46 lines
813 B
C
Executable File
46 lines
813 B
C
Executable File
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#define STATE_SENSOR_BUFFER_SIZE 8
|
|
|
|
typedef struct {
|
|
uint8_t buffer[STATE_SENSOR_BUFFER_SIZE];
|
|
int front;
|
|
int rear;
|
|
int size;
|
|
} SensorBuffer;
|
|
|
|
void senbuf_init(SensorBuffer *sb);
|
|
|
|
int senbuf_is_full(SensorBuffer *sb);
|
|
|
|
int senbuf_push(SensorBuffer *sb, uint8_t value);
|
|
|
|
int senbuf_pop(SensorBuffer *sb);
|
|
|
|
void senbuf_get(SensorBuffer *sb, uint8_t *out, int lookahead);
|
|
|
|
|
|
|
|
// History Buffer
|
|
|
|
#define HISTORY_SIZE 20000
|
|
|
|
typedef struct {
|
|
uint8_t buffer[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, uint8_t value);
|
|
|
|
int hisbuf_pop(HistoryBuffer *sb);
|
|
|
|
void hisbuf_get(HistoryBuffer *sb, uint8_t *out, int lookahead);
|