Skip to content

Commit 52615e7

Browse files
authored
feat(lp5817): Add commands for reading state; remove POR clear from enable (#535)
* feat(lp5817): Add commands for reading state; remove POR clear from enable * cleanup * add const * fix * improve API, docs, and example * fix sa - add missing return path
1 parent 4d74a1d commit 52615e7

File tree

2 files changed

+255
-44
lines changed

2 files changed

+255
-44
lines changed

components/lp5817/example/main/lp5817_example.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,27 @@ extern "C" void app_main(void) {
5252
// enable fading and exponential dimming on all channels
5353
using Ch = espp::Lp5817::Channel;
5454
for (auto ch : {Ch::OUT0, Ch::OUT1, Ch::OUT2}) {
55+
// enable output on the channel
56+
if (!lp.set_output_enable(ch, true, ec)) {
57+
logger.error("Failed to enable output on channel {}: {}", ch, ec.message());
58+
return;
59+
}
60+
// set the dot current (DC) according to how much current you want to drive
61+
uint8_t dc_value = 0x50; // about 80/255 of max current
62+
if (!lp.set_dot_current(ch, dc_value, ec)) {
63+
logger.error("Failed to set dot-current on channel {}: {}", ch, ec.message());
64+
return;
65+
}
66+
// enable fading on the channel
5567
if (!lp.set_fade_enable(ch, true, ec)) {
5668
logger.error("Failed to enable fading on channel {}: {}", ch, ec.message());
5769
return;
5870
}
71+
// enable exponential dimming on the channel
5972
if (!lp.set_exponential_dimming_enable(ch, true, ec)) {
6073
logger.error("Failed to enable exponential dimming on channel {}: {}", ch, ec.message());
6174
return;
6275
}
63-
if (!lp.set_output_enable(ch, true, ec)) {
64-
logger.error("Failed to enable output on channel {}: {}", ch, ec.message());
65-
return;
66-
}
6776
}
6877

6978
// Latch the settings (update)

0 commit comments

Comments
 (0)