-
Notifications
You must be signed in to change notification settings - Fork 214
Arduino Multiple Configs
Overview > Configuring GUIslice >
GUIslice relies on a series of config flags to selectively compile various drivers and features. This selectivity makes it possible to run on low resource devices. By default, the user config is defined in the library folder itself, along with the core library files. Changing the config options generally means updating the config in the GUIslice library folder, not the user sketch.
Development environments such as Arduino IDE or PlatformIO differ in how they support the ability to alter these compilation flags.
The Arduino IDE is deliberately very restrictive when it comes to enabling different compilation configuration options to be loaded. Unfortunately this prevents defining compilation flags in the sketch or just placing a config file in the sketch folder.
However, if a user is running GUIslice on more than one hardware setup, there are a couple solutions as noted below:
-
Create GUIslice example sketches
- Copy the GUIslice examples from the unzipped folder (
GUIslice-master\examples\arduino\*
orGUIslice-master\examples\arduino_min\*
) into the Arduino sketches folder (eg.My Documents\Arduino\
)
- Copy the GUIslice examples from the unzipped folder (
-
Modify the GUIslice config
- Modify the GUIslice config file (
GUIslice_config.h
) located in the in the Arduino library folder - See the section Configuring-GUIslice for details
- Modify the GUIslice config file (
-
Copy images to SD card (optional)
- If external SD card is enabled, copy resource (images) from the unzipped folder (
\examples\arduino\res
) into the root of the SD card
- If external SD card is enabled, copy resource (images) from the unzipped folder (
-
Run an example sketch
- Select an example sketch to run (eg.
ex02_ard_btn_txt
) - Open the sketch, verify and upload
- Select an example sketch to run (eg.
The above Method 1 provides the same GUIslice configuration (GUIslice_config.h<
) to all sketches. However, there may be cases where different sketches are targeting different display hardware, pinouts or other settings. In that case, the GUIslice configuration should be stored within the sketch folder instead of the library folder. However, since the GUIslice library requires direct access to the configuration file, it is actually easiest to copy all GUIslice source files into the sketch folder:
- Remove the GUIslice library folder (from the Arduino libraries folder)
- Copy the GUIslice library to each sketch folder
- Copy the source files from the unzipped folder (
GUIslice-master\src\*
) into the GUIslice example sketch folder (eg.\Arduino\ex02_ard_btn_txt\
) - After this, your Arduino sketch folder should look like:
- Copy the source files from the unzipped folder (
My Documents\Arduino\
ex02_ard_btn_txt\
ex02_ard_btn_txt.ino
GUIslice.c
GUIslice.h
GUIslice_config.h
GUIslice_config_ard.h
GUIslice_drv.h
GUIslice_drv_adagfx.cpp
GUIslice_drv_adagfx.h
...
configs\
my-config.h
- Modify the GUIslice config in each of the GUIslice example sketch folders as required
Similar to Method 1, the global config file is updated. However, to support different configurations, we can detect the different platforms (eg. ESP vs Arduino) and select a different user config file accordingly.
To do this, we can modify the /src/GUIslice_config.h
to use a couple #ifdef
commands to selectively load the different user config files:
// ---------------------------------------------------------------------------------------
// Add your own configs here:
// ---------------------------------------------------------------------------------------
#if defined(__AVR__)
#include "../configs/my-config-arduino.h"
#elif defined(ESP8266) || defined(ESP32)
#include "../configs/my-config-esp.h"
#endif