lexus2k / ssd1306

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

Refactor ssd1306_platform_i2cInit to commonize all platform signatures #71

Closed montaguk closed 5 years ago

montaguk commented 5 years ago

Initial attempt at a solution for #68.

This implementation refactors ssd1306_platform_i2cInit to use a config structure instead of the generic arg value that is used now. This approach allows the signature to remain the same across all platforms, but is now flexible enough to support setting all of the required fields in the more complicated platforms like esp32.

The public APIs for I2C init (ssd1306_i2cInit and ssd1306_i2cInitEx) are not impacted. This does, however, change the way that ssd1306_platform_i2cInit is called, but it doesn't appear that this is intended to be a public facing API. If anyone is currently using this API directly in a consuming project, I would expect compilation errors (or at least warnings) since the type for the third arg has changed from a uint8_t to a pointer.

Please note that I only tested this on the esp32 (IDF) platform as I don't have any of the other setups readily available.

lexus2k commented 5 years ago

I reverted merge commit due to issues with compilation. Please, submit new pull request after fixing the issues.

montaguk commented 5 years ago

Sorry for the churn on this. Looks like I missed an parameter rename in the Arduino platform init that I wasn't set up to test with before. I went back and installed Arduino and have a branch that works on the ESP32 via the Arduino APIs/toolchain.

I also confirmed that my new branch is working using the Linux SDL build. However I've been running into issues when building for vanilla AVR. I'm getting build failures related to code I haven't touched on the AVR platform.

I'm running:

./build_and_run.sh -p avr -m attiny85 -f demos/ssd1306_demo

but I run into issues:

mkdir -p ../bld/lcd/
avr-gcc -std=gnu11 -mmcu=attiny85 -DF_CPU=16000000 -MD -g -Os -I. -Wall -Werror -ffunction-sections -fdata-sections -fno-exceptions -c lcd/lcd_ili9341.c -o ../bld/lcd/lcd_ili9341.o
lcd/lcd_ili9341.c: In function ‘ili9341_240x320_init’:
lcd/lcd_ili9341.c:200:26: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
     ssd1306_lcd.height = 320;
                          ^
cc1: all warnings being treated as errors
Makefile.common:43: recipe for target '../bld/lcd/lcd_ili9341.o' failed
make[1]: *** [../bld/lcd/lcd_ili9341.o] Error 1

I checked out master and repeated, and it seems to be broken there as well. Is this known to be working on master? Perhaps I have some sort of configuration issue that is resulting in the wrong files being compiled?

Once I've rebased/squashed my branch I'll submit a new PR with the build issue addressed.