I'm designing the multilingual menu for SSD1306 and I chose the using abstract classes approach for this.
The generic screen class is an abstract class ScreenBuilder, which other screen types inherite from, such as:
- MenuBuilder
- HomescreenBuilder
- SettingScreenBuilder
- NotificationScreenBuilder
To implement multilinguality, I created a MenuItemsOnLanguage as an abstract class for labels exist in the project, and 2 classes which inherits from this and implements returning labels on the language:
- MenuItemsOnEnglish
- MenuItemsOnRussian
After all, I declare the reference with type of abstract class to be able to substitute the screen and language.
Like this:
Code: Select all
MenuItemsOnLanguage * screen_labels;
// MenuItemsOnEnglish * english;
// MenuItemsOnRussian * russian;
ScreenBuilder * current_screen = nullptr;
HomescreenBuilder * home_screen = nullptr;
MenuBuilder * main_menu_screen = nullptr;
SettingScreenBuilder * brightness = nullptr;
SettingScreenBuilder * volume = nullptr;
...
MenuBuilder * wifi_connection_timeout = nullptr;
MenuBuilder * language_select = nullptr;
SettingScreenBuilder * reset_to_defaults_screen = nullptr;
SettingScreenBuilder * about_software_screen = nullptr;
NotificationScreenBuilder * notif_to_show = nullptr;
Code: Select all
/home/espidf5/.espressif/tools/xtensa-esp32s3-elf/esp-2022r1-11.2.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/11.2.0/../../../../xtensa-esp32s3-elf/bin/ld: esp-idf/interface_manager/libinterface_manager.a(interface_organize.cpp.obj):(.literal._Z23interface_organize_initP11u8g2_struct+0x0): undefined reference to `_ZTV19MenuItemsOnLanguage'
/home/espidf5/.espressif/tools/xtensa-esp32s3-elf/esp-2022r1-11.2.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/11.2.0/../../../../xtensa-esp32s3-elf/bin/ld: esp-idf/interface_manager/libinterface_manager.a(setting_screen_builder.cpp.obj):(.literal._ZN20SettingScreenBuilderC2EP11u8g2_structNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x0): undefined reference to `_ZTV13ScreenBuilder'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/espidf5/esp32-workspace/esp32s3-voice/build/log/idf_py_stderr_output_8751 and /home/espidf5/esp32-workspace/esp32s3-voice/build/log/idf_py_stdout_output_8751