-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrill.h
69 lines (56 loc) · 1.43 KB
/
Trill.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
#include <I2c.h>
class Trill : public I2c
{
private:
enum {
kCommandNone = 0,
kCommandMode = 1,
kCommandScanSettings = 2,
kCommandPrescaler = 3,
kCommandNoiseThreshold = 4,
kCommandIdac = 5,
kCommandBaselineUpdate = 6,
kCommandMinimumSize = 7,
kCommandIdentify = 255
};
enum {
kOffsetCommand = 0,
kOffsetData = 4
};
enum {
kNormalLengthDefault = 20,
kRawLength = 60
};
bool isReady;
uint8_t device_type_; // Which type of device is connected (if any)
uint8_t firmware_version_; // Firmware version running on the device
uint8_t dataBuffer[kRawLength];
uint16_t commandSleepTime = 10000;;
public:
static unsigned int constexpr numSensors = 26;
int rawData[numSensors];
enum Modes {
NORMAL = 0,
RAW = 1,
BASELINE = 2,
DIFF = 3
};
Trill();
~Trill();
Trill(int i2c_bus, int i2c_address);
int setup(int i2c_bus = 1, int i2c_address = 0x18);
void cleanup();
bool ready(){ return isReady; }
/* Update the baseline value on the sensor*/
int updateBaseLine();
int prepareForDataRead();
int readI2C();
/* Return the type of the device attached or 0 if none is attached */
int identify();
/* --- Scan configuratin settings --- */
int setMode(uint8_t mode);
int setScanSettings(uint8_t speed, uint8_t num_bits = 12);
int setPrescaler(uint8_t prescaler);
int setNoiseThreshold(uint8_t threshold);
int setIDACValue(uint8_t value);
};