/*
 * adc.h
 *
 * $Id$
*/

#ifndef __HW_ADC_H_
#define __HW_ADC_H_


#include <Arduino.h>


typedef struct AdcData {
	uint16_t raw;
	uint16_t avg[8];
	uint8_t idx;
} AdcData;


#define ADC_PIN_VBAT			34
#define ADC_PIN_HALL			36
#define ADC_PIN_LED_K			2

#define ADC_BRIGHT_THRESH_MIN	3000
#define ADC_BRIGHT_COUNT_ADD	500

#define ADC_GET_PROCESS			0x00
#define ADC_GET_RESTART			0x01
#define ADC_GET_STOP_DARK		0xff


void adc_init();

bool adc_start(int pin);
uint16_t adc_end(int pin);

bool adc_get_blocking(int pin);

uint16_t adc_val_raw(uint8_t pin);

uint16_t IRAM_ATTR adc_get_vbat();

uint16_t adc_val_brightness();
uint8_t IRAM_ATTR adc_get_brightness_c();
uint8_t IRAM_ATTR adc_get_brightness(uint8_t reset);


#endif // __HW_ADC_H
