Can one library have multiply sub libraries inside?

I have one library imported in Arduino Create: Elegoo_GFX.h

But in a code example there is included 3 libraries:

#include <Elegoo_GFX.h> // Core graphics library
#include <Elegoo_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>

Is Elegoo_TFTLCD.h and TouchScreen.h sub directories in the Elegoo_GFX.h library?

(deleted)

It looks like it, but I find it pretty weird, that a library has a "hidden" sub library. How do I see if it has other "hidden" sub libraries?

spycatcher2k:
Look and see! you have the libraries there! :slight_smile:

I guess there is a hint there, but as a newbie I cant figure it out.

(deleted)

But there is nothing about Elegoo_TFTLCD.h or TouchScreen.h in the Elegoo_GFX librarys files. But somehow it is included in the program without problem.

That is what I dont understand and was hoping somebody could tell me.

(deleted)

AalborgHTX:
Is Elegoo_TFTLCD.h and TouchScreen.h sub directories in the Elegoo_GFX.h library?

Some libraries have multiple .h files. That doesn't mean it's multiple "sub libraries", it just means they split the declarations into multiple files.

Some libraries have dependencies on other libraries and the library author may decide to just dump that library into the folder with their own library. This makes it so the user doesn't need to install the dependency separately and also ensures that they will be using the specific version of the dependency the library was written to use.

Whether either of those are the case, I couldn't say without looking at the library in question. I can't do that because you didn't provide a link to the library.

What I can tell you for certain is that none of those files are in a subdirectory. If they were, you would need to specify the subdirectory in the #include directive.

AalborgHTX:
I have one library imported in Arduino Create

An important difference between the Arduino Web Editor (AKA "Arduino Create") and the Arduino IDE is that all the 2000+ libraries in the Arduino Library Manager index are pre-installed in the Arduino Web Editor, whereas you need to specifically install those libraries in the Arduino IDE. So even if you haven't imported a library, if it's in the Arduino Library Manager index, you have it installed and you can #include it in your sketches. I don't know whether these particular libraries are in the Arduino Library Manager index. If you check the box next to "Console: Show verbose output", compile your sketch, and then check the contents of the black console panel below the sketch panel (you might need to drag it up to make it visible if you don't have Preferences > Always show output panel checked) then you will see the locations of all the libraries used by the sketch. If you are having trouble interpreting that information, post it here and I'll explain it.

I have imported the library Elegoo GFX library in Arduino Create. But no “TFTLCD” or “Touchscreen” library.

In the example (a program called “phonecal”) have these things included:

#include <Elegoo_GFX.h> // Core graphics library
#include <Elegoo_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>

But somehow it compiles the example with no problem.

The console:
/home/builder/opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware /home/builder/opt/arduino-builder/hardware -hardware /home/builder/.arduino15/packages -tools /home/builder/opt/arduino-builder/tools -tools /home/builder/.arduino15/packages -built-in-libraries /home/builder/opt/libraries/latest -logger humantags -fqbn arduino:avr:uno -build-cache /tmp -build-path /tmp/228537286/build -verbose -prefs runtime.tools.flashpack.path=/home/builder/.arduino15/packages/Intel/tools/flashpack/2.0.0 -prefs runtime.tools.core2-32-poky-linux.path=/home/builder/.arduino15/packages/Intel/tools/core2-32-poky-linux/1.6.2+1.0 -prefs runtime.tools.arm-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-linux-gcc/4.9.3 -prefs runtime.tools.linuxuploader.path=/home/builder/.arduino15/packages/arduino/tools/linuxuploader/1.5.1 -prefs runtime.tools.x86-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/x86-linux-gcc/7.2.0 -prefs runtime.tools.dfu-util.path=/home/builder/.arduino15/packages/arduino/tools/dfu-util/0.9.0-arduino1 -prefs runtime.tools.avr-gcc.path=/home/builder/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 -prefs runtime.tools.nrf5x-cl-tools.path=/home/builder/.arduino15/packages/arduino/tools/nrf5x-cl-tools/9.3.1 -prefs runtime.tools.i586-poky-linux-uclibc.path=/home/builder/.arduino15/packages/Intel/tools/i586-poky-linux-uclibc/1.6.2+1.0 -prefs runtime.tools.arc-elf32.path=/home/builder/.arduino15/packages/Intel/tools/arc-elf32/1.6.9+1.0.1 -prefs runtime.tools.arduino101load.path=/home/builder/.arduino15/packages/Intel/tools/arduino101load/2.0.1 -prefs runtime.tools.arduinoOTA.path=/home/builder/.arduino15/packages/arduino/tools/arduinoOTA/1.2.1 -prefs runtime.tools.CMSIS-Atmel.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0 -prefs runtime.tools.avrdude.path=/home/builder/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14 -prefs runtime.tools.openocd.path=/home/builder/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7 -prefs runtime.tools.sketchUploader.path=/home/builder/.arduino15/packages/Intel/tools/sketchUploader/1.6.2+1.0 -prefs runtime.tools.arm-none-eabi-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4 -prefs runtime.tools.bossac.path=/home/builder/.arduino15/packages/industruino/tools/bossac/1.7.0-industruino -prefs runtime.tools.CMSIS.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS/4.5.0 -libraries /tmp/228537286/custom -libraries /tmp/228537286/pinned /tmp/228537286/phonecal

Sketch uses 18236 bytes (56%) of program storage space. Maximum is 32256 bytes.

Global variables use 873 bytes (42%) of dynamic memory, leaving 1175 bytes for local variables. Maximum is 2048 bytes.

Programming with: Serial

Flashing with command:C:/Users/mick/.arduino-create/arduino/avrdude/6.3.0-arduino14/bin/avrdude.exe -CC:/Users/mick/.arduino-create/arduino/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:C:/Users/mick/AppData/Local/Temp/arduino-create-agent521200750/phonecal.hex:i

avrdude: Version 6.3-20171130

Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is “C:/Users/mick/.arduino-create/arduino/avrdude/6.3.0-arduino14/etc/avrdude.conf”

Using Port : COM4

Using Programmer : arduino

Overriding Baud Rate : 115200

AVR Part : ATmega328P

Chip Erase delay : 9000 us

PAGEL : PD7

BS2 : PC2

RESET disposition : dedicated

RETRY pulse : SCK

serial program mode : yes

parallel program mode : yes

Timeout : 200

StabDelay : 100

CmdexeDelay : 25

SyncLoops : 32

ByteDelay : 0

PollIndex : 3

PollValue : 0x53

Memory Detail :

Block Poll Page Polled

Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff

flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff

lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00

signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino

Description : Arduino

Hardware Version: 3

Firmware Version: 4.4

Vtarget : 0.3 V

Varef : 0.3 V

Oscillator : 28.800 kHz

SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)

avrdude: safemode: lfuse reads as 0

avrdude: safemode: hfuse reads as 0

avrdude: safemode: efuse reads as 0

avrdude: reading input file “C:/Users/mick/AppData/Local/Temp/arduino-create-agent521200750/phonecal.hex”

avrdude: writing flash (18236 bytes):

Writing | ################################################## | 100% 2.86s

avrdude: 18236 bytes of flash written

avrdude: verifying flash memory against C:/Users/mick/AppData/Local/Temp/arduino-create-agent521200750/phonecal.hex:

avrdude: load data flash data from input file C:/Users/mick/AppData/Local/Temp/arduino-create-agent521200750/phonecal.hex:

avrdude: input file C:/Users/mick/AppData/Local/Temp/arduino-create-agent521200750/phonecal.hex contains 18236 bytes

avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 2.23s

avrdude: verifying …

avrdude: 18236 bytes of flash verified

avrdude: safemode: lfuse reads as 0

avrdude: safemode: hfuse reads as 0

avrdude: safemode: efuse reads as 0

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

Link to libraries:

https://www.elegoo.com/tutorial/Elegoo%202.8%20Inch%20Touch%20Screen%20User%20Manual%20V1.00.2019.03.19.zip

Which file did you import?

pert:
Which file did you import?

Elegoo_GFX

I assume by "Elegoo_GFX", you mean "Install libraries/Elegoo_GFX.zip".

After importing only that file, I can't reproduce what you're reporting. Compilation fails for me due to the missing file Elegoo_TFTLCD.h:

/tmp/909462478/sketch_may15cg/sketch_may15cg.ino:5:56: fatal error: Elegoo_TFTLCD.h: No such file or directory

That file is not in any libraries in the Arduino Library Manager index. I think you must have imported the Elegoo_TFTLCD library and forgotten you did it. Do you see the Elegoo_TFTLCD library listed under the "Custom" tab of your libraries in Arduino Web Editor?

I find it very strange that your console output doesn't show the location of the libraries used by your sketch. When I compile the phonecal example sketch, I get this helpful information at the end of the output:

Using library Elegoo GFX Library at version 1.0.2 in folder: /tmp/481769599/custom/Elegoo GFX Library

Using library Elegoo TFTLCD at version 1.0.2 in folder: /tmp/481769599/custom/Elegoo TFTLCD

Using library adafruit_touchscreen_1_0_1 at version 1.0.1 in folder: /home/builder/opt/libraries/latest/adafruit_touchscreen_1_0_1

/home/builder/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-size -A /tmp/481769599/build/phonecal.ino.elf

Sketch uses 32878 bytes (12%) of program storage space. Maximum is 253952 bytes.

Global variables use 873 bytes (10%) of dynamic memory, leaving 7319 bytes for local variables. Maximum is 8192 bytes.

In my output, you can see exactly where each of the library files came from.

Do you see the Elegoo_TFTLCD library listed under the "Custom" tab of your libraries in Arduino Web Editor?

No. I have only the Elegoo GFX library under the Custom tab. It is very weird.

But thanks for your help :).

Please do this:

  • In the Arduino Web Editor, click the "Libraries" tab on the left side of the screen.
  • Click the "Custom" tab.
  • Hover your mouse over "Elegoo GFX Library".
  • Click the downward pointing triangle button that appears.
  • Click "Download Library".
  • Attach the downloaded file in a reply here. If you click the "Reply" button, you'll see an "Attachments and other settings" link that will allow you to make and attachment.

Okay :slight_smile:

Elegoo GFX Library.zip (31.9 KB)