aboutsummaryrefslogtreecommitdiff
path: root/stm32f091/sensor.c
blob: f2e9e29c9db318a61362ffa1ff11e72791f7f6d0 (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 <FreeRTOS.h>
#include <task.h>
#include <Si7021_driver.h>

#include "sensor.h"
#include "backlog.h"

uint8_t ws_sensor_temperature() {
	float temp = 0.f;
	r_single_Si7021(&temp, Temperature);
	return (uint8_t) temp; //TODO: convert with range -> util.h
}

uint8_t ws_sensor_humidity() {
	return 0x00;
}

uint8_t ws_sensor_atmospheric_pressure() {
	return 0x00;
}

void ws_sensor_read() {
	ws_s_backlog_record record = {
		.sens_temperature = ws_sensor_temperature(),
		.sens_atm_pressure = ws_sensor_atmospheric_pressure(),
		.sens_humidity = ws_sensor_humidity()
	};
	ws_backlog_add_record(record);
}

void ws_sensor_read_task() {
	while (1) {
		ws_sensor_read();
		vTaskDelay(portTICK_PERIOD_MS * 1000 * 60);
	}
}