• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Compiling ESP32 CYD using book up to module 2.5

Q&A Forum › Category: ESP32 › Compiling ESP32 CYD using book up to module 2.5
0 Vote Up Vote Down
Richard Funnell asked 5 months ago

I’m going through the CYD book, and I’m up to module 2.5. It compiles fine, but all the examples take ages to compile the first time.  Taking module 2.5 Basic Slider it takes 8 minutes to just compile, if I then upload it to the CYD device it takes 2 minutes to compile and upload. If I compile a Nano board with a large program it only takes 55 secs. Is this normal? My pc is i5 intel with 16mb ram just for your info. Many thanks

15 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

Hi.
Yes. It’s normal.
When you compile one of those LVGL codes for the first time it will take a considerable amount of time.
The second time you compile, it will be faster.
 
If you prefer, you can use VS Code instead of Arduino IDE, which is usually faster.
Regards,
Sara

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

Hi Sara,
I have been trying all this time to get this running under Vscode PlatformIO.   I have tried to follow the book regarding downloading a new lvgl.h file setup,  and placing it in the right place, But I really don’t know the right place to do all of the changes. I seem somehow to have loaded the library lvgl but it seemed to have downloaded version 9.2.2.
Could you please possibly steer me in the right direction

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

If you want to use VS Code, we have this guide on our blog: 

  • Programming the ESP32 CYD (Cheap Yellow Display) with VS Code

I hope this helps.
 
Regards,
Sara

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

Great, many thanks……

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

Then, let me know if you need further help.
Regards,
Sara

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

OK , just had a problem installing LVGL library, Went to search for it and it came up with 29 possibles, so not knowing which to select I inserted the library into the platformio.ini file:

lib_deps =
    https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
    bodmer/TFT_eSPI@^2.5.43
    lvgl@9.2.0

I hope this was ok. it seemed to work with the hello world, button, toggle and slider program.

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

So do I have to create the lv_conf.h file every new project?
 

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

Also have tried 2_5 example, Basic Slider, this compiles ok in Arduino IDE using the same setup in VSCode that worked with the test program: hello world, button, toggle and slider program. comes with an error:

Start your code here

 *  Executing task in folder CYD_2_5_Basic_Slider: C:\Users\Richard\.platformio\penv\Scripts\platformio.exe run 
 
Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
————————————————————————————————————–Verbose mode can be enabled via `-v, –verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.4.0+sha.a9b9d09) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 – framework-arduinoespressif32 @ 3.20011.230801 (2.0.11)
 – tool-esptoolpy @ 1.40501.0 (4.5.1)
 – toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies…
Dependency Graph
|– XPT2046_Touchscreen @ 1.4.0+sha.f956c5d
|– TFT_eSPI @ 2.5.43
|– lvgl @ 9.2.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
src/main.cpp: In function ‘void setup()’:
src/main.cpp:178:3: error: ‘ledcAttachChannel’ was not declared in this scope
   ledcAttachChannel(CYD_LED_RED, freq, resolution, ledChannel);
   ^~~~~~~~~~~~~~~~~
src/main.cpp:178:3: note: suggested alternative: ‘ledcAttachPin’
   ledcAttachChannel(CYD_LED_RED, freq, resolution, ledChannel);
   ^~~~~~~~~~~~~~~~~
   ledcAttachPin
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
 
Is there any difference to the program which I copied from the Arduino  IDE to VSCode?
that needs to change, ?
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

Hi.
So do I have to create the lv_conf.h file every new project? Yes!
 
That error is probably because you’re using an older version of the ESP32 boards.
Check the boards version you have installed in VS Code.
 
Regards,
Sara
 

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

I’m using the CYD as recommended, not the seperate ESP32 and TFT display
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

I’m sorry. 
I’m  referring to the ESP32 installation on VS Code. The ESP32-Arduino core.

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

Not sure how to check what ESP32 core is installed on PlatformIO, The program compiles right to the end but still fails on

 ledcAttachChannel(CYD_LED_RED, freq, resolution, ledChannel);
 

So I think I will return to Arduino IDE 2 at least it works.
 
Many thanks for your time and wish you both a Happy Christmas

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

Either way, for using the oldest version, you must replace:

 ledcAttachChannel(CYD_LED_RED, freq, resolution, ledChannel);

with

ledcSetup(ledChannel, freq, resolution);
ledcAttachPin(CYD_LED_RED, ledChannel);

And then, when calling the ledcWrite(), you must pass as argument the ledChannel instead of the GPIO.
Instead of this:

ledcWrite(CYD_LED_RED, map((int)lv_slider_get_value(slider), 0, 100, 255, 0))

Use this:

ledcWrite(ledChannel , map((int)lv_slider_get_value(slider), 0, 100, 255, 0))

ALTERNATIVELY:
Edit your platformio.ini file with the platform as follows:

platform = espressif32@6.1.0 ;

 

After saving the platformio.ini file with this new setting, the original code should work without changes.

 

Let me know if this helps.
Regards,
Sara

0 Vote Up Vote Down
Richard Funnell answered 5 months ago

That was really helpful, result below,
Using the Code 2.5 Basic slider from the Book version 1.4       
Tried changing the PlatformIO.ini to espressif32 @ 6.1.0
[env:esp32dev]
platform = espressif32@6.1.0
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
    https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
    bodmer/TFT_eSPI@^2.5.43
    lvgl@9.2.0
Processing esp32dev (platform: espressif32@6.1.0; board: esp32dev; framework: arduino)
Still had the error.
Changed back to platform = espressif32.

Start your code here

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
——————————————————————————————————————Verbose mode can be enabled via `-v, –verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.4.0+sha.a9b9d09) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 – framework-arduinoespressif32 @ 3.20011.230801 (2.0.11)
 – tool-esptoolpy @ 1.40501.0 (4.5.1)
 – toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies…
Dependency Graph
|– XPT2046_Touchscreen @ 1.4.0+sha.f956c5d
|– TFT_eSPI @ 2.5.43
|– lvgl @ 9.2.0
Changed the lines of code you suggested,
This compiled OK. The slider starts @ 0% but the RED LED is on full, until you start to move the slider then it dims and increases to full at 100%. Moving it back to 0% the LED is now off?
Searched through the code and changed ‘ ledcWrite(CYD_LED_RED, 255); ‘
 to ‘ledcWrite(ledChannel, 255); ‘
Now it works fine..
So, is it a library that has changed although it’s using lvgl v9.20 or is it a different version of the Arduino core? As the 2.5 code un-changed compiles on Arduino IDE 2.3.4 using ESP32 3.0.4 and the same libraries lvgl 9.2

0 Vote Up Vote Down
Sara Santos Staff answered 4 months ago

The change is related to the functions used to control PWM.
There was a change on the ESP32 arduino core. It seems that platformIO is still using the old methods by default. This is not related to LVGL.
 
You can learn more about this in this article: https://randomnerdtutorials.com/esp32-migrating-version-2-to-3-arduino/#ledc-removed-api
 
Regards,
Sara
 

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.