summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-01-26 23:33:55 +0100
committerskullydazed <skullydazed@users.noreply.github.com>2019-02-11 00:37:12 +0100
commitbf2670601d29551896bab6811b9bb64de2d0ee0e (patch)
tree459467a986f6ce0fa3ef2accbfd0d43a3afffad8
parent159191a8747891920aea7de2324507daa8a661fb (diff)
downloadqmk_firmware-bf2670601d29551896bab6811b9bb64de2d0ee0e.tar.gz
qmk_firmware-bf2670601d29551896bab6811b9bb64de2d0ee0e.tar.xz
compiles, but long delay on startup and problems
-rw-r--r--drivers/issi/is31fl3731-simple.c18
-rw-r--r--drivers/issi/is31fl3731-simple.h2
-rw-r--r--quantum/led_matrix.c20
-rw-r--r--quantum/led_matrix.h30
-rw-r--r--quantum/led_matrix_drivers.c50
-rw-r--r--quantum/quantum.c16
-rw-r--r--quantum/quantum.h6
-rw-r--r--tmk_core/common/action.c2
8 files changed, 79 insertions, 65 deletions
diff --git a/drivers/issi/is31fl3731-simple.c b/drivers/issi/is31fl3731-simple.c
index 46d51dac7..9c31df209 100644
--- a/drivers/issi/is31fl3731-simple.c
+++ b/drivers/issi/is31fl3731-simple.c
@@ -29,6 +29,7 @@
#include "is31fl3731-simple.h"
#include "i2c_master.h"
#include "progmem.h"
+#include "print.h"
// This is a 7-bit address, that gets left-shifted and bit 0
// set to 0 for write, 1 for read (as per I2C protocol)
@@ -72,10 +73,19 @@ uint8_t g_twi_transfer_buffer[20];
// We could optimize this and take out the unused registers from these
// buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's
// probably not worth the extra complexity.
-uint8_t g_pwm_buffer[DRIVER_COUNT][144];
+uint8_t g_pwm_buffer[LED_DRIVER_COUNT][144];
bool g_pwm_buffer_update_required = false;
-uint8_t g_led_control_registers[DRIVER_COUNT][18] = { { 0 }, { 0 } };
+/* There's probably a better way to init this... */
+#if LED_DRIVER_COUNT == 1
+ uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}};
+#elif LED_DRIVER_COUNT == 2
+ uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}};
+#elif LED_DRIVER_COUNT == 3
+ uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}};
+#elif LED_DRIVER_COUNT == 4
+ uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}};
+#endif
bool g_led_control_registers_update_required = false;
// This is the bit pattern in the LED control registers
@@ -194,7 +204,7 @@ void IS31FL3731_init(uint8_t addr) {
}
void IS31FL3731_set_value(int index, uint8_t value) {
- if (index >= 0 && index < DRIVER_LED_TOTAL) {
+ if (index >= 0 && index < LED_DRIVER_LED_COUNT) {
is31_led led = g_is31_leds[index];
// Subtract 0x24 to get the second index of g_pwm_buffer
@@ -204,7 +214,7 @@ void IS31FL3731_set_value(int index, uint8_t value) {
}
void IS31FL3731_set_value_all(uint8_t value) {
- for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ for (int i = 0; i < LED_DRIVER_LED_COUNT; i++) {
IS31FL3731_set_value(i, value);
}
}
diff --git a/drivers/issi/is31fl3731-simple.h b/drivers/issi/is31fl3731-simple.h
index c102837a3..3b107d48f 100644
--- a/drivers/issi/is31fl3731-simple.h
+++ b/drivers/issi/is31fl3731-simple.h
@@ -25,7 +25,7 @@ typedef struct is31_led {
uint8_t v;
} __attribute__((packed)) is31_led;
-extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
+extern const is31_led g_is31_leds[LED_DRIVER_LED_COUNT];
void IS31FL3731_init(uint8_t addr);
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index 9a0aa6acd..3b284990d 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -59,7 +59,7 @@ bool g_suspend_state = false;
uint32_t g_tick = 0;
// Ticks since this key was last hit.
-uint8_t g_key_hit[DRIVER_LED_TOTAL];
+uint8_t g_key_hit[LED_DRIVER_LED_COUNT];
// Ticks since any key was last hit.
uint32_t g_any_key_hit = 0;
@@ -95,7 +95,7 @@ void map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i, uint8_t
led_matrix led;
*led_count = 0;
- for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
+ for (uint8_t i = 0; i < LED_DRIVER_LED_COUNT; i++) {
// map_index_to_led(i, &led);
led = g_leds[i];
if (row == led.matrix_co.row && column == led.matrix_co.col) {
@@ -187,7 +187,7 @@ void led_matrix_task(void) {
g_any_key_hit++;
}
- for (int led = 0; led < DRIVER_LED_TOTAL; led++) {
+ for (int led = 0; led < LED_DRIVER_LED_COUNT; led++) {
if (g_key_hit[led] < 255) {
if (g_key_hit[led] == 254)
g_last_led_count = MAX(g_last_led_count - 1, 0);
@@ -271,7 +271,7 @@ void led_matrix_init(void) {
// TODO: put the 1 second startup delay here?
// clear the key hits
- for (int led=0; led<DRIVER_LED_TOTAL; led++) {
+ for (int led=0; led<LED_DRIVER_LED_COUNT; led++) {
g_key_hit[led] = 255;
}
@@ -317,7 +317,7 @@ static uint8_t decrement(uint8_t value, uint8_t step, uint8_t min, uint8_t max)
// uint8_t led[8], led_count;
// map_row_column_to_led(row,column,led,&led_count);
// for(uint8_t i = 0; i < led_count; i++) {
-// if (led[i] < DRIVER_LED_TOTAL) {
+// if (led[i] < LED_DRIVER_LED_COUNT) {
// void *address = backlight_get_custom_key_value_eeprom_address(led[i]);
// eeprom_update_byte(address, value);
// }
@@ -396,9 +396,11 @@ uint8_t led_matrix_get_mode(void) {
return led_matrix_config.mode;
}
-void led_matrix_set_value(uint8_t val, bool eeprom_write) {
+void led_matrix_set_value_noeeprom(uint8_t val) {
led_matrix_config.val = val;
- if (eeprom_write) {
- eeconfig_update_led_matrix(led_matrix_config.raw);
- }
+}
+
+void led_matrix_set_value(uint8_t val) {
+ led_matrix_set_value_noeeprom(val);
+ eeconfig_update_led_matrix(led_matrix_config.raw);
}
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h
index 20f2e73c6..6db162963 100644
--- a/quantum/led_matrix.h
+++ b/quantum/led_matrix.h
@@ -21,6 +21,11 @@
#define LED_MATRIX_H
+#ifndef BACKLIGHT_ENABLE
+ #error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE
+#endif
+
+
typedef struct Point {
uint8_t x;
uint8_t y;
@@ -38,7 +43,7 @@ typedef struct led_matrix {
uint8_t modifier:1;
} __attribute__((packed)) led_matrix;
-extern const led_matrix g_leds[DRIVER_LED_TOTAL];
+extern const led_matrix g_leds[LED_DRIVER_LED_COUNT];
typedef struct {
uint8_t index;
@@ -104,26 +109,11 @@ void led_matrix_decrease_speed(void);
void led_matrix_mode(uint8_t mode, bool eeprom_write);
void led_matrix_mode_noeeprom(uint8_t mode);
uint8_t led_matrix_get_mode(void);
-void led_matrix_set_value(uint8_t mode, bool eeprom_write);
+void led_matrix_set_value(uint8_t mode);
+void led_matrix_set_value_noeeprom(uint8_t mode);
-#ifndef BACKLIGHT_ENABLE
-#define backlight_toggle() backlight_matrix_toggle()
-#define backlight_enable() backlight_matrix_enable()
-#define backlight_enable_noeeprom() backlight_matrix_enable_noeeprom()
-#define backlight_disable() backlight_matrix_disable()
-#define backlight_disable_noeeprom() backlight_matrix_disable_noeeprom()
-#define backlight_step() backlight_matrix_step()
-#define backlight_set_value(val) backlight_matrix_set_value(val)
-#define backlight_set_value_noeeprom(val) backlight_matrix_set_value_noeeprom(val)
-#define backlight_step_reverse() backlight_matrix_step_reverse()
-#define backlight_increase_val() backlight_matrix_increase_val()
-#define backlight_decrease_val() backlight_matrix_decrease_val()
-#define backlight_increase_speed() backlight_matrix_increase_speed()
-#define backlight_decrease_speed() backlight_matrix_decrease_speed()
-#define backlight_mode(mode) backlight_matrix_mode(mode)
-#define backlight_mode_noeeprom(mode) backlight_matrix_mode_noeeprom(mode)
-#define backlight_get_mode() backlight_matrix_get_mode()
-#endif
+// Hook into the existing backlight API
+#define backlight_set(val) led_matrix_set_value(val)
typedef struct {
/* Perform any initialisation required for the other driver functions to work. */
diff --git a/quantum/led_matrix_drivers.c b/quantum/led_matrix_drivers.c
index f00f4f366..e0f8b2094 100644
--- a/quantum/led_matrix_drivers.c
+++ b/quantum/led_matrix_drivers.c
@@ -39,32 +39,32 @@ static void init(void) {
i2c_init();
#ifdef IS31FL3731
#ifdef LED_DRIVER_ADDR_1
- IS31FL3731_init(DRIVER_ADDR_1);
+ IS31FL3731_init(LED_DRIVER_ADDR_1);
#endif
#ifdef LED_DRIVER_ADDR_2
- IS31FL3731_init(DRIVER_ADDR_2);
+ IS31FL3731_init(LED_DRIVER_ADDR_2);
#endif
#ifdef LED_DRIVER_ADDR_3
- IS31FL3731_init(DRIVER_ADDR_3);
+ IS31FL3731_init(LED_DRIVER_ADDR_3);
#endif
#ifdef LED_DRIVER_ADDR_4
- IS31FL3731_init(DRIVER_ADDR_4);
+ IS31FL3731_init(LED_DRIVER_ADDR_4);
#endif
#else
#ifdef LED_DRIVER_ADDR_1
- IS31FL3733_init(DRIVER_ADDR_1);
+ IS31FL3733_init(LED_DRIVER_ADDR_1);
#endif
#ifdef LED_DRIVER_ADDR_2
- IS31FL3733_init(DRIVER_ADDR_2);
+ IS31FL3733_init(LED_DRIVER_ADDR_2);
#endif
#ifdef LED_DRIVER_ADDR_3
- IS31FL3733_init(DRIVER_ADDR_3);
+ IS31FL3733_init(LED_DRIVER_ADDR_3);
#endif
#ifdef LED_DRIVER_ADDR_4
- IS31FL3733_init(DRIVER_ADDR_4);
+ IS31FL3733_init(LED_DRIVER_ADDR_4);
#endif
#endif
- for (int index = 0; index < DRIVER_LED_TOTAL; index++) {
+ for (int index = 0; index < LED_DRIVER_COUNT; index++) {
#ifdef IS31FL3731
IS31FL3731_set_led_control_register(index, true);
#else
@@ -74,29 +74,29 @@ static void init(void) {
// This actually updates the LED drivers
#ifdef IS31FL3731
#ifdef LED_DRIVER_ADDR_1
- IS31FL3731_update_led_control_registers(DRIVER_ADDR_1);
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
#endif
#ifdef LED_DRIVER_ADDR_2
- IS31FL3731_update_led_control_registers(DRIVER_ADDR_2);
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
#endif
#ifdef LED_DRIVER_ADDR_3
- IS31FL3731_update_led_control_registers(DRIVER_ADDR_3);
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
#endif
#ifdef LED_DRIVER_ADDR_4
- IS31FL3731_update_led_control_registers(DRIVER_ADDR_4);
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
#endif
#else
#ifdef LED_DRIVER_ADDR_1
- IS31FL3733_update_led_control_registers(DRIVER_ADDR_1);
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
#endif
#ifdef LED_DRIVER_ADDR_2
- IS31FL3733_update_led_control_registers(DRIVER_ADDR_2);
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
#endif
#ifdef LED_DRIVER_ADDR_3
- IS31FL3733_update_led_control_registers(DRIVER_ADDR_3);
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
#endif
#ifdef LED_DRIVER_ADDR_4
- IS31FL3733_update_led_control_registers(DRIVER_ADDR_4);
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
#endif
#endif
}
@@ -104,29 +104,29 @@ static void init(void) {
static void flush(void) {
#ifdef IS31FL3731
#ifdef LED_DRIVER_ADDR_1
- IS31FL3731_update_pwm_buffers(DRIVER_ADDR_1);
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
#endif
#ifdef LED_DRIVER_ADDR_2
- IS31FL3731_update_pwm_buffers(DRIVER_ADDR_2);
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
#endif
#ifdef LED_DRIVER_ADDR_3
- IS31FL3731_update_pwm_buffers(DRIVER_ADDR_3);
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
#endif
#ifdef LED_DRIVER_ADDR_4
- IS31FL3731_update_pwm_buffers(DRIVER_ADDR_4);
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
#endif
#else
#ifdef LED_DRIVER_ADDR_1
- IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1);
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
#endif
#ifdef LED_DRIVER_ADDR_2
- IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2);
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
#endif
#ifdef LED_DRIVER_ADDR_3
- IS31FL3733_update_pwm_buffers(DRIVER_ADDR_3);
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
#endif
#ifdef LED_DRIVER_ADDR_4
- IS31FL3733_update_pwm_buffers(DRIVER_ADDR_4);
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
#endif
#endif
}
diff --git a/quantum/quantum.c b/quantum/quantum.c
index bd3715c80..0e605d4cb 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -1031,7 +1031,11 @@ void matrix_init_quantum() {
eeconfig_init();
}
#ifdef BACKLIGHT_ENABLE
- backlight_init_ports();
+ #ifdef LED_MATRIX_ENABLE
+ led_matrix_init();
+ #else
+ backlight_init_ports();
+ #endif
#endif
#ifdef AUDIO_ENABLE
audio_init();
@@ -1067,8 +1071,12 @@ void matrix_scan_quantum() {
matrix_scan_combo();
#endif
- #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN)
- backlight_task();
+ #if defined(BACKLIGHT_ENABLE)
+ #if defined(LED_MATRIX_ENABLE)
+ led_matrix_task();
+ #elif defined(BACKLIGHT_PIN)
+ backlight_task();
+ #endif
#endif
#ifdef RGB_MATRIX_ENABLE
@@ -1198,7 +1206,7 @@ static inline void set_pwm(uint16_t val) {
OCRxx = val;
}
-#ifndef BACKLIGHT_CUSTOM_DRIVER
+#ifndef BACKLIGHT_CUSTOM_DRIVER || LED_MATRIX_ENABLE
__attribute__ ((weak))
void backlight_set(uint8_t level) {
if (level > BACKLIGHT_LEVELS)
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 56a6a1a99..169883609 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -28,7 +28,11 @@
#include "matrix.h"
#include "keymap.h"
#ifdef BACKLIGHT_ENABLE
- #include "backlight.h"
+ #ifdef LED_MATRIX_ENABLE
+ #include "led_matrix.h"
+ #else
+ #include "backlight.h"
+ #endif
#endif
#ifdef RGBLIGHT_ENABLE
#include "rgblight.h"
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index ec8d6ed7b..d4d4ac28d 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -537,7 +537,7 @@ void process_action(keyrecord_t *record, action_t action)
action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
break;
#endif
-#ifdef BACKLIGHT_ENABLE
+#if defined(BACKLIGHT_ENABLE) | defined(LED_MATRIX_ENABLE)
case ACT_BACKLIGHT:
if (!event.pressed) {
switch (action.backlight.opt) {