/* * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD * * SPDX-License-Identifier: MIT */ #include "workers.h" #include #include #include #include #include using namespace smooth_ui_toolkit::lvgl_cpp; using namespace setup_workers; using namespace stackchan; static std::string _tag = "Setup-Connectivity"; WifiSetupWorker::WifiSetupWorker() { _state = State::AppDownload; _last_state = State::None; _is_first_in = true; // Create default avatar auto avatar = std::make_unique(); avatar->init(lv_screen_active(), &lv_font_montserrat_24); GetStackChan().attachAvatar(std::move(avatar)); _app_config_signal_id = GetHAL().onAppConfigEvent.connect([this](AppConfigEvent event) { _last_app_config_event = event; }); GetHAL().startAppConfigServer(); } WifiSetupWorker::~WifiSetupWorker() { GetHAL().onAppConfigEvent.disconnect(_app_config_signal_id); GetStackChan().resetAvatar(); } void WifiSetupWorker::update() { cleanup_ui(); update_state(); } void WifiSetupWorker::update_state() { switch (_state) { case State::AppDownload: { if (_is_first_in) { _is_first_in = false; auto& avatar = GetStackChan().avatar(); avatar.leftEye().setVisible(false); avatar.rightEye().setVisible(false); avatar.mouth().setVisible(false); avatar.setSpeech("Scan the QR code to download the \"StackChan\" app."); auto& data = _state_app_download_data; std::string qrcode_text = "todotodotodotodotodotodotodlotodotodotodoto"; data.qrcode = std::make_unique(lv_screen_active()); data.qrcode->setSize(150); data.qrcode->setDarkColor(lv_color_white()); data.qrcode->setLightColor(lv_color_black()); data.qrcode->update(qrcode_text); data.qrcode->align(LV_ALIGN_CENTER, -60, -25); data.btn = std::make_unique