From b32ac8fe0c4e36dcedc25c12afb48d569fc11822 Mon Sep 17 00:00:00 2001 From: beammeup0x <98652152+beammeup0x@users.noreply.github.com> Date: Sat, 29 Jan 2022 15:52:09 +0100 Subject: [PATCH 1/2] fixed LED driver clock setting in function ledDriverInit() --- src/SparkFunSX1509.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/SparkFunSX1509.cpp b/src/SparkFunSX1509.cpp index 9671a8a..0d103d9 100644 --- a/src/SparkFunSX1509.cpp +++ b/src/SparkFunSX1509.cpp @@ -284,11 +284,17 @@ void SX1509::ledDriverInit(uint8_t pin, uint8_t freq /*= 1*/, bool log /*= false // Use configClock to setup the clock divder if (_clkX == 0) // Make clckX non-zero { - _clkX = 2000000.0 / (1 << (1 - 1)); // Update private clock variable + // _clkX = 2000000.0 / (1 << (1 - 1)); // Update private clock variable + _clkX = 2000000.0; + clock(INTERNAL_CLOCK_2MHZ); // enable internal 2MHz clock - uint8_t freq = (1 & 0x07) << 4; // freq should only be 3 bits from 6:4 - tempByte |= freq; + // uint8_t freq = (1 & 0x07) << 4; // freq should only be 3 bits from 6:4 + // tempByte |= freq; } + + freq = (freq & 0x7) << 4; // mask only 3 bits and shift to bit position 6:4 + tempByte |= freq; + writeByte(REG_MISC, tempByte); // Enable LED driver operation (REG_LED_DRIVER_ENABLE) From 759c0b6a1b44f3b669d216829b2317efc3b24455 Mon Sep 17 00:00:00 2001 From: beammeup0x <98652152+beammeup0x@users.noreply.github.com> Date: Sat, 29 Jan 2022 16:13:22 +0100 Subject: [PATCH 2/2] fixed issue in setting LED driver frequency in function ledDriverInit() --- src/SparkFunSX1509.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SparkFunSX1509.cpp b/src/SparkFunSX1509.cpp index 0d103d9..201779b 100644 --- a/src/SparkFunSX1509.cpp +++ b/src/SparkFunSX1509.cpp @@ -286,7 +286,6 @@ void SX1509::ledDriverInit(uint8_t pin, uint8_t freq /*= 1*/, bool log /*= false { // _clkX = 2000000.0 / (1 << (1 - 1)); // Update private clock variable _clkX = 2000000.0; - clock(INTERNAL_CLOCK_2MHZ); // enable internal 2MHz clock // uint8_t freq = (1 & 0x07) << 4; // freq should only be 3 bits from 6:4 // tempByte |= freq;