From e21641a6c1ddb0e71f7b9e01501fa739786c68b1 Mon Sep 17 00:00:00 2001 From: olikraus Date: Sat, 16 Dec 2017 11:57:35 +0100 Subject: [PATCH] 1.5.2 --- examples/Box3D/Box3D.ino | 1 + examples/HelloWorld/HelloWorld.ino | 1 + extras/ChangeLog | 3 ++ library.properties | 2 +- src/Ucglib.cpp | 61 ++++++++++++++++++++---------- src/clib/ucg.h | 4 +- 6 files changed, 50 insertions(+), 22 deletions(-) diff --git a/examples/Box3D/Box3D.ino b/examples/Box3D/Box3D.ino index 73194c8..1977186 100644 --- a/examples/Box3D/Box3D.ino +++ b/examples/Box3D/Box3D.ino @@ -75,6 +75,7 @@ //Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); //Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); //Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); +//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 17, /*cd=*/ 16, /*cs=*/ 0, /*reset=*/ 2); /* FT SSD1351 direct connect to ESP32 */ //Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */ //Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */ diff --git a/examples/HelloWorld/HelloWorld.ino b/examples/HelloWorld/HelloWorld.ino index 23ddf36..0937e40 100644 --- a/examples/HelloWorld/HelloWorld.ino +++ b/examples/HelloWorld/HelloWorld.ino @@ -84,6 +84,7 @@ //Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); //Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); //Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); +//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 17, /*cd=*/ 16, /*cs=*/ 0, /*reset=*/ 2); /* FT SSD1351 direct connect to ESP32 */ //Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */ //Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */ diff --git a/extras/ChangeLog b/extras/ChangeLog index 96a81aa..b28336d 100644 --- a/extras/ChangeLog +++ b/extras/ChangeLog @@ -39,6 +39,9 @@ Changelog Ucglib (http://code.google.com/p/ucglib/) * Support for SSD1331 OLEDs 2016-01-07 v1.4.0 Oliver Kraus * Support for ESP8266 (issue 61) +2017-12-16 v1.5.2 Oliver Kraus + * Integration of HX8352C and ILI9486 support + * Fix ESP32 errors diff --git a/library.properties b/library.properties index 23d0159..4758f3e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Ucglib -version=1.5.1 +version=1.5.2 author=oliver maintainer=oliver sentence=True color TFT and OLED library, Up to 18 Bit color depth. Supported display controller: ST7735, ILI9163, ILI9325, ILI9341, ILI9486,LD50T6160, PCF8833, SEPS225, SSD1331, SSD1351, HX8352C. diff --git a/src/Ucglib.cpp b/src/Ucglib.cpp index d7d531e..b43fb84 100644 --- a/src/Ucglib.cpp +++ b/src/Ucglib.cpp @@ -161,12 +161,13 @@ static void ucg_com_arduino_send_generic_SW_SPI(ucg_t *ucg, uint8_t data) digitalWrite(ucg->pin_list[UCG_PIN_SDA], 0 ); } // no delay required, also Arduino Due is slow enough - //delayMicroseconds(1); + // delay required for ESP32 + delayMicroseconds(1); digitalWrite(ucg->pin_list[UCG_PIN_SCL], 1 ); - //delayMicroseconds(1); + delayMicroseconds(1); i--; digitalWrite(ucg->pin_list[UCG_PIN_SCL], 0 ); - //delayMicroseconds(1); + delayMicroseconds(1); data <<= 1; } while( i > 0 ); @@ -664,21 +665,29 @@ static int16_t ucg_com_arduino_3wire_9bit_HW_SPI(ucg_t *ucg, int16_t msg, uint16 digitalWrite(ucg->pin_list[UCG_PIN_RST], 1); /* setup Arduino SPI */ +#if ARDUINO >= 10600 SPI.begin(); -#if defined(__AVR__) - SPI.setClockDivider( SPI_CLOCK_DIV2 ); - //SPI.setClockDivider( SPI_CLOCK_DIV64 ); - //SPI.setDataMode(SPI_MODE0); - -#endif -#if defined(__SAM3X8E__) - SPI.setClockDivider( (((ucg_com_info_t *)data)->serial_clk_speed * 84L + 999)/1000L ); -#endif + SPI.beginTransaction(SPISettings(1000000000UL/((ucg_com_info_t *)data)->serial_clk_speed, MSBFIRST, SPI_MODE0)); +#else + SPI.begin(); + + if ( ((ucg_com_info_t *)data)->serial_clk_speed/2 < 70 ) + SPI.setClockDivider( SPI_CLOCK_DIV2 ); + else if ( ((ucg_com_info_t *)data)->serial_clk_speed/2 < 140 ) + SPI.setClockDivider( SPI_CLOCK_DIV4 ); + else + SPI.setClockDivider( SPI_CLOCK_DIV8 ); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); +#endif break; case UCG_COM_MSG_POWER_DOWN: +#if ARDUINO >= 10600 + SPI.endTransaction(); + SPI.end(); +#else SPI.end(); +#endif break; case UCG_COM_MSG_DELAY: /* flush pending data first, then do the delay */ @@ -1189,18 +1198,32 @@ static int16_t ucg_com_arduino_4wire_HW_SPI(ucg_t *ucg, int16_t msg, uint16_t ar pinMode(ucg->pin_list[UCG_PIN_CS], OUTPUT); /* setup Arduino SPI */ + +#if ARDUINO >= 10600 SPI.begin(); -#if defined(__AVR__) - SPI.setClockDivider( SPI_CLOCK_DIV2 ); -#endif -#if defined(__SAM3X8E__) - SPI.setClockDivider( (((ucg_com_info_t *)data)->serial_clk_speed * 84L + 999)/1000L ); -#endif + SPI.beginTransaction(SPISettings(1000000000UL/((ucg_com_info_t *)data)->serial_clk_speed, MSBFIRST, SPI_MODE0)); +#else + SPI.begin(); + + if ( ((ucg_com_info_t *)data)->serial_clk_speed/2 < 70 ) + SPI.setClockDivider( SPI_CLOCK_DIV2 ); + else if ( ((ucg_com_info_t *)data)->serial_clk_speed/2 < 140 ) + SPI.setClockDivider( SPI_CLOCK_DIV4 ); + else + SPI.setClockDivider( SPI_CLOCK_DIV8 ); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); +#endif + + break; case UCG_COM_MSG_POWER_DOWN: - SPI.end(); +#if ARDUINO >= 10600 + SPI.endTransaction(); + SPI.end(); +#else + SPI.end(); +#endif break; case UCG_COM_MSG_DELAY: delayMicroseconds(arg); diff --git a/src/clib/ucg.h b/src/clib/ucg.h index 80b1e98..c070a77 100644 --- a/src/clib/ucg.h +++ b/src/clib/ucg.h @@ -279,8 +279,8 @@ struct _ucg_arg_t struct _ucg_com_info_t { - uint16_t serial_clk_speed; - uint16_t parallel_clk_speed; + uint16_t serial_clk_speed; /* nano seconds cycle time */ + uint16_t parallel_clk_speed; /* nano seconds cycle time */ };