ropg / heltec_esp32_lora_v3

Proper working Arduino library for the Heltec ESP32 LoRa v3 board, as well as for Wireless Stick v3 and Wireless Stick Lite v3. Uses RadioLib
MIT License
250 stars 12 forks source link

PlatformIO VSC config Ubuntu #24

Open jo-ei opened 1 month ago

jo-ei commented 1 month ago

Hi, i like to use it on my Ubuntu with Visual Studio Code with platform.io.

here is my platformio.ini config

[platformio]
default_envs = my-config
description = my Test Project

[env:my-config]
platform = espressif32
board = heltec_wifi_lora_32_V3
framework = arduino
monitor_speed = 115200

lib_deps = 
    ropg/Heltec_ESP32_LoRa_v3@^0.9.0

build_flags = 
    -DWireless_Stick_V3=1
    -DREGION_EU868=1
    -DHELTEC_WIRELESS_STICK_LITE=1

i got the following error:

In file included from src/main.cpp:5:
.pio/libdeps/my-config/Heltec_ESP32_LoRa_v3/src/heltec_unofficial.h:33:19: error: 'const uint8_t GPIO_NUM_8' redeclared as different kind of symbol
 #define SS        GPIO_NUM_8
                   ^~~~~~~~~~
/home/user/.platformio/packages/framework-arduinoespressif32/variants/heltec_wifi_lora_32_V3/pins_arduino.h:23:22: note: in expansion of macro 'SS'
 static const uint8_t SS    = 8;
                      ^~
In file included from /home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32s3/include/esp_hw_support/include/esp_sleep.h:13,
                 from /home/user/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal.h:33,
                 from /home/user/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:36,
                 from .pio/libdeps/my-config/RadioLib/src/BuildOpt.h:121,
                 from .pio/libdeps/my-config/RadioLib/src/TypeDef.h:6,
                 from .pio/libdeps/my-config/RadioLib/src/RadioLib.h:38,
                 from .pio/libdeps/my-config/Heltec_ESP32_LoRa_v3/src/heltec_unofficial.h:53,
                 from src/main.cpp:5:
/home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32s3/include/hal/include/hal/gpio_types.h:240:5: note: previous declaration 'gpio_num_t GPIO_NUM_8'
     GPIO_NUM_8 = 8,     /*!< GPIO8, input and output */
     ^~~~~~~~~~

Same by the other: MOSI, MISO, SCK, RST_OLED, BUSY_LoRa, .......

Can somebody help me to get this fixed?

Thanks

Velocet commented 4 weeks ago

build_flags = -DWireless_Stick_V3=1 -DREGION_EU868=1 -DHELTEC_WIRELESS_STICK_LITE=1

You defined the used board three times. Try this instead:

build_flags = -DREGION_EU868=1

jo-ei commented 4 weeks ago

Thanks for the tip, unfortunately the error remains 100% the same.

According to the documentation "5. Stick or Stick Lite?" I have to set the value HELTEC_WIRELESS_STICK_LITE.

I'm currently just not sure if -DREGION_EU868=1 works for the frequency selection

ropg commented 4 weeks ago

To my knowledge, that region definition only does something if you use the stack that Heltec included with its library. As we use RadioLib, it does nothing.

aintgotnoname commented 3 weeks ago

Of course, you could just comment out the duplicate definitions in the heltec_unofficial.h file. The defined values are the same as the pins_arduino.h file where the original/duplicates are found. I don't believe there is a way to use defines to avoid this conflict in .ini or environments to avoid this.

Your next conflict will be when you try including heltec_unofficial.h in multiple .cpp files.
That will require a different refactoring of this include into separate declarations and definitions. (Burdensome with updates, but works for me.)

ropg commented 3 weeks ago

As for having everything in the .h file:

I gave that some thought actually, but simply could not come up with a scenario where you'd need/want to include this library twice, ever. There are advantages to doing it this way, the main one being that I can make the code behave differently based on #define statements before the #include. That doesn't work if the library is a separate compilation unit.

How would you then turn off compilation of the display driver, or tell loop() to do button power-off? Modify a config.h in library dir? (harder to explain, can't contain it in examples, possibly overwritten on upgrades)

ropg commented 3 weeks ago

As for the definitions. I put them in there so that things still worked when playing with generic ESP32 board definitions while experimenting with my own board definitions, a direction I have since abandoned because it was a much larger can of worms than I thought. It's on my list to make things work with platformio, just have been busy with other things.