Warning: Adafruit_GFX setAddrWindow() function parameter change

Unfortunately Adafruit have changed the input parameters to the setAddrWindow() member function for all the Adafruit_GFX compatible hardware libraries.

This has broken compatibility with all legacy sketches that used the function and means that derived libraries are no longer compatible. If your library or sketch is affected then complain to Adafruit.

From the technical viewpoint the change makes sense since typically these end point coordinates needed to be calculated in the sketch or calling function, but now they must be calculated in the library function.

It used to be:

setAddrWindow(x_start, y_start, x_end, y_end);

If it now:

setAddrWindow(x_start, y_start, width, height);

You should also use startWrite() and endWrite() to bracket low level writes, this is essential for the ESP32 which uses a mutex to access the SPI hardware. The following change will work for the Adafruit JPEGDecoder library examples:

   tft.startWrite(); // <<<<<<<<<<<< New

   // draw image MCU block only if it will fit on the screen
   if ( ( mcu_x + win_w) <= tft.width() && ( mcu_y + win_h) <= tft.height())
   {
     // Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
     // tft.setAddrWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1); // Old line
     tft.setAddrWindow(mcu_x, mcu_y, win_w, win_h);  // <<<<<<<<<<<< new changed line
     // Write all MCU pixels to the TFT window
     while (mcu_pixels--) tft.pushColor(*pImg++);
   }

   else if ( ( mcu_y + win_h) >= tft.height()) JpegDec.abort();

   tft.endWrite();  // <<<<<<<<<<<< New

A user here also reports that drawRGBBitmap() can be used to paint the jpeg blocks to the screen.

I only noticed the change a few weeks ago.
If you look through the GitHub history you will see that the change was almost two years ago.

I agree. Using w, h is far better than x1, y1.
It would have been wiser to declare a new method with a different name and deprecate the old style x1, y1 method.

The "other" feature is: Mode #3 for software SPI and mode #0 for hardware SPI.

Hey-ho. Adafruit can do whatever they want. I am surprised that neither I nor Bodmer had noticed the "changes" until now.

David.

Yes, looks like the change happened in March 2017 in the hardware driver libraries like ILI9341, and then migrated into the SPI code incorporated into the GFX library.

I suspect that 2016 was the last time I looked at the Adafruit code, doesn't time fly!

It is not a big deal as few sketches use setAddrWindow and most folk seem to stick with a particular library and the associated examples.

At least it makes setAddrWindow parameters more intuitive.

Had not noticed the bit bashed SPI mode change but that is not something I have needed.