olikraus / ucglib

Arduino True Color Library for TFTs and OLEDs
https://github.com/olikraus/ucglib/wiki
Other
261 stars 76 forks source link

SSD1351 not updating without using ucg.begin() #95

Open NSchnitzler opened 5 years ago

NSchnitzler commented 5 years ago

Hi,

i am making my first steps with a SSD1351 128x128 RGB OLED in combination with a Arduino DUE. My problem is, that the Display is only updatingafter using the ucg.begin(..) function at the beginning of every update like shown in the small snippet below. After commenting out this line, the display keeps the old content.

void updateScreen(void) { ucg.begin(UCG_FONT_MODE_TRANSPARENT); <--- Display not updating without this ucg.clearScreen(); ucg.setFont(ucg_font_helvB10_hr); ucg.setPrintPos(0, 40); ucg.print(String(rnd)); ucg.setPrintPos(0, 60); ucg.print(frequency); }

The init look like: ` Ucglib_SSD1351_18x128x128_HWSPI ucg(/cd=/ 9, /cs=/ 10, /reset=/ 11); // ** DISPLAY INIT *** uint8_t z = 127; // start value uint32_t lcg_rnd(void) { z = (uint8_t)((uint16_t)65 * (uint16_t)z + (uint16_t)17); return (uint32_t)z; }

setup: ucg.begin(UCG_FONT_MODE_TRANSPARENT); ucg.setFont(ucg_font_helvB14_hr); ucg.clearScreen(); `

Addition The problem seems to be the also connected AD9833, both devices seems to interfere because of the SPI bus

Can anyone help?

thank in advance

MattMatic commented 5 years ago

I have a similar issue that's related. With ILI9341 and XPT2046, the SPI bus goes down to the lowest common denominator (2MHz for touch). Actually, I think it's the last SPISettings that gets called.

Unfortunately it looks like UCGLIB isn't using SPI.begin / .beginTransaction / .end for each transfer - but assuming it has exclusive use of the SPI bus throughout the powerUp to powerDown lifetime :-(

From a quick look, it appears that UCGLIB needs a callback for 'start' and 'end' of the SPI bus access. It would also be good if the library could also use block hardware SPI transfers more frequently to send data with DMA.

(FWIW, I have an Arduino project on Teensy 3.6 that's built under Segger's Embedded Studio and J-Link programmer - which makes debugging this much easier)

Matt

NSchnitzler commented 5 years ago

I switched to SW-SPI and now both devices were working as expected.