diff --git a/cppsrc/U8x8lib.cpp b/cppsrc/U8x8lib.cpp index ab1c81ca..e87abd93 100644 --- a/cppsrc/U8x8lib.cpp +++ b/cppsrc/U8x8lib.cpp @@ -713,7 +713,8 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a break; case U8X8_MSG_BYTE_INIT: - u8x8->bus_clock = u8x8->display_info->sck_clock_hz; + if ( u8x8->bus_clock == 0 ) /* issue 769 */ + u8x8->bus_clock = u8x8->display_info->sck_clock_hz; /* disable chipselect */ u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level); @@ -832,7 +833,8 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_spi(U8X8_UNUSED u8x8_t *u8x8, U8X8_U break; case U8X8_MSG_BYTE_INIT: - u8x8->bus_clock = u8x8->display_info->sck_clock_hz; + if ( u8x8->bus_clock == 0 ) /* issue 769 */ + u8x8->bus_clock = u8x8->display_info->sck_clock_hz; /* disable chipselect */ u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level); /* no wait required here */ @@ -1135,7 +1137,8 @@ extern "C" uint8_t u8x8_byte_arduino_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSE Wire.write((uint8_t *)arg_ptr, (int)arg_int); break; case U8X8_MSG_BYTE_INIT: - u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL; + if ( u8x8->bus_clock == 0 ) /* issue 769 */ + u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL; #if defined(ESP8266) || defined(ARDUINO_ARCH_ESP8266) || defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_ESP32) /* for ESP8266/ESP32, Wire.begin has two more arguments: clock and data */ if ( u8x8->pins[U8X8_PIN_I2C_CLOCK] != U8X8_PIN_NONE && u8x8->pins[U8X8_PIN_I2C_DATA] != U8X8_PIN_NONE ) @@ -1180,7 +1183,8 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_U Wire1.write((uint8_t *)arg_ptr, (int)arg_int); break; case U8X8_MSG_BYTE_INIT: - u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL; + if ( u8x8->bus_clock == 0 ) /* issue 769 */ + u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL; Wire1.begin(); break; case U8X8_MSG_BYTE_SET_DC: diff --git a/cppsrc/U8x8lib.h b/cppsrc/U8x8lib.h index 2f48a978..e56b0d4f 100644 --- a/cppsrc/U8x8lib.h +++ b/cppsrc/U8x8lib.h @@ -111,6 +111,9 @@ /* As of writing this, I did not found any official board which supports this */ /* so this is not tested (May 2017), issue #224 */ /* fixed ifdef, #410, #377 */ +/* meanwhile it is defined e.g. here: https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrzero/variant.h#L91 */ +/* so it should be available for mkrzero */ + #ifdef SPI_INTERFACES_COUNT #if SPI_INTERFACES_COUNT > 1 #define U8X8_HAVE_2ND_HW_SPI diff --git a/csrc/u8x8_setup.c b/csrc/u8x8_setup.c index f5b0d1b5..d931f119 100644 --- a/csrc/u8x8_setup.c +++ b/csrc/u8x8_setup.c @@ -102,6 +102,7 @@ void u8x8_SetupDefaults(u8x8_t *u8x8) u8x8->is_font_inverse_mode = 0; u8x8->device_address = 0; u8x8->utf8_state = 0; /* also reset by u8x8_utf8_init */ + u8x8->bus_clock = 0; /* issue 769 */ u8x8->i2c_address = 255; u8x8->debounce_default_pin_state = 255; /* assume all low active buttons */