- Added MainUI class for displaying voice state, status icon, and buttons. - Introduced MainUIHandler to manage UI interactions and bridge communication. - Created SettingsUI for displaying QR code and configuration instructions. - Implemented SettingsUIHandler to manage settings and web server interactions. - Developed WebHandler for handling HTTP requests for settings configuration. - Updated AppRegistry to initialize with the new Discord app descriptor. - Enhanced InteractionHandler to support keyboard interactions across app switches. - Updated UIHandler to manage app switching and rendering of app icons. - Enabled QR code support in LVGL configuration.
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "ui/apps/iotdis/ui/main.h"
|
|
#include "ui/interaction_handler.h"
|
|
#include "ui/apps/iotdis/bridge/bridge.h"
|
|
#include "ui/apps/iotdis/settings/settings_handler.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/semphr.h"
|
|
#include "esp_err.h"
|
|
#include <memory>
|
|
|
|
/**
|
|
* @brief Main UI Handler for Discord App
|
|
*
|
|
* Manages the MainUI instance and interaction with the InteractionHandler.
|
|
* Each handler instance has its own IotDisBridge to prevent conflicts.
|
|
*/
|
|
class MainUIHandler {
|
|
public:
|
|
|
|
MainUIHandler();
|
|
~MainUIHandler();
|
|
|
|
esp_err_t init(lv_obj_t* parent, InteractionHandler* interaction_handler, SettingHandler* setting_handler);
|
|
esp_err_t deinit(void);
|
|
|
|
esp_err_t register_on_settings_button_clicked(lv_event_cb_t cb, void* user_data);
|
|
void update_config_prompt(bool is_configured);
|
|
void update_status();
|
|
|
|
private:
|
|
static void on_mute_button_clicked_static_(lv_event_t* e);
|
|
static void on_status_update_static_(StatusUpdateEventData data, void* user_data);
|
|
|
|
void on_mute_button_clicked_();
|
|
void on_status_update_(StatusUpdateEventData data);
|
|
void send_mute_command_();
|
|
void update_ui_();
|
|
|
|
std::unique_ptr<MainUI> main_ui_ = nullptr;
|
|
std::unique_ptr<IotDisBridge> bridge_ = nullptr;
|
|
SettingHandler* setting_handler_ = nullptr; // Not owned
|
|
|
|
// Voice state tracking
|
|
StatusUpdateEventData::VoiceState current_state_ = StatusUpdateEventData::VoiceState::UNKNOWN;
|
|
SemaphoreHandle_t state_mutex_ = nullptr;
|
|
|
|
// Callback for settings button
|
|
lv_event_cb_t on_settings_callback_ = nullptr;
|
|
void* settings_callback_user_data_ = nullptr;
|
|
};
|
|
|