[SOLVED] VL53L1X library won't include in web IDE


#1

I am trying to include the GitHub library for the Sparkfun VL53L1X distance sensor [https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library] into my weather station code.

I did this successfully in a small test program by clicking the “+” button in the web IDE and then copying the files

SparkFun_VL53L1X_Arduino_Library.cpp
SparkFun_VL53L1X_Arduino_Library.h
vl53l1_register_map.h

into the template tabs for my project. My code contains:

#include "vl53l1_register_map.h"
// This #include statement was automatically added by the Particle IDE.
#include "SparkFun_VL53L1X_Arduino_Library.h"
...
VL53L1X distanceSensor ;

In my test program. this all works fine. But when I repeated the same process on my weather code, I get this:


weatherlcd1.ino:442:1: error: 'VL53L1X' does not name a type

The line it’s complaining about is where the distanceSensor object is defined. As far as I can tell, I typed all the names correctly. Why did this include work OK once but not twice? What am I doing wrong?

The compiler seems to be finding the library because I see this:


Building cpp file: src/SparkFun_VL53L1X_Arduino_Library.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-6-msrc/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=0.7.0 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../services/inc -I../communication/src -I../hal/inc -I../hal/shared -I../hal/src/photon -I../hal/src/stm32f2xx -I../hal/src/stm32 -I../hal/src/photon/api -I../hal/src/photon/include -I../hal/src/photon/wiced/security/BESL/host/WICED/ -I../hal/src/photon/wiced/security/BESL/include -I../hal/src/photon/wiced/security/BESL -I../hal/src/photon/wiced/security/BESL/crypto -I../hal/src/photon/wiced/WWD/include/ -I../hal/src/photon/wiced/platform/include/ -I../hal/src/photon/wiced/platform/GCC/ -I../hal/src/photon/wiced/security/BESL/supplicant/ -I../hal/src/photon/libraries/crypto -I../platform/shared/inc -I../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F2xx/CMSIS/Include -I../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../dynalib/inc -Isrc -I./libraries -Ilib/ITEADLIB_Nextion/src -Ilib/Adafruit_Sensor/src -Ilib/SparkFun_Serial_Graphic_LCD/src -Ilib/SparkFunPhant/src -Ilib/ThingSpeak/src -Ilib/Adafruit_AM2315/src -Ilib/SparkFun_Photon_Weather_Shield_Library/src -Ilib/Sunrise/src -Ilib/OneWire/src -I. -MD -MP -MF ../build/target/user/platform-6-msrc/SparkFun_VL53L1X_Arduino_Library.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DSPARK_PLATFORM_NET=BCM9WCDUSI09 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=5 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,207 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++11 -c -o ../build/target/user/platform-6-msrc/SparkFun_VL53L1X_Arduino_Library.o src/SparkFun_VL53L1X_Arduino_Library.cpp
src/SparkFun_VL53L1X_Arduino_Library.cpp:42:6: warning: "ARDUINO" is not defined [-Wundef]
 #if (ARDUINO >= 100)
      ^
src/SparkFun_VL53L1X_Arduino_Library.cpp:68:7: warning: "__MK20DX256__" is not defined [-Wundef]
 #elif __MK20DX256__
       ^
src/SparkFun_VL53L1X_Arduino_Library.cpp:71:7: warning: "ARDUINO_ARCH_ESP32" is not defined [-Wundef]
 #elif ARDUINO_ARCH_ESP32
       ^

I must be missing something here.


#2

Is it possible for you to share your code? You can use the SHARE THIS REVISION button to get a link to your code so we can try to find your problem.


#3

It would be except that I have a number of API keys embedded in it. Is there some way I can make an exact local duplicate of my code that has all of its libraries included? That way I could redact the keys from the copy and share the result.

In the meantime I have shared the test program which does compile (and has no API keys):

https://go.particle.io/shared_apps/5bfb0a868b88543efc000461

UPDATE:

OK, I figured it out. This was strange. When you create a new library using the “+” button, the IDE gives you two empty tabs: one called “lib1.cpp” and one called “lib1.h”. I copied the .h file first. When you do that for some reason it also copies that same text into the .cpp file. When I next went to copy the original .cpp file it must not have worked and I didn’t notice.

The result was that my newVL52L1X.cpp file actually contained the text from the original VL53L1X.h file. So of couse that’s not going to compile.

But then I tried copying the original .cpp file and I ended up with the new .h file being overwritten with the .cpp text. It took three tries to get this to work correctly. I don’t think this was operator error either.

A related problem is that the tabs at the top of the window don’t display the entire file name. Instead of “SPARKFUN_VL53L1X_ARDUINO_LIBRARY_H”, all I see is “SPARKFU”. In fact I have two tabs, both named “SPARKFU”. To see which file it really is, I either have to click on the text and then laboriously right-arrow all the way to the end, or click on some other tab and then mouse over the tab of interest in which case the full name pops up at the bottom of the window. This makes it hard to tell which file you’re actually looking at.

My suggestions: the IDE should display the full file name in the tab, or if there’s no room then the full name should appear when you mouse over it. And when you copy a .h file or a .cpp file, don’t automatically copy that same text into the other file. That doesn’t even make sense.


#4

These are known bugs with Web IDE but there will be little effort to iron that out since in time current Web IDE will be superseded.

If you want to see what tab you are currently working on, just look in the address bar of your browser - for non-active tabs you’ve already found the hover-to-see-link feature.

For “quick” navigation between many tabs you can also open the project drawer (<>) and select the files from there.


#5

Ah ha - I never even thought of looking there. Of course that name is cut off there too, but hovering the mouse in the address bar will in fact display the full file name. I also never thought of clicking on the file names in the list of files on the left side. That is indeed much simpler than what I was doing. Thanks!