lexus2k / ssd1306

Driver for SSD1306, SSD1331, SSD1351, IL9163, ILI9341, ST7735, PCD8544, Nokia 5110 displays running on Arduino/ESP32/Linux (Rasperry) platforms
MIT License
662 stars 127 forks source link

SSD1306 Examples fail to compile under esp32 2.0.0 Board #132

Closed ericd1949 closed 2 years ago

ericd1949 commented 2 years ago

I found this when compiling one of my sketches on a Mac with Arduino 1.8.13, not the latest I know. But the code, as described in the error is still there, If I'm wrong - heartfelt apologies. This did not occur when I downgraded the ESP32 boards to 1.0.6

The ssd1306_demo example sketch also, error given: /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:186:9: error: 'i2s_write_bytes' was not declared in this scope i2s_write_bytes(I2S_PORT, (char)line, (m_ptr - line) sizeof(uint16_t), portMAX_DELAY); ^~~~~~~

Also, maybe relevant an earlier error said: /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:119:32: warning: 'I2S_COMM_FORMAT_I2S_MSB' is deprecated [-Wdeprecated-declarations] .communication_format = I2S_COMM_FORMAT_I2S_MSB, ^~~~~~~

***** Full Error log ** warning: 'I2S_COMM_FORMAT_I2S_MSB' is deprecated [-Wdeprecated-declarations] .communication_format = I2S_COMM_FORMAT_I2S_MSB, ^~~~~~~ In file included from /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h:30, from /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/hal/include/hal/i2s_hal.h:28, from /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/driver/include/driver/i2s.h:16, from /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.h:12, from /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:5: /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/hal/include/hal/i2s_types.h:71:5: note: declared here I2S_COMM_FORMAT_I2S_MSB attribute((deprecated)) = 0x01, /!< I2S format MSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_MSB) correspond to I2S_COMM_FORMAT_STAND_I2S/ ^~~~~~~ /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp: In member function 'void CompositeOutput::sendFrameHalfResolution(const uint8_t)': /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:186:9: error: 'i2s_write_bytes' was not declared in this scope i2s_write_bytes(I2S_PORT, (char)line, (m_ptr - line) sizeof(uint16_t), portMAX_DELAY); ^~~~~~~ /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:186:9: note: suggested alternative: 'i2s_write_expand' i2s_write_bytes(I2S_PORT, (char)line, (m_ptr - line) sizeof(uint16_t), portMAX_DELAY); ^~~~~~~ i2s_write_expand /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp: In member function 'void CompositeOutput::check_buffer()': /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:278:9: error: 'i2s_write_bytes' was not declared in this scope i2s_write_bytes(I2S_PORT, (char)line, sizeof(uint16_t) (m_end - line), portMAX_DELAY); ^~~~~~~ /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:278:9: note: suggested alternative: 'i2s_write_expand' i2s_write_bytes(I2S_PORT, (char)line, sizeof(uint16_t) * (m_end - line), portMAX_DELAY); ^~~~~~~ i2s_write_expand Using library ssd1306 at version 1.8.2 in folder: /Users/ericd/Documents/Arduino/libraries/ssd1306 Using library Wire at version 2.0.0 in folder: /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/libraries/Wire Using library SPI at version 2.0.0 in folder: /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/libraries/SPI exit status 1 Error compiling for board ESP32 Dev Module.

lexus2k commented 2 years ago

Hi,

It looks like they changed API again in new version of ESP32 IDF SDK. It should be easy to check compilation after replacing i2s_write_bytes with i2s_write_expand. However, many people still use older version of ESP32 SDK, and replacing the function in ssd1306 library will break compilation for them. I need to find the way to get know, what version of ESP32 SDK the ssd1306 library is being compiled for.

lexus2k commented 2 years ago

Hi, can you check the library from the master branch? It would be nice to know if the latest commit fixes the issue for you

ericd1949 commented 2 years ago

Thanks for your quick response - I changed to your SSD1306 library version 1.8.3, initially worked fine with ESP board 1.0.6. Then upgraded to ESP boards 2.0, and it found some more stuff it didn't like (first error log below) downgraded to ESP32 boards 1.06 and got the second set of errors. Then put back ssd1306 library version 1.8.2 and all was fine again.

I didn't understand that, seemed unlikely, but it did happen, I quit and restarted Arduino app between each change. Anyway, I did it all again from scratch and the second error log occurred with 1.8.3 and boards 1.0.6. Maybe I'd left the old ssd1306 1.8.2 library in the library directory, and Arduino had used that old version, which worked. So accidentally, in my clumsy process, I got an error log for 1.8.3 and boards 2.0.

Oh boy, interesting, but not what I'd call a good laugh :-) Cheers, Eric

Error Log for boards 2.0 and library 1.8.3 ############################################### /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp: In member function 'void CompositeOutput::init_hardware()': /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:119:32: warning: 'I2S_COMM_FORMAT_I2S_MSB' is deprecated [-Wdeprecated-declarations] .communication_format = I2S_COMM_FORMAT_I2S_MSB, ^~~~~~~ In file included from /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h:30, from /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/hal/include/hal/i2s_hal.h:28, from /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/driver/include/driver/i2s.h:16, from /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.h:12, from /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:5: /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/2.0.0/tools/sdk/esp32/include/hal/include/hal/i2s_types.h:71:5: note: declared here I2S_COMM_FORMAT_I2S_MSB attribute((deprecated)) = 0x01, /!< I2S format MSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_MSB) correspond to I2S_COMM_FORMAT_STAND_I2S/ ^~~~~~~ /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp: In member function 'void CompositeOutput::check_buffer()': /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:280:9: error: 'i2s_write_bytes' was not declared in this scope i2s_write_bytes(I2S_PORT, (char)line, sizeof(uint16_t) (m_end - line), &bytes_written, portMAX_DELAY); ^~~~~~~ /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:280:9: note: suggested alternative: 'i2s_write_expand' i2s_write_bytes(I2S_PORT, (char)line, sizeof(uint16_t) (m_end - line), &bytes_written, portMAX_DELAY); ^~~~~~~ i2s_write_expand exit status 1 Error compiling for board WEMOS D1 MINI ESP32.

Error Log for boards 1.06 and library 1.8.3 ############################################### /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp: In member function 'void CompositeOutput::check_buffer()': /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:280:112: error: invalid conversion from 'size_t {aka unsigned int}' to 'TickType_t {aka unsigned int}' [-fpermissive] i2s_write_bytes(I2S_PORT, (char)line, sizeof(uint16_t) (m_end - line), &bytes_written, portMAX_DELAY); ^ /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:280:112: error: too many arguments to function 'int i2s_write_bytes(i2s_port_t, const void, size_t, TickType_t)' In file included from /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.h:12:0, from /Users/ericd/Documents/Arduino/libraries/ssd1306/src/intf/vga/esp32/CompositeOutput.cpp:5: /Users/ericd/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/tools/sdk/include/driver/driver/i2s.h:301:5: note: declared here int i2s_write_bytes(i2s_port_t i2s_num, const void src, size_t size, TickType_t ticks_to_wait) attribute ((deprecated)); ^ exit status 1 Error compiling for board WEMOS D1 MINI ESP32.

lexus2k commented 2 years ago

Please, check latest commit. 1.8.3 version is re-published.

ericd1949 commented 2 years ago

This may not be the same problem, but I still see compilation failures with the re-published 1.8.3 and ESP32 boards v2.0.0

That demo_example sketch does now compile with 1.8.3 and ESP32 boards 2.0.0

But, my sketch will not compile successfully . It compiles fine with 1.8.3 and ESP32 boards 1.0.6, but with ESP32 2.0.0 boards I get these errors. I'm on Arduino 1.8.13 on a Mac Mini Big Sur (the line 151 in my sketch is the #include "ssd1306.h" line

############### Error log ################

In file included from /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/ssd1306.h:31, from /Users/ericd/Documents/Arduino/Spod/Spod32_v1_5/Spod32_v1_5.ino:151: /Users/ericd/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r1/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.h: In member function 'int std::cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const std::cxx11::basic_string<_CharT, _Traits, _Alloc>&) const': /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/nano_gfx_types.h:35:18: error: expected unqualified-id before '(' token

define min(a,b) ((a)<(b)?(a):(b))

              ^

/Users/ericd/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r1/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.tcc: In member function 'std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::rfind(const _CharT*, std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) const': /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/nano_gfx_types.h:35:18: error: expected unqualified-id before '(' token

define min(a,b) ((a)<(b)?(a):(b))

              ^

/Users/ericd/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r1/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.tcc: In member function 'int std::cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) const': /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/nano_gfx_types.h:35:18: error: expected unqualified-id before '(' token

define min(a,b) ((a)<(b)?(a):(b))

              ^

/Users/ericd/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r1/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.tcc: In member function 'int std::cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) const': /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/nano_gfx_types.h:35:18: error: expected unqualified-id before '(' token

define min(a,b) ((a)<(b)?(a):(b))

              ^

/Users/ericd/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r1/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.tcc: In member function 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const _CharT*) const': /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/nano_gfx_types.h:35:18: error: expected unqualified-id before '(' token

define min(a,b) ((a)<(b)?(a):(b))

              ^

/Users/ericd/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r1/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.tcc: In member function 'int std::cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*) const': /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/nano_gfx_types.h:35:18: error: expected unqualified-id before '(' token

define min(a,b) ((a)<(b)?(a):(b))

              ^

/Users/ericd/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r1/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.tcc: In member function 'int std::cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*, std::cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) const': /Users/ericd/Documents/Arduino/libraries/ssd1306-master/src/nano_gfx_types.h:35:18: error: expected unqualified-id before '(' token

define min(a,b) ((a)<(b)?(a):(b))

lexus2k commented 2 years ago

Hmm, I fixed some similar issue for lcdgfx few days or weeks ago. It looks like ESP32 IDE was updated greatly. Can you port the changes from https://github.com/lexus2k/lcdgfx/commit/053e92216829df4e040df8c5f1388b3f0f271dda commit, and let me know if the issue is gone?

ericd1949 commented 2 years ago

Very happy to do that, I'm away this weekend, so I'll try it early next week.

Just to be clear, I'll put the changes from that commit into nano_gfx_types .h and see what happens

ericd1949 commented 2 years ago

Yes, excellent, that fixed it. I changed:

define min(a,b) ((a)<(b)?(a):(b)) to #define __min(a,b) ((a)<(b)?(a):(b))

and

define max(a,b) ((a)>(b)?(a):(b)) to #define __max(a,b) ((a)>(b)?(a):(b))

Thanks for your help.