-
Notifications
You must be signed in to change notification settings - Fork 0
/
K30.h
53 lines (43 loc) · 1.62 KB
/
K30.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
#ifndef __WICKED_DEVICE_K30__
#define __WICKED_DEVICE_K30__
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <HardwareSerial.h>
#include <stdint.h>
class K30 {
public:
K30(HardwareSerial * serial);
K30(SoftwareSerial * swserial);
void setSerial(HardwareSerial *serial);
void setSerial(SoftwareSerial *serial);
boolean getSample(float * result);
boolean readABCPeriod(uint32_t * result);
boolean enableABC(uint16_t periodInHours); // 180 is the default
boolean disableABC(void);
boolean calibrateToBackground(void);
boolean calibrateToNitrogen(void);
private:
HardwareSerial * hwserial;
SoftwareSerial * swserial;
static uint16_t wCRCTable[];
boolean serialBeginCalled;
void resetSerial();
void endSerial();
int read();
int available();
void beginSerial();
void write(uint8_t * value, int size);
void write(uint8_t value);
boolean requestResponse(uint8_t * request, uint8_t requestLength, uint8_t * response, uint8_t expectedResponseLength);
boolean requestResponseOnce(uint8_t * request, uint8_t requestLength, uint8_t * response, uint8_t expectedResponseLength);
uint16_t extractUint16Field(uint8_t * response, uint8_t byteOffset);
void clearCO2SerialInput(void);
uint16_t co2_CRC16 (const uint8_t *nData, uint16_t wLength);
boolean co2ResponseMatchesRequest(uint8_t * request, uint8_t * response, uint8_t num);
boolean clearCalibrationAcknowledgements(void);
boolean startBackgroundCalibration(void);
boolean startNitrogenCalibration(void);
boolean checkBackgroundCalibrationComplete(boolean * status);
boolean checkNitrogenCalibrationComplete(boolean * status);
};
#endif