Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

blitFrameBuffer hangs
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

blitFrameBuffer hangs

by dstieglitz on Sat Nov 27, 2021 4:41 pm

Hi there:

I am trying to use the Arcada frame buffer for double buffering on my Clue. Below is a sample program that shows the issue I'm having. The blitFrameBuffer method seems to hang on a second call after successfully drawing to the screen? Maybe it's something else. I based this code on the examples and the documentation, can anyone shed some light on what's going on here (or reproduce this)?

Arduino 1.8.16
Arcada 2.5.2

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_Arcada.h>

Adafruit_Arcada arcada;
uint16_t *framebuffer;

#define SCREEN_W 240
#define SCREEN_H 240
#define DISP_TOP 30

void setup() {
  while (!Serial);
  Serial.begin(115200);
  Serial.println("clue_blit_test");

  if (!arcada.arcadaBegin()) {
    Serial.print("Failed to begin");
    while (1);
  }
  delay(200);
 
  Serial.println("displayBegin()...");
  arcada.displayBegin();
  Serial.println("createFrameBuffer(240,240)...");
  if (! arcada.createFrameBuffer(SCREEN_W, SCREEN_H)) {
    Serial.println("Failed to allocate framebuffer");
    while (1);
  }
 
  framebuffer = arcada.getFrameBuffer();
  Serial.println((int)framebuffer);
  arcada.setBacklight(255);
  delay(200);
 
  draw_loading_screen("Loading...", arcada.getCanvas());
  if (!arcada.blitFrameBuffer(0, 0, false, true)) {
    Serial.println("Could not blit frame buffer for some reason");
  }
  delay(200);
 
  Serial.println("done setting up");
}

void draw_loading_screen(String text, GFXcanvas16 *_canvas) {
  Serial.println("draw_loading_screen");
  _canvas->fillScreen(ARCADA_BLACK);
  _canvas->setCursor(0, DISP_TOP);
  _canvas->setTextSize(2);
  _canvas->setTextColor(ARCADA_RED, ARCADA_BLACK);
  _canvas->print(text);
}

void loop() {
  int i = 0;
  while (1) {
    draw_loading_screen("Loading " + i, arcada.getCanvas());
    if (!arcada.blitFrameBuffer(0, 0, false, true)) {
      Serial.println("Could not blit frame buffer for some reason");
    }
    delay(1000);
    i++;
  }
}
dstieglitz
 
Posts: 8
Joined: Mon Dec 16, 2013 1:08 pm

Re: blitFrameBuffer hangs

by dstieglitz on Thu Dec 02, 2021 11:21 am

FWIW this seems to be happening with the latest examples shipped for Arduino, e.g., https://github.com/adafruit/Adafruit_Ar ... lotter.ino

I'm trying to figure out if this is a "my environment" issue or a known issue with the latest libraries... if anyone can reproduce (or not) please lmk.
dstieglitz
 
Posts: 8
Joined: Mon Dec 16, 2013 1:08 pm

Re: blitFrameBuffer hangs

by jimsbugs on Tue Dec 21, 2021 6:19 pm

Yes, this is broken for me, too. Digging into it, there appears to be a bug in the Adafruit support for NRF52 boards in the SPI code. In version 1.2.0, line 211 of the file:
Code: Select all | TOGGLE FULL SIZE
~/.arduino15/packages/adafruit/hardware/nrf52/1.2.0/libraries/SPI/SPI.cpp

is:
Code: Select all | TOGGLE FULL SIZE
    const size_t xfer_len = min((uint16_t) count, UINT16_MAX);

Changing it to:
Code: Select all | TOGGLE FULL SIZE
    const size_t xfer_len = min(count, UINT16_MAX);

allows blits to work properly on the CLUE. Hopefully that is sufficient to get you going.

jimsbugs
 
Posts: 1
Joined: Tue Dec 21, 2021 6:03 pm

Re: blitFrameBuffer hangs

by dstieglitz on Fri Dec 24, 2021 11:49 am

Excellent find, this fixes the problem for me -- thank you @jimsbugs.
dstieglitz
 
Posts: 8
Joined: Mon Dec 16, 2013 1:08 pm

Re: blitFrameBuffer hangs

by dstieglitz on Fri Dec 24, 2021 11:59 am

dstieglitz
 
Posts: 8
Joined: Mon Dec 16, 2013 1:08 pm

Please be positive and constructive with your questions and comments.


cron