You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
AutoConnect/mkdocs/changelabel.md

8.1 KiB

Change the item's label text

You can change the text of AutoConnect menu items. The easiest way is to rewrite the header file directly in the library that defines the menu label. Advanced Usage section describes the detailed how to change the label text directly.

However, this way is less preferred as it modifies the library code and further affects the entire Arduino project you compile. So, here's how to change the label text for each Arduino project without directly modifying the library code. Using this method, you can also display the label text and fixed text on AutoConnect pages in your national language.

(e.g. in Japanese)

Preparation

AutoConnect needs a definition file as c++ header (.h) to change the label text. It is used when your Arduino project is compiled, and there is no additional memory consumption due to changing the label text. This header file describes each fixed text of AutoConnect with the #define preprocessor directive.

The next thing you need is PlatformIO. PlatformIO is a very powerful environment for embedded development with multi-platform and multi-architecture build systems. And you can easily set up a PlatformIO for the Arduino development system as follows on your host machine.

!!! info "Install PlatformIO and VSCode" Please refer to the official documentation for PlatformIO and VSCode installation.

The rest of this section assumes that you have a PlatformIO environment with VSCode as the front end that has installed on your host machine.

How to change the label text

Label text replacement header file

AutoConnect label texts are pre-assigned with a fixed string so that it can be determined at compile time. Their default definitions are in the AutoConnectLabels.h file that has all the replaceable label text defined by the #define directive.

Label placedPre-defined textID (#define macro)
Menu itemConfigure new APAUTOCONNECT_MENULABEL_CONFIGNEW
Open SSIDsAUTOCONNECT_MENULABEL_OPENSSIDS
DisconnectAUTOCONNECT_MENULABEL_DISCONNECT
Reset...AUTOCONNECT_MENULABEL_RESET
HOMEAUTOCONNECT_MENULABEL_HOME
UpdateAUTOCONNECT_MENULABEL_UPDATE
Device infoAUTOCONNECT_MENULABEL_DEVINFO
Button labelRESETAUTOCONNECT_BUTTONLABEL_RESET
UPDATEAUTOCONNECT_BUTTONLABEL_UPDATE
Page titlePage not foundAUTOCONNECT_PAGETITLE_NOTFOUND
AutoConnect configAUTOCONNECT_PAGETITLE_CONFIG
AutoConnect connectingAUTOCONNECT_PAGETITLE_CONNECTING
AutoConnect connection failedAUTOCONNECT_PAGETITLE_CONNECTIONFAILED
AutoConnect credentialsAUTOCONNECT_PAGETITLE_CREDENTIALS
AutoConnect disconnectedAUTOCONNECT_PAGETITLE_DISCONNECTED
AutoConnect resettingAUTOCONNECT_PAGETITLE_RESETTING
AutoConnect statisticsAUTOCONNECT_PAGETITLE_STATISTICS
Page:[statistics] rowEstablished connectionAUTOCONNECT_PAGESTATS_ESTABLISHEDCONNECTION
ModeAUTOCONNECT_PAGESTATS_MODE
IPAUTOCONNECT_PAGESTATS_IP
GWAUTOCONNECT_PAGESTATS_GATEWAY
Subnet maskAUTOCONNECT_PAGESTATS_SUBNETMASK
SoftAP IPAUTOCONNECT_PAGESTATS_SOFTAPIP
AP MACAUTOCONNECT_PAGESTATS_APMAC
STA MACAUTOCONNECT_PAGESTATS_STAMAC
ChannelAUTOCONNECT_PAGESTATS_CHANNEL
dBmAUTOCONNECT_PAGESTATS_DBM
Chip IDAUTOCONNECT_PAGESTATS_CHIPID
CPU Freq.AUTOCONNECT_PAGESTATS_CPUFREQ
Flash sizeAUTOCONNECT_PAGESTATS_FLASHSIZE
Free memoryAUTOCONNECT_PAGESTATS_FREEMEM
Page:[config] textTotal:AUTOCONNECT_PAGECONFIG_TOTAL
Hidden:AUTOCONNECT_PAGECONFIG_HIDDEN
SSIDAUTOCONNECT_PAGECONFIG_SSID
PassphraseAUTOCONNECT_PAGECONFIG_PASSPHRASE
Enable DHCPAUTOCONNECT_PAGECONFIG_ENABLEDHCP
ApplyAUTOCONNECT_PAGECONFIG_APPLY
Page:[update] textUpdating firmwareAUTOCONNECT_TEXT_UPDATINGFIRMWARE
Select firmware:AUTOCONNECT_TEXT_SELECTFIRMWARE
Successfully updated, rebooting...AUTOCONNECT_TEXT_OTASUCCESS
Failed to update:AUTOCONNECT_TEXT_OTAFAILURE
Page:[connection failed]Connection FailedAUTOCONNECT_PAGECONNECTIONFAILED_CONNECTIONFAILED
TextNo saved credentials.AUTOCONNECT_TEXT_NOSAVEDCREDENTIALS
Menu TextConnectingAUTOCONNECT_MENUTEXT_CONNECTING
DisconnectAUTOCONNECT_MENUTEXT_DISCONNECT
FailedAUTOCONNECT_MENUTEXT_FAILED

The definition of label text must conform to a certain coding pattern. Undefine with #undef the #define directive corresponding to the above IDs, and then redefine the ID with the replacement text. And surround it with #ifdef ~ #endif.

#ifdef AUTOCONNECT_MENULABEL_CONFIGNEW
#undef AUTOCONNECT_MENULABEL_CONFIGNEW
#define AUTOCONNECT_MENULABEL_CONFIGNEW   "NEW_STRING_YOU_WISH"
#endif

You may not need to rewrite all definitions. It depends on your wishes and is sufficient that the above the include file contains only the labels you need.

Configuration of platformio.ini

You prepare its header file and place it in the src folder of the project folder. You can name the file whatever you like, but for the sake of explanation, let's say mylabels.h.

When you store mylabels.h containing the new label text definition in the src folder, your Arduino project folder structure should look like this:

<Project folder>
|-- <pio>
|-- <.vscode>
|-- <include>
|-- <lib>
|-- <src>
|   |-- main.cpp
|   |-- mylabels.h  <-- Depends on the project
|-- <test>
|-- .gitignore
|-- .travis.yml
|-- platformio.ini

Then, open platformio.ini file and add new build_flags for including mylabels.h to override the label text.

build_flags = -DAC_LABELS='"${PROJECT_SRC_DIR}/mylabels.h"'

!!! hint "Just change the mylabels.h" Keep -DAC_LABELS='"${PROJECT_SRC_DIR}/YOUR_FILE_NAME"' when changing the above build_flags item to match your labels header file name.

After placing the mylabels.h file and add the build_flags, build the project with the replaced label text. You will see the AutoConnect screen with the new text replaced by mylabels.h.

!!! caution "Need clean-up before re-build with updated mylabels.h" When you have updated mylabels.h, you need deleting compiled library object files before build. Use Clean of a PlatformIO task on VSCode status bar.