diff --git a/mkdocs.yml b/mkdocs.yml index ef38e70..878efc5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,6 +40,7 @@ nav: - 'Saved credentials access': credit.md - 'File upload handler': acupload.md - 'Custom colorized': colorized.md + - 'Change label text': changelabel.md - 'FAQ' : faq.md - 'Change log' : changelog.md - 'License' : license.md diff --git a/mkdocs/changelabel.md b/mkdocs/changelabel.md new file mode 100644 index 0000000..dc36074 --- /dev/null +++ b/mkdocs/changelabel.md @@ -0,0 +1,120 @@ +## 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](advancedusage.md#change-the-menu-labels) 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](https://platformio.org/). [PlatformIO](https://docs.platformio.org/en/latest/what-is-platformio.html#overview) 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. + +- [Microsoft Visual Studio Code](https://platformio.org/install/ide?install=vscode) +- [PlatformIO IDE](https://platformio.org/platformio-ide) (included PlatformIO core) + +!!! info "Install PlatformIO and VSCode" + Please refer to [the official documentation](https://docs.platformio.org/en/latest/ide/vscode.html#installation) 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`](https://github.com/Hieromon/AutoConnect/blob/master/src/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
Button labelRESETAUTOCONNECT_BUTTONLABEL_RESET
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:[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`. + +```cpp +#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: + +``` + +|-- +|-- <.vscode> +|-- +|-- +|-- +| |-- main.cpp +| |-- mylabels.h <-- Depends on the project +|-- +|-- .gitignore +|-- .travis.yml +|-- platformio.ini +``` + +Then, open [`platformio.ini`](https://docs.platformio.org/en/latest/projectconf.html) file and add new [`build_flags`](https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-flags) for including `mylabels.h` to override the label text. + +```ini +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. +

+

diff --git a/mkdocs/images/localize.png b/mkdocs/images/localize.png new file mode 100644 index 0000000..fadb7df Binary files /dev/null and b/mkdocs/images/localize.png differ diff --git a/mkdocs/images/vscode_clean.png b/mkdocs/images/vscode_clean.png new file mode 100644 index 0000000..0b97bc2 Binary files /dev/null and b/mkdocs/images/vscode_clean.png differ diff --git a/mkdocs/images/vscode_statusbar.png b/mkdocs/images/vscode_statusbar.png new file mode 100644 index 0000000..822a59a Binary files /dev/null and b/mkdocs/images/vscode_statusbar.png differ