Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with ESP32/BLE activated and Sprites #3377

Open
Rockman18 opened this issue Jun 22, 2024 · 0 comments
Open

Issue with ESP32/BLE activated and Sprites #3377

Rockman18 opened this issue Jun 22, 2024 · 0 comments

Comments

@Rockman18
Copy link

Rockman18 commented Jun 22, 2024

On Arduino IDE and PlatformIO. I'm using a TTGO T-Display 16MB (ESP32). I want to push a sprite corresponding to a png image with transparency (normally loaded on LitlleFS but in my sample i use a fake sprite). This Sprite is pushed on a background sprite. I have another sprite corresponding to a button. I push it twice on the background sprite too. Then I push the background sprite to TFT. If I add BLEDevice::init() my png sprite never appear on scren but my buttons sprites are well displayed. Without BLEDevice::init(), all the sprites are well displayed. There is enough heap available, so I can't understand this behaviour.

  • arduino-esp32 v3.0.1 (I can't use 2.x because all my BLE architecture is based on the latest API, I need the new APIs)
  • TFT_eSPI v2.5.43 (to compile with arduino-esp32 v3.0.1 I use the workaround described in compile error in arduino ide #3346)

PlatformIO.ini

[env:lilygo-t-display]
platform = https://github.com/platformio/platform-espressif32.git
board = lilygo-t-display
board_build.partitions = huge_app.csv
board_build.filesystem = littlefs
framework = arduino
platform_packages =
	framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.1
	framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.1/esp32-arduino-libs-3.0.1.zip
monitor_speed = 115200
lib_deps =
	bodmer/TFT_eSPI@^2.5.43
	bitbank2/PNGdec@^1.0.2

main.cpp

#include <Arduino.h>
#include <TFT_eSPI.h>
#include <BLEDevice.h>

static TFT_eSPI tft = TFT_eSPI();

void setup()
{
  Serial.begin(115200);

  // TFT init
  tft.begin();
  tft.fillScreen(TFT_BLACK);

  BLEDevice::init("MyBLEDevice"); // Comment this line to display png_transparent sprite.
}

void loop()
{
  Serial.print("Heap : ");
  Serial.print(ESP.getFreeHeap());
  Serial.print("/");
  Serial.println(ESP.getHeapSize());

  TFT_eSprite backgroundSprite = TFT_eSprite(&tft);
  backgroundSprite.createSprite(135, 240);
  backgroundSprite.fillSprite(TFT_CYAN);

  // Header
  backgroundSprite.fillRect(0, 0, 135, 20, TFT_BLACK);
  
  // Header content
  backgroundSprite.setTextFont(2);
  backgroundSprite.setTextSize(1);
  backgroundSprite.setTextDatum(MC_DATUM);
  backgroundSprite.setTextColor(TFT_LIGHTGREY);
  backgroundSprite.drawString("HEADER", 67, 10);

  // Mid-Zone
  TFT_eSprite png_transparent = TFT_eSprite(&tft);
  png_transparent.createSprite(135, 200);
  png_transparent.fillSprite(TFT_TRANSPARENT);
  png_transparent.fillRect(10, 10, 50, 50, TFT_GREEN);
  png_transparent.pushToSprite(&backgroundSprite, 0, 20, TFT_TRANSPARENT); // Never pushed on background if BLEDevice is init
  png_transparent.deleteSprite();

  // Footer
  backgroundSprite.fillRect(0, 220, 135, 20, TFT_BLACK);

  // Footer content
  backgroundSprite.drawNumber(esp_timer_get_time() / 1000000, 67, 230);

  TFT_eSprite button = TFT_eSprite(&tft);
  button.createSprite(40, 10);
  button.fillSprite(TFT_RED);
  button.pushToSprite(&backgroundSprite, 5, 225, TFT_TRANSPARENT); // Well pushed on background
  button.pushToSprite(&backgroundSprite, 90, 225, TFT_TRANSPARENT); // Well pushed on background
  button.deleteSprite();

  backgroundSprite.pushSprite(0, 0, TFT_TRANSPARENT);
}

With BLEDevice::init() :

Without BLEDevice::init() :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant