-
Notifications
You must be signed in to change notification settings - Fork 0
/
AD524X.h
69 lines (53 loc) · 1.28 KB
/
AD524X.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
//
// FILE: AD524X.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.03
// PURPOSE: I2C digital PotentioMeter AD5241 AD5242
// DATE: 2013-10-12
// URL:
//
// Released to the public domain
//
#ifndef AD524X_h
#define AD524X_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
#define AD524X_VERSION "0.1.03"
#define AS524X_OK 0
#define AS524X_ERROR 100
class AD524X
{
public:
AD524X();//DEFAULT CONSTRUCTOR
// address
explicit AD524X(const uint8_t);
uint8_t zeroAll();
// rdac
uint8_t read(const uint8_t);
// for debugging
uint8_t readBackRegister(); // returns the last value written in register.
// rdac value
uint8_t write(const uint8_t, const uint8_t);
// rdac value O1 O2
uint8_t write(const uint8_t, const uint8_t, const uint8_t, const uint8_t);
uint8_t setO1(const uint8_t); // HIGH / LOW
uint8_t setO2(const uint8_t); // HIGH / LOW
uint8_t getO1();
uint8_t getO2();
// rdac
uint8_t midScaleReset(const uint8_t);
//
// uint8_t shutDown();
private:
uint8_t send(const uint8_t, const uint8_t); // cmd value
uint8_t _address;
uint8_t _lastValue[2];
uint8_t _O1;
uint8_t _O2;
};
#endif
// -- END OF FILE --