-
Notifications
You must be signed in to change notification settings - Fork 1
/
tsd305lib.h
48 lines (41 loc) · 1.09 KB
/
tsd305lib.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
/*
* Description : Header file of TSD305 Sensor (by TEConnectivity) for Arduino platform.
* Author : Pranjal Joshi
* Date : 25/05/2020
* License : MIT
* This code is published as open source software. Feel free to share/modify.
*/
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
struct tsd_eeprom_struct {
int16_t amb_min;
int16_t amb_max;
int16_t obj_min;
int16_t obj_max;
int16_t adc_cal;
};
class tsd305 {
public:
tsd305();
tsd_eeprom_struct begin(void);
tsd_eeprom_struct begin(bool debug);
bool isConnected(void);
float getSensorTemp(void);
float getObjectTemp(void);
float DtoF(float temp);
private:
uint16_t tsdReadCoef(uint8_t addr);
float tsdReadFloat(uint8_t addr);
tsd_eeprom_struct tsdReadEeprom(void);
void tsdReadADCs(uint32_t *amb, uint32_t *obj);
float getTCF(void);
void tsdGetTempCompensation(float *offset, float *offsettc);
// fixed parameters which can be read from EEPROM once only
float tc, tref;
float k4,k3,k2,k1,k0;
float tk4,tk3,tk2,tk1,tk0;
tsd_eeprom_struct s;
};