Custom Build using PlatformIO?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Custom Build using PlatformIO?

#1 Post by rmhoutz » 20 Apr 2021, 02:23

In the documents it says to open the file pre_extra_script.py if the first Build is successful.
But I can't find any file with that name in the Github source file. Here is what is found with a *.py search.
Screenshot 2021-04-19 202117.png
Screenshot 2021-04-19 202117.png (33.33 KiB) Viewed 6988 times

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Custom Build using PlatformIO?

#2 Post by Ath » 20 Apr 2021, 08:27

For ESP8266/ESP8285 you can edit pre_custom_esp82xx.py and for ESP32 you can edit pre_custom_esp32.py

Alternative is you copy Custom-sample.h to Custom.h (in the same foulder you find Custom-sample.h), and un-comment all the options and plugins you want, set your local WiFi credentials so it will connect automatically, etc.

OT: To me, the advantage of editing these .py files is that your build will be as close to the prebuilt 'custom' builds, with the plugins you select added. You will have to pay attention when updating your sources though (using 'git pull upstream mega', assuming you have added the ESPEasy repo as 'upstream' from your fork).
/Ton (PayPal.me)

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#3 Post by rmhoutz » 20 Apr 2021, 14:45

Ath wrote: 20 Apr 2021, 08:27 For ESP8266/ESP8285 you can edit pre_custom_esp82xx.py
I haven't made any changes to pre_custom_esp82xx.py but it's showing I have 4 errors and 4 warnings.
Is that normal?
Screenshot 2021-04-20 084244.png
Screenshot 2021-04-20 084244.png (39.07 KiB) Viewed 6967 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Custom Build using PlatformIO?

#4 Post by TD-er » 20 Apr 2021, 15:12

Then you probably have not installed PlatformIO in your VS code.
It is under the "extensions" in VS code.
Installation of PlatformIO does take a while and needs a restart of VS code.
See also: https://www.youtube.com/watch?v=ArqwMcYSMsU

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#5 Post by rmhoutz » 20 Apr 2021, 15:15

I successfully flashed the build_output\bin\ESP_Easy_mega_20210420_custom_ESP8266_4M1M.bin
And was able to get on the AP and configure my WiFi.
For ESP8266/ESP8285 you can edit pre_custom_esp82xx.py and for ESP32 you can edit pre_custom_esp32.py

Alternative is you copy Custom-sample.h to Custom.h (in the same foulder you find Custom-sample.h), and un-comment all the options and plugins you want, set your local WiFi credentials so it will connect automatically, etc.
Should I be able to configure my WiFi and set options and plugins via the pre_custom_esp82xx.py?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Custom Build using PlatformIO?

#6 Post by TD-er » 20 Apr 2021, 15:19

If you want such specific settings, you may want to have a look at the Custom-sample.h and rename it to Custom.h.
The build process detects whether this file exists and will use it for "Custom" builds made in PlatformIO.

Setting string-like configuration like passwords is a bit tricky in a Python config file, so for that it is better to use the Custom.h route.
You may also keep a copy of Custom.h somewhere for yourself to make it easier to create your own builds.
The file will never be overwritten by Git checkouts, but just to be sure it is best to keep a copy somewhere else too as you will probably use that file a lot :)

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#7 Post by rmhoutz » 20 Apr 2021, 15:22

TD-er wrote: 20 Apr 2021, 15:12 Then you probably have not installed PlatformIO in your VS code.
It is under the "extensions" in VS code.
Installation of PlatformIO does take a while and needs a restart of VS code.
See also: https://www.youtube.com/watch?v=ArqwMcYSMsU
Here is my extensions in VS.
Screenshot 2021-04-20 091704.png
Screenshot 2021-04-20 091704.png (119.65 KiB) Viewed 6958 times
If I click the extension it gives me the option to Uninstall.
Screenshot 2021-04-20 091857.png
Screenshot 2021-04-20 091857.png (42.14 KiB) Viewed 6958 times
I did follow along with the youtube video provided.

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#8 Post by rmhoutz » 20 Apr 2021, 15:26

TD-er wrote: 20 Apr 2021, 15:19 If you want such specific settings, you may want to have a look at the Custom-sample.h and rename it to Custom.h.
The build process detects whether this file exists and will use it for "Custom" builds made in PlatformIO.
Okay now I feel like I'm getting somewhere. :D

Thanks for this information TD-er

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Custom Build using PlatformIO?

#9 Post by TD-er » 20 Apr 2021, 15:38

The Python extension is disabled on my setup, so I guess I have done that with a reason...

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#10 Post by rmhoutz » 20 Apr 2021, 16:31

Good to know I have now disabled Python in my setup also.
Screenshot 2021-04-20 101505.png
Screenshot 2021-04-20 101505.png (12.39 KiB) Viewed 6949 times
I copied and saved Custom-sample.h as Custom.h
Screenshot 2021-04-20 101610.png
Screenshot 2021-04-20 101610.png (31.52 KiB) Viewed 6949 times
I configured the Custom.h file with my network settings and enabled some of the Controllers
Screenshot 2021-04-20 102017.png
Screenshot 2021-04-20 102017.png (62 KiB) Viewed 6949 times
After uploading using PlatformIO none of my settings have taken.
Screenshot 2021-04-20 102317.png
Screenshot 2021-04-20 102317.png (64.58 KiB) Viewed 6949 times
The terminal shows the custom_ESP8266_4M1M was a success
Screenshot 2021-04-20 102930.png
Screenshot 2021-04-20 102930.png (34.86 KiB) Viewed 6949 times
I'm not using any ESP32 devices so if I can get it to quit trying to use that it would be great.

Thanks again for all your help.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Custom Build using PlatformIO?

#11 Post by Ath » 20 Apr 2021, 16:46

You should best build (or upload) from the PlatformIO menu:
Screenshot - 20-04-2021 , 15_58_19.png
Screenshot - 20-04-2021 , 15_58_19.png (18.36 KiB) Viewed 6947 times
/Ton (PayPal.me)

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#12 Post by rmhoutz » 20 Apr 2021, 17:09

Got ya. I used the Upload under project tasks but the device still booted back up into AP and didn't have my Wifi settings.
After I connect to my Wifi using a tablet it will then connect to my network but doesn't have any of the other settings I configured like NTP and MQTT.
Screenshot 2021-04-20 110239.png
Screenshot 2021-04-20 110239.png (143.74 KiB) Viewed 6944 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Custom Build using PlatformIO?

#13 Post by TD-er » 20 Apr 2021, 17:13

I wonder what you mean by the settings not being used...
If you refer to those "DEFAULT_..." defines, those are only used when creating a new instance of whatever they refer to.
So you may need to perform a "factory default" (See tools page) to create a new settings file where all your DEFAULT_xxx defines are being used.

You may first want to check you actually have uploaded the latest build (see Tools->Sysinfo page, the build time)
When you just recompile only a few changed files, you may want to do a "clean" build first in PlatformIO (option is shown on Ath's screenshot) and then perform a new build or else the _BUILD_TIME_ may not be reflecting the actual build time.

I find uploading via PIO quite simple to do as you then have feedback whether an update was successful, which may not always be clear when doing an OTA update.

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#14 Post by rmhoutz » 20 Apr 2021, 19:05

TD-er wrote: 20 Apr 2021, 17:13 I wonder what you mean by the settings not being used...
If you refer to those "DEFAULT_..." defines, those are only used when creating a new instance of whatever they refer to.
Yes that's what I was meaning.
I did a Erase Flash then uploaded it and it did pickup the defaults.

Thanks again for all the patience you've shown me.

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#15 Post by rmhoutz » 20 Apr 2021, 21:00

If I'm understanding correctly, if I reset the unit to factory defaults anything that was configured in my initial upload of my Custom.h should be restored?
Is that correct?

Or do I need to do something more to save a Pre-defined config?
Screenshot 2021-04-20 145812.png
Screenshot 2021-04-20 145812.png (34.36 KiB) Viewed 6929 times

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Custom Build using PlatformIO?

#16 Post by rmhoutz » 20 Apr 2021, 21:20

I would also like to set the I2C Interface to None in my Custom.h can that be done by commenting out those lines?
Screenshot 2021-04-20 151913.png
Screenshot 2021-04-20 151913.png (3.02 KiB) Viewed 6926 times

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Custom Build using PlatformIO?

#17 Post by Ath » 20 Apr 2021, 21:50

If you change both values to (-1) they will show as None in the UI (and I2C will be technically disabled).

Edit: Checkout the value for DEFAULT_PIN_STATUS_LED, a few lines lower.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests