From 0bdcb815263966d50639f59e4525ff99ae4a49aa Mon Sep 17 00:00:00 2001 From: Natalia Date: Sat, 20 Oct 2018 11:29:29 +0300 Subject: [PATCH] u8g2 i2c multibus support (#2526) * u8g2 support for more than only one i2c bus * Removed unnecessary #include --- app/platform/u8x8_nodemcu_hal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/platform/u8x8_nodemcu_hal.c b/app/platform/u8x8_nodemcu_hal.c index 475da763..8b73f4cb 100644 --- a/app/platform/u8x8_nodemcu_hal.c +++ b/app/platform/u8x8_nodemcu_hal.c @@ -133,11 +133,11 @@ uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void * switch(msg) { case U8X8_MSG_BYTE_SEND: - if (hal->id == 0) { + if (hal->id < NUM_I2C) { data = (uint8_t *)arg_ptr; while( arg_int > 0 ) { - platform_i2c_send_byte( 0, *data ); + platform_i2c_send_byte( hal->id, *data ); data++; arg_int--; } @@ -164,9 +164,9 @@ uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void * break; case U8X8_MSG_BYTE_START_TRANSFER: - if (hal->id == 0) { - platform_i2c_send_start( 0 ); - platform_i2c_send_address( 0, u8x8_GetI2CAddress(u8x8), PLATFORM_I2C_DIRECTION_TRANSMITTER ); + if (hal->id < NUM_I2C) { + platform_i2c_send_start( hal->id ); + platform_i2c_send_address( hal->id, u8x8_GetI2CAddress(u8x8), PLATFORM_I2C_DIRECTION_TRANSMITTER ); } else { // invalid id @@ -175,8 +175,8 @@ uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void * break; case U8X8_MSG_BYTE_END_TRANSFER: - if (hal->id == 0) { - platform_i2c_send_stop( 0 ); + if (hal->id < NUM_I2C) { + platform_i2c_send_stop( hal->id ); } else { // invalid id