blob: a2b3940616f529d4c3c1b50d982ec65b4cd84771 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "driver/ccs811.h"
#include "driver/gpio.h"
#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C)
#include "driver/i2c.h"
#else
#include "driver/soft_i2c.h"
#endif
#ifdef MULTIPASS_ARCH_esp8266
#define nWAKE GPIO::d5
#endif
void CCS811::init()
{
gpio.output(nWAKE);
gpio.write(nWAKE, 1);
}
short CCS811::check()
{
gpio.write(nWAKE, 0);
txbuf[0] = 0x20;
rxbuf[0] = 0;
i2c.xmit(address, 1, txbuf, 1, rxbuf);
gpio.write(nWAKE, 1);
return rxbuf[0];
}
CCS811 ccs811(0x5a);
|