|
|
@@ -1,3 +1,23 @@
|
|
|
+/* Copyright 2017 Jason Williams
|
|
|
+ * Copyright 2018 Jack Humbert
|
|
|
+ * Copyright 2018 Yiancar
|
|
|
+ * Copyright 2020 MelGeek
|
|
|
+ * Copyright 2021 MasterSpoon
|
|
|
+ *
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
+ * the Free Software Foundation, either version 2 of the License, or
|
|
|
+ * (at your option) any later version.
|
|
|
+ *
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
+ */
|
|
|
+
|
|
|
#include "is31fl3743a.h"
|
|
|
#include <string.h>
|
|
|
#include "i2c_master.h"
|
|
|
@@ -155,12 +175,14 @@ void is31fl3743a_init(uint8_t addr, uint8_t sync) {
|
|
|
|
|
|
void is31fl3743a_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|
|
is31fl3743a_led_t led;
|
|
|
+
|
|
|
if (index >= 0 && index < IS31FL3743A_LED_COUNT) {
|
|
|
memcpy_P(&led, (&g_is31fl3743a_leds[index]), sizeof(led));
|
|
|
|
|
|
if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
g_pwm_buffer_update_required[led.driver] = true;
|
|
|
g_pwm_buffer[led.driver][led.r] = red;
|
|
|
g_pwm_buffer[led.driver][led.g] = green;
|
|
|
@@ -178,10 +200,9 @@ void is31fl3743a_set_scaling_register(uint8_t index, uint8_t red, uint8_t green,
|
|
|
is31fl3743a_led_t led;
|
|
|
memcpy_P(&led, (&g_is31fl3743a_leds[index]), sizeof(led));
|
|
|
|
|
|
- g_scaling_registers[led.driver][led.r] = red;
|
|
|
- g_scaling_registers[led.driver][led.g] = green;
|
|
|
- g_scaling_registers[led.driver][led.b] = blue;
|
|
|
-
|
|
|
+ g_scaling_registers[led.driver][led.r] = red;
|
|
|
+ g_scaling_registers[led.driver][led.g] = green;
|
|
|
+ g_scaling_registers[led.driver][led.b] = blue;
|
|
|
g_scaling_registers_update_required[led.driver] = true;
|
|
|
}
|
|
|
|
|
|
@@ -190,9 +211,9 @@ void is31fl3743a_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
|
|
is31fl3743a_select_page(addr, IS31FL3743A_COMMAND_PWM);
|
|
|
|
|
|
is31fl3743a_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
|
|
- }
|
|
|
|
|
|
- g_pwm_buffer_update_required[index] = false;
|
|
|
+ g_pwm_buffer_update_required[index] = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void is31fl3743a_update_scaling_registers(uint8_t addr, uint8_t index) {
|
|
|
@@ -202,6 +223,7 @@ void is31fl3743a_update_scaling_registers(uint8_t addr, uint8_t index) {
|
|
|
for (int i = 0; i < IS31FL3743A_SCALING_REGISTER_COUNT; i++) {
|
|
|
is31fl3743a_write_register(addr, i + 1, g_scaling_registers[index][i]);
|
|
|
}
|
|
|
+
|
|
|
g_scaling_registers_update_required[index] = false;
|
|
|
}
|
|
|
}
|