Skip to content

Commit d291930

Browse files
committed
Tested working.
1 parent 2e831e2 commit d291930

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ Created & maintained by Max Chan.
77
This driver interfaces the microcontroller with the Microchip MCP41xxx/42xxx
88
digital potentiometers and MCP43xxx/44xxx digital rheostats.
99

10-
## Device numbering
10+
## Device addressing
1111

1212
This driver supports a daisy-chained string of digi-pots sharing a single chip
1313
select line. Device 0 is the first pot on the chip closest to the MCU. Only
1414
MCP42xxx and MCP44xxx can daisy chain, but MCP41xxx and MCP43xxx can be at the
1515
end of a chain.
1616

17-
When using a lone MCP41xxx/43xxx digi-pot, address device 0.
17+
When using a lone MCP41xxx/43xxx digi-pot, you can call `analogWrite` without
18+
the device address.
1819

1920
## Shutdown Mode
2021

src/MCP41xxx.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ void MCP41xxx::begin(void)
2323
pinMode(_ss, OUTPUT);
2424
}
2525

26+
void MCP41xxx::analogWrite(uint16_t value)
27+
{
28+
analogWrite(0, value);
29+
}
30+
2631
void MCP41xxx::analogWrite(uint8_t gate, uint16_t value)
2732
{
2833

src/MCP41xxx.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,22 @@ class MCP41xxx
3131
*/
3232
void begin(void);
3333

34+
/*!
35+
Write a value to the DAC chip.
36+
37+
@param value The DAC value. It is capped to 10 bits and excessive bits are
38+
ignored.
39+
*/
40+
void analogWrite(uint16_t value);
41+
3442
/*!
3543
Write a value to the DAC chip.
3644
45+
@param gate The ID of the DAC.
3746
@param value The DAC value. It is capped to 10 bits and excessive bits are
3847
ignored.
3948
*/
40-
void analogWrite(uint8_t gate = 0, uint16_t value);
49+
void analogWrite(uint8_t gate, uint16_t value);
4150
};
4251

4352
#endif // !defined(_TLC5615_H_)

0 commit comments

Comments
 (0)