aboutsummaryrefslogtreecommitdiff
path: root/barometer_sim.c
blob: 5c5b7d4deabd3f2c750a3015454bcde86f5a0283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "barometer.h"

/* Dummy pressures to return in sequence, each call to barometer_read */
static const float pressures[] = {
	1019.5,
	1019.45,
	1019.41,
	1019.33,
	1019.2,
	1019.0,
	1018.99,
	1018.91,
	1018.88,
	1018.86,
	1018.83,
	1018.82,
};
static int cursor = 0;

static void barometer_init(void)
{
	cursor = 0;
}

static float barometer_read(void)
{
	cursor %= sizeof(pressures)/sizeof(pressures[0]);
	return pressures[cursor++];
}

/**/

void get_system_barometer(struct barometer *barometer)
{
	barometer->init = barometer_init;
	barometer->read_pressure = barometer_read;
}