Help with drawing on Display - Sample code

Can anyone give me or point me to some sample code for drawing on the display of an ESP32-S3- BOX LITE.

I'm using the Arduino IDE

I have tried various examples from Github, some work to an extent and some don't, as they require other libraries that don't exist.

All I want is to be able to Draw a line, Draw a pixel etc...basic stuff.

Thanks
Phil

I've moved your topic to Project Guidance....I don't think the was anything to do with the community.

What examples have you tried?

Thanks for that - I wasn't sure where to put it.

I've tried the ones here;
https://github.com/esp-arduino-libs/ESP32_Display_Panel/tree/master

The Panel example took a lot of configuration of Conf files, and did give me a coloured banner on the screen; but I couldn't find any documentation on other Draw commands.

I then tried the LvGl Porting example but get errors on the compile, with other components missing. I have posted the errors on the ESP forum.

I have created sketch's before on Arduino boards with displays - using TinyScreen libraries - and this was a breeze and worked a treat. I'm just looking for something simple forr the ESP.

I'm relatively new to Embedded programming, (though have over 30years+ coding experience on other systems) - and just doing this as a 1-off for a colleague - so looking for something quick and easy.

thanks

Phil

That's alright I like to move stuff when it's needed. :blush:

EDIT: I see you must of....
I presume you also tested out the ESP32 examples from here?

Wow.. I thought there might be an easy answer here, but looking through the example code, apparently not.

It seems like they're not that excited about you getting up and drawing quickly with that product, hey?

I have basically no relevant experience here to offer, but if you can get the "coloured banner" example to draw bitmap data to the screen, you could probably use a separate library, like AdafruitGFX, to render bitmap data, and then feed it into your working example.

This may or may not be a reasonable way of going about things..

1 Like

OK, I found more info on the ESP32....Can you see if this library for displays on ESP32s works?

GitHub - Bodmer/TFT_eSPI: Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips

News: New board setup files have been added for the Seeed XIAO with round display, LilyGo T-Embed S3, LilyGo_T_QT_Pro_S3, ESP32 S3 Box and ESP32_S3_Box_Lite. The "RPi" interface style boards are now supported with the ESP32 S3.

Yeah, @theeccentricgenius's idea is sounding much better. Forget my nonsense.

Thanks Guys - I'm out this afternoon but will look at your suggestions later this evening and get back to you on progress.

Tried to use this, especially lvDemos one, but the examples aren't Arduino based, and the included libraries aren't in the project?

#include "bsp/esp-bsp.h"
#include "demos/lv_demos.h"

Yes tried to use that but get errors

Error compiling for board ESP32-S3-Box.
xtensa-esp32s3-elf-g++: error: CreateProcess: No such file or directory

But can't find any references to xtensa-esp32s3-elf-g++?/

Phil

I dont think they will write one library for each device attached to ESP32.
I think they ported major functions (not all) for the SOC, the chip itself ESP32 only. as you can read in arduino core esp32 page.
go to espressif page and study this solution datasheet. it might require you to program in esp-idf IDE and that´s it....it´s my guess, sorry if im wrong.

Did you take a look at TFT_eSPI yet, suggested by theeccentricgenius?

The example Gradient_Fill.ino seems nice and simple.

I think(?) you should be able to copy the macros from Setup250_ESP32_S3_Box_Lite.h to the top of your example sketch.

Edit: Actually, uncomment the line in User_Setup_Select.h

Toddnz

Really appreciate the help here, but I must be missing something. That TDT_eSPI compiles and loads fine - but doesn't show anything on the screen - I've put some SerialPrint lines in to see where it's up to and it seems to just stop after the setup runs.

I've also included the User_Setup_Select.h and uncommented the relevant board for BOX_Lite - but same thing. Compiles fine but seems lock up after Setup.

Code below - Show 'Setup DOne now' - then 'in the loop' - then stops. Nothing on screen at all.

`/*
  This sketch demonstrates the use of the horizontal and vertical gradient
  rectangle fill functions.

  Example for library:
  https://github.com/Bodmer/TFT_eSPI

  Created by Bodmer 27/1/22
*/
#include <Arduino.h>
#include <User_Setup_Select.h>
#include <TFT_eSPI.h>       // Include the graphics library
TFT_eSPI tft = TFT_eSPI();  // Create object "tft"

// -------------------------------------------------------------------------
// Setup
// -------------------------------------------------------------------------
void setup(void) {
 Serial.begin(115200); /* prepare for possible serial debug */
 Serial.println("Hello Arduino!");
 
  tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_RED);
  tft.setTextFont(2);
   Serial.println("Setup done now");
}

// -------------------------------------------------------------------------
// Main loop
// -------------------------------------------------------------------------
void loop()
{
  Serial.println("In the loop");
  tft.fillRectHGradient(0, 0, 160, 50, TFT_MAGENTA, TFT_BLUE);
  tft.setCursor(10,10);
  tft.print("Horizontal gradient");

  tft.fillRectVGradient(0, 60, 160, 50, TFT_ORANGE, TFT_RED);
  tft.setCursor(10,70);
  tft.print("Vertical gradient");

  while(1) delay(500); // Wait here
    
  Serial.println("In the loop");
}`

ST7789V is supported by TFT_eSPI.... You don't need to include the User_Setup_Select.h.

You need to uncomment this line,

//#include <User_Setups/Setup25_TTGO_T_Display.h> // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT

Not this line though.

//#include <User_Setups/Setup24_ST7789.h> // Setup file for DSTIKE/ESP32/ESP8266 configured for ST7789 240 x 240

I've got a ST7789V screen on a different ESP32 model, and I use this library....It should work for you too.

EDIT: Follow the instructions in post #16.

I do notice the line:

//#include <User_Setups/Setup250_ESP32_S3_Box_Lite.h>      // For the ESP32 S3 Box Lite

Supposedly for the exact hardware being used. I would hope that this setup works! I realize that this was the setup you were already testing out.

I have no experience in this area, only a few general observations to make, sorry.

@PhilMonfie I do hope that you have some success. It looks like you've been taking all the right steps, yet still no luck.

I keep forgetting to update my library....I've got user setups for TTGO and probably a few other modifications I've forgotten. :roll_eyes:

Thanks. If I don't include the #include <User_Setup_Select.h> line - how does it find it?

I've got it in a libraries folder in the sketch, with all of the setup files in a folder alongside.

TFT_Drawing_Test
---->TFT_Drawing_Test.ino
---->libraries
-------->User_Setup_Select.h
-------->User_Setups
-------------->all of the setup files

Peeking through the source code, it seems like User_Setup_Select.h is included in TFT_eSPI.h

Have you tried installing the library with the "library manager"?

User_Setup_Select.h is included with one of the other library files....I don't know exactly which one, and don't really care to much about it as it works.