convenience function
This commit is contained in:
parent
cc7035c7a9
commit
6b4c156ae0
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS "sensirion_common.c" "sensirion_i2c.c" "sensirion_i2c_hal.c" "scd4x_i2c.c"
|
||||
idf_component_register(SRCS "sensirion_common.c" "sensirion_i2c.c" "sensirion_i2c_hal.c" "scd4x_i2c.c" "scd4x_config.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES "driver")
|
||||
REQUIRES driver nvs_flash)
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef SCD4X_DATA_H
|
||||
#define SCD4X_DATA_H
|
||||
|
||||
#include "nvs_flash.h"
|
||||
|
||||
struct scd4x_data {
|
||||
uint16_t co2;
|
||||
int32_t temperature;
|
||||
@ -11,7 +13,10 @@ typedef struct scd4x_data scd4x_data_t;
|
||||
struct scd4x_config {
|
||||
scd4x_data_t* measure;
|
||||
uint16_t delay;
|
||||
uint8_t mode;
|
||||
};
|
||||
typedef struct scd4x_config scd4x_config_t;
|
||||
|
||||
scd4x_config_t* get_sensor_configuration(nvs_handle_t nvs);
|
||||
|
||||
#endif
|
||||
|
17
scd4x_config.c
Normal file
17
scd4x_config.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include "nvs_flash.h"
|
||||
|
||||
#include "scd4x_data.h"
|
||||
|
||||
scd4x_config_t* get_sensor_configuration(nvs_handle_t nvs){
|
||||
scd4x_data_t* data = malloc(sizeof(scd4x_data_t));
|
||||
uint16_t conf = 0;
|
||||
ESP_ERROR_CHECK(nvs_get_u16(nvs, "sensor_conf", &conf));
|
||||
|
||||
scd4x_config_t* config = malloc(sizeof(scd4x_config_t));
|
||||
*config = (scd4x_config_t) {
|
||||
.measure = data,
|
||||
.delay = (conf >> 2),
|
||||
.mode = (conf & 0b11)
|
||||
};
|
||||
return config;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user