### Minimal Builder Setup Source: https://github.com/gyverlibs/settings/blob/main/docs/3.builder.md This snippet shows the basic structure for a builder function and its integration into the SettingsGyver setup and loop. ```cpp SettingsGyver sett; // билдер void build(sets::Builder& b) { // b.Input(...); // b.Button(...); } void setup() { // подключение к WiFi... sett.begin(); sett.onBuild(build); } void loop() { sett.tick(); } ``` -------------------------------- ### Widget Interaction Examples Source: https://github.com/gyverlibs/settings/blob/main/docs/3.builder.md Illustrates different ways to interact with widgets, including anonymous widgets, widgets linked to String or char arrays, and widgets with IDs for database interaction. ```cpp String str; char cstr[20]; void build(sets::Builder& b) { // виджет без id и начального значения // При установке с вебморды получаем значение напрямую if (b.Input("My input")) { Serial.println(b.build.value); } // виджет без id с привязанной String-строкой // при установке с вебморды значение запишется в строку b.Input("My input", &str); b.Input("My input", cstr); // для массивов известной длины, char[N] // b.Input("My input", AnyPtr(cstr, 20)); // старая версия с ручным указанием длины // виджет с id без привязанной переменной // будет работать с базой данных по указанному ключу b.Input("my_inp"_h, "My input"); // действие возвращается независимо от наличия id if (b.Button()) Serial.println("btn 1"); if (b.Button("my_btn2"_h)) Serial.println("btn 2"); } ``` -------------------------------- ### Widget ID Configuration Source: https://github.com/gyverlibs/settings/blob/main/docs/3.builder.md Demonstrates how to define widget IDs using DB_KEYS and various methods to assign them to widgets, including hash strings and GyverDB hashes. ```cpp DB_KEYS( kk, my_inp, button ); void build(sets::Builder& b) { b.Input("My input"); // без ID b.Input("my_inp"_h, "My input"); // хэш-строка b.Input(SH("my_inp"), "My input"); // хэш-строка b.Input(H(my_inp), "My input"); // хэш-строка b.Input(kk::my_inp, "My input"); // GyverDB-хэш } ``` -------------------------------- ### Separating UI and Actions Source: https://github.com/gyverlibs/settings/blob/main/docs/3.builder.md Demonstrates a pattern for separating the UI definition from the action handling logic within the builder function using a switch statement on the build ID. ```cpp void build(sets::Builder& b) { // вывод UI b.Input("my_inp"_h, "My input"); b.Button("my_btn"_h, "My button"); // обработка действий switch (b.build.id) { case "my_inp"_h: Serial.print("input: "); Serial.println(b.build.value); break; case "my_btn"_h: Serial.println("btn click"); break; } } ``` -------------------------------- ### Accessing Build Information Source: https://github.com/gyverlibs/settings/blob/main/docs/3.builder.md Shows how to check if a widget action occurred within the builder and retrieve its ID and value. ```cpp void build(sets::Builder& b) { // можно узнать, было ли действие по виджету if (b.build.isAction()) { Serial.print("Set: 0x"); Serial.print(b.build.id, HEX); Serial.print(" = "); Serial.println(b.build.value); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.