-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGasesBoardTester.h
48 lines (35 loc) · 1.18 KB
/
GasesBoardTester.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
#pragma once
#include <Arduino.h>
#include <Wire.h>
// Uncomment the right include depending opn wich tester board you are using
/* #define USED_BOARD_LOOKUP "currentLookUp_Board_0.h" */
#define USED_BOARD_LOOKUP "currentLookUp_Board_1.h"
/* #define USED_BOARD_LOOKUP "currentLookUp_Board_2.h" */
/* #define USED_BOARD_LOOKUP "currentLookUp_Board_3.h" */
#include USED_BOARD_LOOKUP
extern TwoWire auxWire;
class testerGasesBoard {
public:
struct Resistor {
byte address;
byte SET;
byte READ;
};
enum ElectrodeType {ELECTRODE_W, ELECTRODE_A};
struct Electrode {
Resistor pots[2];
ElectrodeType type;
int16_t nA;
};
uint16_t totalLevels_W = sizeof CURRENT_LOOKUP_W / 2;
uint16_t totalLevels_A = sizeof CURRENT_LOOKUP_A / 2;
Electrode electrode_W = {{{0x28, 0x00, 0x0C}, {0x28, 0x010, 0x1C}}, ELECTRODE_W};
Electrode electrode_A = {{{0x2A, 0x00, 0x0C}, {0x2A, 0x010, 0x1C}}, ELECTRODE_A};
bool begin();
void setCurrent(Electrode wichElectrode, int16_t wichCurrent);
int16_t getCurrent(Electrode wichElectrode);
private:
const uint16_t DELTA_CURRENT = 1400; // nA threshold (+/- 1400)
void setPot(Resistor wichPot, uint8_t wichValue);
uint8_t readPot(Resistor wichPot);
};