sensors.h 1.21 KB
#ifndef SENSORS_H
#define SENSORS_H

#include <stdint.h>
#include <stdio.h>
#include "i2c.h"
#include "libwismart.h"
#include "module.h"
#include "json.h"

#define		LIGHT_ADDR		0x39
#define		DISTANCE_ADDR	0x01
#define		PRESSURE_ADDR	0x77

typedef struct {
  uint8_t ID;
  char* description;
  char* type;
  char* unit;
  char* additional_data;
} sensor;

uint8_t register_sensor(sensor sens);

//SENSOR DEFINITIONS
extern sensor light_sensor;
extern sensor ultrasound_sensor;
extern sensor pressure_sensor;

//SENSOR FUNCTIONS

//LIGHT SENSOR
uint32_t get_light_data(void);
uint16_t get_light_ch0(void);
uint16_t get_light_ch1(void);

//ULTRASONIC SENSOR
uint16_t get_distance_data(void);
void init_ultrasound(void);
uint8_t get_distance_low(void);
uint8_t get_distance_high(void);

//PRESSURE SENSOR
typedef struct {
	uint16_t AC1;
	uint16_t AC2;
	uint16_t AC3;
	uint16_t AC4;
	uint16_t AC5;
	uint16_t AC6;
	uint16_t B1;
	uint16_t B2;
	uint16_t MB;
	uint16_t MC;
	uint16_t MD;
} bmp085_callibration;

uint16_t get_pressure_data(void);
bmp085_callibration get_callibration_data(void);
char* callibration_data_csv(bmp085_callibration parameters);
void init_pressure(void);

#endif