b-parasite-esp32/code/nrf-connect/prstlib/include/prstlib/adc.h
rbaron 5ceccfafcc Extracts prstlib
Moves ble sample to code/nrf-connect/samples
2022-11-27 18:37:42 +01:00

34 lines
No EOL
738 B
C

#ifndef _PRST_ADC_H_
#define _PRST_ADC_H_
#include <stdint.h>
typedef struct {
int16_t raw;
int32_t millivolts;
float voltage;
} prst_adc_read_t;
typedef struct {
prst_adc_read_t adc_read;
// A value from 0 (completely dry) to 2^10 (completely wet).
uint16_t relative;
// In [0, 1.0].
float percentage;
} prst_adc_soil_moisture_t;
typedef struct prst_adc_photo_sensor {
prst_adc_read_t adc_read;
// Value in lux.
uint16_t brightness;
} prst_adc_photo_sensor_t;
int prst_adc_init();
int prst_adc_batt_read(prst_adc_read_t* out);
int prst_adc_soil_read(float battery_voltage, prst_adc_soil_moisture_t* out);
int prst_adc_photo_read(float battery_voltage, prst_adc_photo_sensor_t* out);
#endif // _PRST_ADC_H_