-
Notifications
You must be signed in to change notification settings - Fork 3
/
Seeed_VEML6070.h
117 lines (83 loc) · 2.12 KB
/
Seeed_VEML6070.h
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef _SEEED_VE_H
#define _SEEED_VE_H
#include "Arduino.h"
#include "Wire.h"
#ifndef SEEED_DN_DEFINES
#define SEEED_DN_DEFINES
#ifdef SEEED_XIAO_M0
#define SERIAL_DB Serial
#elif defined(ARDUINO_SAMD_VARIANT_COMPLIANCE)
#define SERIAL_DB SerialUSB
#else
#define SERIAL_DB Serial
#endif
typedef int s32;
typedef long unsigned int u32;
typedef short s16;
typedef unsigned short u16;
typedef char s8;
typedef unsigned char u8;
typedef enum {
NO_ERROR = 0,
ERROR_PARAM = -1,
ERROR_COMM = -2,
ERROR_OTHERS = -128,
} veml_err_t;
#define CHECK_RESULT(a,b) do{if(a=b) { \
SERIAL_DB.print(__FILE__); \
SERIAL_DB.print(__LINE__); \
SERIAL_DB.print(" error code ="); \
SERIAL_DB.println(a); \
return a; \
}}while(0)
#endif
#define ENABLE 1
#define DISABLE 0
#define INT_102_STEP 0
#define INT_145_STEP 1
#define IIC_ADDR_H 0X39
#define IIC_ADDR_L 0X38
#define IIC_ADDR_ARA 0X0C
/*Three IIC address,Different functions are implemented by different addresses*/
#define ENABLE_BIT 0X01
#define INT_ENABLE_BIT 0X20
#define THRES_BIT 0X10
#define INTEGRA_BIT 0X0C
/** Divide UV index into five levels:LOW,MODERATE,HIGH,VERY_HIGH,EXTREME.
*/
typedef enum {
LOW_LEVEL = 0,
MODERATE,
HIGH_LEVEL,
VERY_HIGH,
EXTREME,
} RISK_LEVEL;
/** Tntegration time,When Rset =300kΩ,T=125ms,Rset = 600KΩ,T=-250ms
* */
typedef enum {
HALF_OF_T = 0X00,
ONE_T = 0X04,
TWO_T = 0X08,
FOUR_T = 0X0C,
} integration_time_t;
class VEML6070 {
public:
VEML6070();
~VEML6070() {}
veml_err_t clear_ack();
veml_err_t set_cmd_reg();
veml_err_t read_step(u16& step);
veml_err_t init();
veml_err_t disable();
veml_err_t enable();
veml_err_t set_interrupt(bool thre, bool stat);
veml_err_t set_integra_time(integration_time_t T);
void wait_for_ready();
RISK_LEVEL convert_to_risk_level(u16 uvs_step);
private:
u8 addr_h;
u8 addr_l;
u8 addr_ara;
u8 cmd_reg;
};
#endif