Page 1 of 1

Custom Build using PlatformIO?

Posted: 20 Apr 2021, 02:23
by rmhoutz
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 7125 times

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 08:27
by Ath
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).

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 14:45
by rmhoutz
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 7104 times

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 15:12
by TD-er
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

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 15:15
by rmhoutz
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?

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 15:19
by TD-er
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 :)

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 15:22
by rmhoutz
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 7095 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 7095 times
I did follow along with the youtube video provided.

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 15:26
by rmhoutz
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

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 15:38
by TD-er
The Python extension is disabled on my setup, so I guess I have done that with a reason...

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 16:31
by rmhoutz
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 7086 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 7086 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 7086 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 7086 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 7086 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.

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 16:46
by Ath
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 7084 times

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 17:09
by rmhoutz
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 7081 times

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 17:13
by TD-er
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.

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 19:05
by rmhoutz
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.

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 21:00
by rmhoutz
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 7066 times

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 21:20
by rmhoutz
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 7063 times

Re: Custom Build using PlatformIO?

Posted: 20 Apr 2021, 21:50
by Ath
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.