Reduce i2c timeouts for rgb led supported hardware (#360)

* Reduce i2c timeouts for rgb led supported hardware

* update

* make defines more consistent
This commit is contained in:
Drashna Jaelre
2022-10-27 22:43:40 -07:00
committed by GitHub
parent 89e3c4c0da
commit d9f575fa86
5 changed files with 31 additions and 16 deletions

View File

@@ -45,7 +45,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define OLATB 0x15 #define OLATB 0x15
extern i2c_status_t mcp23018_status; extern i2c_status_t mcp23018_status;
#define ERGODOX_EZ_I2C_TIMEOUT 100 #ifndef ERGODOX_EZ_I2C_TIMEOUT
# define ERGODOX_EZ_I2C_TIMEOUT 80
#endif
void init_ergodox(void); void init_ergodox(void);
void ergodox_blink_all_leds(void); void ergodox_blink_all_leds(void);

View File

@@ -23,10 +23,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "ergodox_ez.h" # include "ergodox_ez.h"
bool i2c_rgblight = true; bool i2c_rgblight = true;
extern bool i2c_initialized; extern bool i2c_initialized;
# ifndef ERGODOX_RGBLIGHT_TIMEOUT
# define ERGODOX_RGBLIGHT_TIMEOUT 5
# endif
void rgblight_call_driver(LED_TYPE *led, uint8_t led_num) { void rgblight_call_driver(LED_TYPE *led, uint8_t led_num) {
if (i2c_initialized && !mcp23018_status && i2c_rgblight) { if (i2c_initialized && !mcp23018_status && i2c_rgblight) {
if (i2c_start(0x84, ERGODOX_EZ_I2C_TIMEOUT)) { if (i2c_start(0x84, ERGODOX_RGBLIGHT_TIMEOUT)) {
i2c_rgblight = false; i2c_rgblight = false;
i2c_stop(); i2c_stop();
} else { } else {
@@ -44,11 +47,11 @@ void rgblight_call_driver(LED_TYPE *led, uint8_t led_num) {
# endif # endif
{ {
uint8_t *data = (uint8_t *)(led + i); uint8_t *data = (uint8_t *)(led + i);
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT); i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT); i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT); i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
# ifdef RGBW # ifdef RGBW
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT); i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
# endif # endif
} }
i2c_stop(); i2c_stop();

View File

@@ -102,7 +102,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
#endif #endif
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
i2c_rgblight = true; // re-enable rgb light i2c_rgblight = true; // re-enable rgb light
rgblight_init(); rgblight_set();
#endif #endif
} }
} }

View File

@@ -38,3 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// If not, then only define 15 // If not, then only define 15
# define RGBLED_NUM 15 // Number of LEDs # define RGBLED_NUM 15 // Number of LEDs
#endif #endif
#ifndef ISSI_TIMEOUT
# define ISSI_TIMEOUT 3
#endif

View File

@@ -1,9 +1,15 @@
#pragma once
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
#ifndef STARTUP_SONG # ifndef STARTUP_SONG
# define STARTUP_SONG SONG(E__NOTE(_DS5), E__NOTE(_D5), E__NOTE(_AS4), Q__NOTE(_F5)) # define STARTUP_SONG SONG(E__NOTE(_DS5), E__NOTE(_D5), E__NOTE(_AS4), Q__NOTE(_F5))
# endif
# ifndef GOODBYE_SONG
# define GOODBYE_SONG SONG(E__NOTE(_D5), E__NOTE(_F5), E__NOTE(_C5), Q__NOTE(_AS4))
# endif
#endif #endif
#ifndef GOODBYE_SONG #ifndef ISSI_TIMEOUT
# define GOODBYE_SONG SONG(E__NOTE(_D5), E__NOTE(_F5), E__NOTE(_C5), Q__NOTE(_AS4)) # define ISSI_TIMEOUT 5
#endif
#endif #endif