blitFrameBuffer hangs

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dstieglitz
 
Posts: 8
Joined: Mon Dec 16, 2013 1:08 pm

blitFrameBuffer hangs

Post by dstieglitz »

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

#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++;
  }
}

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

Re: blitFrameBuffer hangs

Post by dstieglitz »

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.

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

Re: blitFrameBuffer hangs

Post by jimsbugs »

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

~/.arduino15/packages/adafruit/hardware/nrf52/1.2.0/libraries/SPI/SPI.cpp
is:

Code: Select all

    const size_t xfer_len = min((uint16_t) count, UINT16_MAX);
Changing it to:

Code: Select all

    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.

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

Re: blitFrameBuffer hangs

Post by dstieglitz »

Excellent find, this fixes the problem for me -- thank you @jimsbugs.

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

Re: blitFrameBuffer hangs

Post by dstieglitz »


Locked
Please be positive and constructive with your questions and comments.

Return to “CLUE Board”