Skip to content

Commit cc73f24

Browse files
committed
+ version 0.1.02
+ stricter interface
1 parent 677aaeb commit cc73f24

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

libraries/AD524X/AD524X.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define AS524X_O1_HIGH 0x10
1919
#define AS524X_O2_HIGH 0x08
2020

21-
AD524X::AD524X(uint8_t address)
21+
AD524X::AD524X(const uint8_t address)
2222
{
2323
// address: 0x01011xx = 0x2C - 0x2F
2424
_address = address;
@@ -32,7 +32,7 @@ uint8_t AD524X::zeroAll()
3232
return write(1, 0);
3333
}
3434

35-
uint8_t AD524X::write(uint8_t rdac, uint8_t value)
35+
uint8_t AD524X::write(const uint8_t rdac, const uint8_t value)
3636
{
3737
if (rdac > 1) return AS524X_ERROR;
3838

@@ -43,7 +43,7 @@ uint8_t AD524X::write(uint8_t rdac, uint8_t value)
4343
return send(cmd, value);
4444
}
4545

46-
uint8_t AD524X::write(uint8_t rdac, uint8_t value, uint8_t O1, uint8_t O2)
46+
uint8_t AD524X::write(const uint8_t rdac, const uint8_t value, const uint8_t O1, const uint8_t O2)
4747
{
4848
if (rdac > 1) return AS524X_ERROR;
4949

@@ -56,16 +56,16 @@ uint8_t AD524X::write(uint8_t rdac, uint8_t value, uint8_t O1, uint8_t O2)
5656
return send(cmd, value);
5757
}
5858

59-
uint8_t AD524X::setO1(uint8_t v)
59+
uint8_t AD524X::setO1(const uint8_t value)
6060
{
61-
_O1 = (v == LOW) ? 0 : AS524X_O1_HIGH;
61+
_O1 = (value == LOW) ? 0 : AS524X_O1_HIGH;
6262
uint8_t cmd = AS524X_RDAC0 | _O1 | _O2;
6363
return send(cmd, _lastValue[0]);
6464
}
6565

66-
uint8_t AD524X::setO2(uint8_t v)
66+
uint8_t AD524X::setO2(const uint8_t value)
6767
{
68-
_O2 = (v == LOW) ? 0: AS524X_O2_HIGH;
68+
_O2 = (value == LOW) ? 0: AS524X_O2_HIGH;
6969
uint8_t cmd = AS524X_RDAC0 | _O1 | _O2;
7070
return send(cmd, _lastValue[0]);
7171
}
@@ -80,12 +80,12 @@ uint8_t AD524X::getO2()
8080
return (_O2 > 0);
8181
}
8282

83-
uint8_t AD524X::read(uint8_t rdac)
83+
uint8_t AD524X::read(const uint8_t rdac)
8484
{
8585
return _lastValue[rdac];
8686
}
8787

88-
uint8_t AD524X::midScaleReset(uint8_t rdac)
88+
uint8_t AD524X::midScaleReset(const uint8_t rdac)
8989
{
9090
if (rdac > 1) return AS524X_ERROR;
9191

@@ -107,7 +107,7 @@ uint8_t AD524X::midScaleReset(uint8_t rdac)
107107
//
108108
// PRIVATE
109109
//
110-
uint8_t AD524X::send(uint8_t cmd, uint8_t value)
110+
uint8_t AD524X::send(const uint8_t cmd, const uint8_t value)
111111
{
112112
Wire.beginTransmission(_address);
113113
Wire.write(cmd);

libraries/AD524X/AD524X.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: AD524X.h
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.01
4+
// VERSION: 0.1.02
55
// PURPOSE: I2C digital PotentioMeter AD5241 AD5242
66
// DATE: 2013-10-12
77
// URL:
@@ -20,7 +20,7 @@
2020

2121
#include <Wire.h>
2222

23-
#define AD524X_VERSION "0.1.01"
23+
#define AD524X_VERSION "0.1.02"
2424

2525
#define AS524X_OK 0
2626
#define AS524X_ERROR -10
@@ -29,28 +29,28 @@ class AD524X
2929
{
3030
public:
3131
// address
32-
AD524X(uint8_t);
32+
AD524X(const uint8_t);
3333

3434
uint8_t zeroAll();
3535
// rdac
36-
uint8_t read(uint8_t);
36+
uint8_t read(const uint8_t);
3737
// rdac value
38-
uint8_t write(uint8_t, uint8_t);
38+
uint8_t write(const uint8_t, const uint8_t);
3939
// rdac value O1 O2
40-
uint8_t write(uint8_t, uint8_t, uint8_t, uint8_t);
40+
uint8_t write(const uint8_t, const uint8_t, const uint8_t, const uint8_t);
4141

42-
uint8_t setO1(uint8_t); // HIGH / LOW
43-
uint8_t setO2(uint8_t); // HIGH / LOW
42+
uint8_t setO1(const uint8_t); // HIGH / LOW
43+
uint8_t setO2(const uint8_t); // HIGH / LOW
4444
uint8_t getO1();
4545
uint8_t getO2();
4646

4747
// rdac
48-
uint8_t midScaleReset(uint8_t);
48+
uint8_t midScaleReset(const uint8_t);
4949
//
5050
// uint8_t shutDown();
5151

5252
private:
53-
uint8_t send(uint8_t, uint8_t); // cmd value
53+
uint8_t send(const uint8_t, const uint8_t); // cmd value
5454

5555
uint8_t _address;
5656
uint8_t _lastValue[2];

0 commit comments

Comments
 (0)