From d0490e4585dd64b599ed2dde964abf2c80e4b932 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 7 Feb 2026 10:04:57 +0100 Subject: [PATCH] Update example to use WUPSConfigItemIPAddress --- plugins/example_plugin_cpp/src/main.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/example_plugin_cpp/src/main.cpp b/plugins/example_plugin_cpp/src/main.cpp index c9ec083..2016048 100644 --- a/plugins/example_plugin_cpp/src/main.cpp +++ b/plugins/example_plugin_cpp/src/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ WUPS_PLUGIN_LICENSE("BSD"); #define OTHER_EXAMPLE2_BOOL_CONFIG_ID "other2BoolItem" #define INTEGER_RANGE_EXAMPLE_CONFIG_ID "intRangeExample" #define MULTIPLE_VALUES_EXAMPLE_CONFIG_ID "multValueExample" +#define IP_ADDRESS_CONFIG_ID "ipAddressExample" /** All of this defines can be used in ANY file. @@ -50,10 +52,12 @@ enum ExampleOptions { #define LOF_FS_OPEN_DEFAULT_VALUE true #define INTEGER_RANGE_DEFAULT_VALUE 10 #define MULTIPLE_VALUES_DEFAULT_VALUE EXAMPLE_OPTION_2 +#define IP_ADDRESS_DEFAULT_VALUE 0x2a2a2a2a bool sLogFSOpen = LOF_FS_OPEN_DEFAULT_VALUE; int sIntegerRangeValue = INTEGER_RANGE_DEFAULT_VALUE; ExampleOptions sExampleOptionValue = MULTIPLE_VALUES_DEFAULT_VALUE; +uint32_t sIPAddress = IP_ADDRESS_DEFAULT_VALUE; static std::forward_list sButtonComboInstances; @@ -103,6 +107,13 @@ void buttonComboItemChanged(ConfigItemButtonCombo *item, uint32_t newValue) { DEBUG_FUNCTION_LINE_INFO("New value in buttonComboItemChanged: %d for %s", newValue, item->identifier); } +void ipAddressItemChangedConfig(ConfigItemIPAddress *item, uint32_t newValue) { + if (std::string_view(IP_ADDRESS_CONFIG_ID) == item->identifier) { + sIPAddress = newValue; + } + DEBUG_FUNCTION_LINE_INFO("New value in ipAddressItemChangedConfig: %d for %s", newValue, item->identifier); +} + WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) { // To use the C++ API, we create new WUPSConfigCategory from the root handle! WUPSConfigCategory root = WUPSConfigCategory(rootHandle); @@ -160,6 +171,13 @@ WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle ro possibleValues, nullptr)); + + root.add(WUPSConfigItemIPAddress::Create(IP_ADDRESS_CONFIG_ID, + "IP address example", + IP_ADDRESS_DEFAULT_VALUE, + sIPAddress, + &ipAddressItemChangedConfig)); + // It's also possible to have nested categories auto nc1 = WUPSConfigCategory::Create("Category inside root"); auto nc2 = WUPSConfigCategory::Create("Category inside subcategory 1");