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
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 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"
bool i2c_rgblight = true;
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) {
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_stop();
} else {
@@ -44,11 +47,11 @@ void rgblight_call_driver(LED_TYPE *led, uint8_t led_num) {
# endif
{
uint8_t *data = (uint8_t *)(led + i);
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT);
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT);
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT);
i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
# ifdef RGBW
i2c_write(*data++, ERGODOX_EZ_I2C_TIMEOUT);
i2c_write(*data++, ERGODOX_RGBLIGHT_TIMEOUT);
# endif
}
i2c_stop();

View File

@@ -102,7 +102,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
#endif
#ifdef RGBLIGHT_ENABLE
i2c_rgblight = true; // re-enable rgb light
rgblight_init();
rgblight_set();
#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
# define RGBLED_NUM 15 // Number of LEDs
#endif
#ifndef ISSI_TIMEOUT
# define ISSI_TIMEOUT 3
#endif

View File

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