#ifndef CCS811_COMPONENT
#define CCS811_COMPONENT
#include "i2cbrn.h"
#include "mcp23018.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#define TAG_CCS "CCS811"

// CCS811 Registers
#define CCS811_REG_STATUS 0x00
#define CCS811_REG_MEAS_MODE 0x01
#define CCS811_REG_ALG_RESULT_DATA 0x02
#define CCS811_REG_RAW_DATA 0x03
#define CCS811_REG_ENV_DATA 0x05
#define CCS811_REG_THRESHOLDS 0x10
#define CCS811_REG_BASELINE 0x11
#define CCS811_REG_HW_ID 0x20
#define CCS811_REG_HW_VERSION 0x21
#define CCS811_REG_FW_BOOT_VERSION 0x23
#define CCS811_REG_FW_APP_VERSION 0x24
#define CCS811_REG_INTERNAL_STATE 0xA0
#define CCS811_REG_ERROR_ID 0xE0
#define CCS811_REG_APP_ERASE 0xF1
#define CCS811_REG_APP_DATA 0xF2
#define CCS811_REG_APP_VERIFY 0xF3
#define CCS811_REG_APP_START 0xF4
#define CCS811_REG_SW_RESET 0xFF

// Measurement Modes
#define CCS811_MODE_IDLE 0x00
#define CCS811_MODE_CONSTANT_1S 0x10
#define CCS811_MODE_CONSTANT_10S 0x20
#define CCS811_MODE_CONSTANT_60S 0x30
#define CCS811_MODE_WAKEUP 0x40

extern i2c_device_config_t CCS811_DEV_CFG;

extern i2c_master_dev_handle_t CCS811_DEV_HANDLE;

esp_err_t ccs811_init();
esp_err_t ccs811_get_data(uint16_t *eCO2, uint16_t *tvoc, uint8_t *current, uint16_t *rawData);
esp_err_t ccs811_set_env_data(float temperature, float humidity);
#endif