Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
c02386ffcThis file is pinned to the selected release. Download the original to open it in your design tool.
/**
* @file ui.c
* @brief User Interface source for MetalDetector project generated by SquareLine Studio.
*
* This file contains the implementation of the user interface.
* It initializes the UI components and sets up the necessary callbacks and themes.
* Functions include initialization of tabs, setting up the theme, and loading the main screen.
*
* Created on: Jul 30, 2024
* Author: Viktor
*/
#include "ui.h"
#include "ui_callbacks.h"
lv_obj_t * ui_Main; /**< Main screen object */
lv_obj_t * ui_Tab; /**< Tab view object */
lv_obj_t * ui_MainTab_; /**< Main tab object */
lv_obj_t * ui_PhaseMainPanel; /**< Phase main panel object */
lv_obj_t * ui_PhaseArc; /**< Phase arc object */
lv_obj_t * ui_PhaseDecorSircle; /**< Phase decoration circle object */
lv_obj_t * ui_PhaseLabel; /**< Phase label object */
lv_obj_t * ui_DepthPanel; /**< Depth panel object */
lv_obj_t * ui_DepthBar; /**< Depth bar object */
lv_obj_t * ui_DepthLabel; /**< Depth label object */
lv_obj_t * ui_SettingsTab_; /**< Settings tab object */
lv_obj_t * ui_GndBalancePanel; /**< Ground balance panel object */
lv_obj_t * ui_GndBalanceConf; /**< Ground balance configuration slider object */
lv_obj_t * ui_GndBalanceLabel; /**< Ground balance label object */
lv_obj_t * ui_GndBalanceButton; /**< Ground balance button object */
lv_obj_t * ui_GndBalanceBtnLabel; /**< Ground balance button label object */
lv_obj_t * ui_GndBalanceVal; /**< Ground balance value label object */
lv_obj_t * ui_SensPanel; /**< Sensitivity panel object */
lv_obj_t * ui_SensConf_; /**< Sensitivity configuration slider object */
lv_obj_t * ui_SensLabel; /**< Sensitivity label object */
lv_obj_t * ui_SenseVal; /**< Sensitivity value label object */
lv_obj_t * ui_ChartDomainDropdown; /**< Chart domain dropdown object */
lv_obj_t * ui_ChartTab_; /**< Chart tab object */
lv_obj_t * ui_Chart; /**< Chart object */
lv_obj_t * ui_Chart_Xaxis; /**< Chart X-axis scale object */
lv_obj_t * ui_Chart_Yaxis1; /**< Chart Y-axis 1 scale object */
lv_obj_t * ui_Chart_Yaxis2; /**< Chart Y-axis 2 scale object */
lv_chart_series_t * ui_Chart_series_1; /**< Chart series 1 object */
lv_chart_series_t * ui_Chart_series_2; /**< Chart series 2 object */
lv_obj_t * ui____initial_actions0; /**< Initial actions object */
UI_ChartDomains_t ui_chart_domain = CHART_TIME_DOMAIN;
static void tab_init(void);
static void tab_main_init(void);
static void tab_settings_init(void);
static void tab_chart_init(void);
static void tab_callbacks_init(void);
/**
* @brief Initializes the user interface components.
*
* This function sets up the default theme for the display, initializes all tabs,
* sets up callbacks, and loads the main screen. It configures the display theme
* using predefined color palettes and font settings.
*/
void ui_init(void)
{
/* Get the default display and set the theme */
lv_disp_t * dispp = lv_display_get_default();
lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE),
lv_palette_main(LV_PALETTE_RED),
false, LV_FONT_DEFAULT);
lv_disp_set_theme(dispp, theme);
/* Initialize tabs and callbacks */
tab_init();
tab_callbacks_init();
/* Create an initial UI object and load the main screen */
ui____initial_actions0 = lv_obj_create(NULL);
lv_disp_load_scr(ui_Main);
}
/**
* @brief Initializes the tabs for the user interface.
*
* This function creates the main screen object and a tab view. It configures the
* tab view by setting its size, alignment, and background color. It also removes
* certain flags to control its behavior, such as scrollable and gesture bubble.
* Additionally, it initializes each specific tab (main, settings, chart).
*/
static void tab_init(void)
{
/* Create the main screen and configure its properties */
ui_Main = lv_obj_create(NULL);
lv_obj_remove_flag(ui_Main, LV_OBJ_FLAG_SCROLLABLE);
/* Create a tab view on the main screen and configure its properties */
ui_Tab = lv_tabview_create(ui_Main);
lv_tabview_set_tab_bar_size(ui_Tab, 25);
lv_obj_set_width(ui_Tab, 320);
lv_obj_set_height(ui_Tab, 240);
lv_obj_set_align(ui_Tab, LV_ALIGN_CENTER);
lv_obj_remove_flag(ui_Tab, LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE |
LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN);
lv_obj_set_style_bg_color(ui_Tab, lv_color_hex(0x89C1F5), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_Tab, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Initialize all specific tabs */
tab_main_init();
tab_settings_init();
tab_chart_init();
}
/**
* @brief Initializes the "Main" tab of the user interface.
*
* This function creates and configures the "Main" tab, including its layout and child objects.
* It sets up various UI elements such as panels, arcs, labels, and bars with specific styles
* and properties. The main components include:
* - A phase main panel with a centered arc and decorative circle.
* - A depth panel with a vertical bar and a label.
*/
static void tab_main_init(void)
{
/* Create the "Main" tab and configure its properties */
ui_MainTab_ = lv_tabview_add_tab(ui_Tab, "Main");
lv_obj_remove_flag(ui_MainTab_, LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE |
LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN);
lv_obj_set_scrollbar_mode(ui_MainTab_, LV_SCROLLBAR_MODE_OFF);
/* Create and configure the phase main panel */
ui_PhaseMainPanel = lv_obj_create(ui_MainTab_);
lv_obj_set_width(ui_PhaseMainPanel, 226);
lv_obj_set_height(ui_PhaseMainPanel, 173);
lv_obj_set_x(ui_PhaseMainPanel, -44);
lv_obj_set_y(ui_PhaseMainPanel, 1);
lv_obj_set_align(ui_PhaseMainPanel, LV_ALIGN_CENTER);
lv_obj_remove_flag(ui_PhaseMainPanel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_radius(ui_PhaseMainPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_PhaseMainPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_PhaseMainPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_PhaseMainPanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui_PhaseMainPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create and configure the phase arc */
ui_PhaseArc = lv_arc_create(ui_PhaseMainPanel);
lv_obj_set_width(ui_PhaseArc, 150);
lv_obj_set_height(ui_PhaseArc, 150);
lv_obj_set_x(ui_PhaseArc, -7);
lv_obj_set_y(ui_PhaseArc, 3);
lv_obj_set_align(ui_PhaseArc, LV_ALIGN_CENTER);
lv_arc_set_range(ui_PhaseArc, 0, 180);
lv_arc_set_value(ui_PhaseArc, -1);
lv_obj_set_style_arc_width(ui_PhaseArc, 30, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_rounded(ui_PhaseArc, false, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_color(ui_PhaseArc, lv_color_hex(0xFFA740), LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_opa(ui_PhaseArc, 255, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_width(ui_PhaseArc, 30, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_rounded(ui_PhaseArc, false, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_PhaseArc, lv_color_hex(0xFFFFFF), LV_PART_KNOB | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_PhaseArc, 0, LV_PART_KNOB | LV_STATE_DEFAULT);
/* Create and configure the phase decorative circle */
ui_PhaseDecorSircle = lv_obj_create(ui_PhaseMainPanel);
lv_obj_set_width(ui_PhaseDecorSircle, 120);
lv_obj_set_height(ui_PhaseDecorSircle, 120);
lv_obj_set_x(ui_PhaseDecorSircle, -6);
lv_obj_set_y(ui_PhaseDecorSircle, 3);
lv_obj_set_align(ui_PhaseDecorSircle, LV_ALIGN_CENTER);
lv_obj_remove_flag(ui_PhaseDecorSircle, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_radius(ui_PhaseDecorSircle, 90, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_PhaseDecorSircle, lv_color_hex(0x1D8784), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_PhaseDecorSircle, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_PhaseDecorSircle, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui_PhaseDecorSircle, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui_PhaseDecorSircle, 12, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_spread(ui_PhaseDecorSircle, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create and configure the phase label */
ui_PhaseLabel = lv_label_create(ui_PhaseDecorSircle);
lv_obj_set_width(ui_PhaseLabel, LV_SIZE_CONTENT);
lv_obj_set_height(ui_PhaseLabel, LV_SIZE_CONTENT);
lv_obj_set_align(ui_PhaseLabel, LV_ALIGN_CENTER);
lv_label_set_text(ui_PhaseLabel, "000");
lv_obj_set_style_text_color(ui_PhaseLabel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_PhaseLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_PhaseLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create and configure the depth panel */
ui_DepthPanel = lv_obj_create(ui_MainTab_);
lv_obj_set_width(ui_DepthPanel, 87);
lv_obj_set_height(ui_DepthPanel, 193);
lv_obj_set_x(ui_DepthPanel, 100);
lv_obj_set_y(ui_DepthPanel, 2);
lv_obj_set_align(ui_DepthPanel, LV_ALIGN_CENTER);
lv_obj_remove_flag(ui_DepthPanel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_radius(ui_DepthPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_DepthPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_DepthPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_DepthPanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui_DepthPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create and configure the depth bar */
ui_DepthBar = lv_bar_create(ui_DepthPanel);
lv_bar_set_range(ui_DepthBar, 0, 516);
lv_obj_set_width(ui_DepthBar, 15);
lv_obj_set_height(ui_DepthBar, 162);
lv_obj_set_x(ui_DepthBar, -1);
lv_obj_set_y(ui_DepthBar, -10);
lv_obj_set_align(ui_DepthBar, LV_ALIGN_RIGHT_MID);
lv_obj_set_style_bg_color(ui_DepthBar, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_DepthBar, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_DepthBar, lv_color_hex(0xE0FF00), LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_DepthBar, 255, LV_PART_INDICATOR | LV_STATE_DEFAULT);
/* Adjust padding of the depth bar if necessary */
if(lv_obj_get_style_pad_top(ui_DepthBar, LV_PART_MAIN) > 0)
{
lv_obj_set_style_pad_right(ui_DepthBar, lv_obj_get_style_pad_right(ui_DepthBar, LV_PART_MAIN) + 1, LV_PART_MAIN);
}
/* Create and configure the depth label */
ui_DepthLabel = lv_label_create(ui_DepthPanel);
lv_obj_set_width(ui_DepthLabel, LV_SIZE_CONTENT);
lv_obj_set_height(ui_DepthLabel, LV_SIZE_CONTENT);
lv_obj_set_x(ui_DepthLabel, 20);
lv_obj_set_y(ui_DepthLabel, 82);
lv_obj_set_align(ui_DepthLabel, LV_ALIGN_CENTER);
lv_label_set_text(ui_DepthLabel, "000");
lv_obj_set_style_text_color(ui_DepthLabel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_DepthLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_DepthLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT);
}
/**
* @brief Initializes the "Settings" tab in the tab view widget.
*
* This function creates and configures the "Settings" tab, adds various UI elements to it,
* such as panels, sliders, labels, and buttons, and sets their styles and positions.
*/
static void tab_settings_init(void)
{
/* Add a new tab named "Settings" to the tab view widget */
ui_SettingsTab_ = lv_tabview_add_tab(ui_Tab, "Settings");
/* Remove gesture, scroll, and snap effects from the "Settings" tab */
lv_obj_remove_flag(ui_SettingsTab_, LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE |
LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN);
/* Disable scrollbar for the "Settings" tab */
lv_obj_set_scrollbar_mode(ui_SettingsTab_, LV_SCROLLBAR_MODE_OFF);
/* Create a panel for GND balance settings within the "Settings" tab */
ui_GndBalancePanel = lv_obj_create(ui_SettingsTab_);
lv_obj_set_width(ui_GndBalancePanel, 304);
lv_obj_set_height(ui_GndBalancePanel, 50);
lv_obj_set_x(ui_GndBalancePanel, 0);
lv_obj_set_y(ui_GndBalancePanel, -54);
lv_obj_set_align(ui_GndBalancePanel, LV_ALIGN_CENTER);
/* Remove scrolling capability from the GND balance panel */
lv_obj_remove_flag(ui_GndBalancePanel, LV_OBJ_FLAG_SCROLLABLE);
/* Set the style for the GND balance panel */
lv_obj_set_style_radius(ui_GndBalancePanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_GndBalancePanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_GndBalancePanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_GndBalancePanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui_GndBalancePanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create a slider for adjusting GND balance within the GND balance panel */
ui_GndBalanceConf = lv_slider_create(ui_GndBalancePanel);
lv_slider_set_range(ui_GndBalanceConf, 0, 50);
lv_slider_set_value(ui_GndBalanceConf, 0, LV_ANIM_OFF);
if(lv_slider_get_mode(ui_GndBalanceConf) == LV_SLIDER_MODE_RANGE)
{
lv_slider_set_left_value(ui_GndBalanceConf, 0, LV_ANIM_OFF);
}
/* Set dimensions, position, and alignment for the GND balance slider */
lv_obj_set_width(ui_GndBalanceConf, 150);
lv_obj_set_height(ui_GndBalanceConf, 10);
lv_obj_set_x(ui_GndBalanceConf, -66);
lv_obj_set_y(ui_GndBalanceConf, 7);
lv_obj_set_align(ui_GndBalanceConf, LV_ALIGN_CENTER);
/* Adjust padding of the GND balance slider if necessary */
if(lv_obj_get_style_pad_top(ui_GndBalanceConf, LV_PART_MAIN) > 0)
{
lv_obj_set_style_pad_right(ui_GndBalanceConf, lv_obj_get_style_pad_right(ui_GndBalanceConf, LV_PART_MAIN) + 1, LV_PART_MAIN);
}
/* Create and configure a label for the GND balance slider */
ui_GndBalanceLabel = lv_label_create(ui_GndBalancePanel);
lv_obj_set_width(ui_GndBalanceLabel, LV_SIZE_CONTENT);
lv_obj_set_height(ui_GndBalanceLabel, LV_SIZE_CONTENT);
lv_obj_set_x(ui_GndBalanceLabel, -68);
lv_obj_set_y(ui_GndBalanceLabel, -13);
lv_obj_set_align(ui_GndBalanceLabel, LV_ALIGN_CENTER);
lv_label_set_text(ui_GndBalanceLabel, "GND Balance");
lv_obj_set_style_text_color(ui_GndBalanceLabel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_GndBalanceLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create and configure a button for setting the GND balance */
ui_GndBalanceButton = lv_button_create(ui_GndBalancePanel);
lv_obj_set_width(ui_GndBalanceButton, 62);
lv_obj_set_height(ui_GndBalanceButton, 23);
lv_obj_set_x(ui_GndBalanceButton, 96);
lv_obj_set_y(ui_GndBalanceButton, 6);
lv_obj_set_align(ui_GndBalanceButton, LV_ALIGN_CENTER);
lv_obj_add_flag(ui_GndBalanceButton, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_remove_flag(ui_GndBalanceButton, LV_OBJ_FLAG_SCROLLABLE);
/* Create and configure a label for the GND balance button */
ui_GndBalanceBtnLabel = lv_label_create(ui_GndBalanceButton);
lv_obj_set_width(ui_GndBalanceBtnLabel, LV_SIZE_CONTENT);
lv_obj_set_height(ui_GndBalanceBtnLabel, LV_SIZE_CONTENT);
lv_obj_set_x(ui_GndBalanceBtnLabel, 1);
lv_obj_set_y(ui_GndBalanceBtnLabel, 1);
lv_obj_set_align(ui_GndBalanceBtnLabel, LV_ALIGN_CENTER);
lv_label_set_text(ui_GndBalanceBtnLabel, "Set");
/* Create and configure a label to display the GND balance value */
ui_GndBalanceVal = lv_label_create(ui_GndBalancePanel);
lv_obj_set_width(ui_GndBalanceVal, LV_SIZE_CONTENT);
lv_obj_set_height(ui_GndBalanceVal, LV_SIZE_CONTENT);
lv_obj_set_x(ui_GndBalanceVal, 30);
lv_obj_set_y(ui_GndBalanceVal, 7);
lv_obj_set_align(ui_GndBalanceVal, LV_ALIGN_CENTER);
lv_label_set_text(ui_GndBalanceVal, "0");
lv_obj_set_style_text_color(ui_GndBalanceVal, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_GndBalanceVal, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create a panel for sensitivity settings within the "Settings" tab */
ui_SensPanel = lv_obj_create(ui_SettingsTab_);
lv_obj_set_width(ui_SensPanel, 307);
lv_obj_set_height(ui_SensPanel, 50);
lv_obj_set_align(ui_SensPanel, LV_ALIGN_CENTER);
/* Remove scrolling capability from the sensitivity panel */
lv_obj_remove_flag(ui_SensPanel, LV_OBJ_FLAG_SCROLLABLE);
/* Set the style for the sensitivity panel */
lv_obj_set_style_radius(ui_SensPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_SensPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_SensPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_SensPanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui_SensPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create a slider for adjusting sensitivity within the sensitivity panel */
ui_SensConf_ = lv_slider_create(ui_SensPanel);
lv_slider_set_range(ui_SensConf_, 0, 20);
lv_slider_set_value(ui_SensConf_, 0, LV_ANIM_OFF);
if(lv_slider_get_mode(ui_SensConf_) == LV_SLIDER_MODE_RANGE)
{
lv_slider_set_left_value(ui_SensConf_, 0, LV_ANIM_OFF);
}
/* Set dimensions, position, and alignment for the sensitivity slider */
lv_obj_set_width(ui_SensConf_, 150);
lv_obj_set_height(ui_SensConf_, 10);
lv_obj_set_x(ui_SensConf_, -66);
lv_obj_set_y(ui_SensConf_, 7);
lv_obj_set_align(ui_SensConf_, LV_ALIGN_CENTER);
/* Adjust padding of the sensitivity slider if necessary */
if(lv_obj_get_style_pad_top(ui_SensConf_, LV_PART_MAIN) > 0)
{
lv_obj_set_style_pad_right(ui_SensConf_, lv_obj_get_style_pad_right(ui_SensConf_, LV_PART_MAIN) + 1, LV_PART_MAIN);
}
/* Create and configure a label for the sensitivity slider */
ui_SensLabel = lv_label_create(ui_SensPanel);
lv_obj_set_width(ui_SensLabel, LV_SIZE_CONTENT);
lv_obj_set_height(ui_SensLabel, LV_SIZE_CONTENT);
lv_obj_set_x(ui_SensLabel, -68);
lv_obj_set_y(ui_SensLabel, -13);
lv_obj_set_align(ui_SensLabel, LV_ALIGN_CENTER);
lv_label_set_text(ui_SensLabel, "Sensitivity");
lv_obj_set_style_text_color(ui_SensLabel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_SensLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create and configure a label to display the sensitivity value */
ui_SenseVal = lv_label_create(ui_SensPanel);
lv_obj_set_width(ui_SenseVal, LV_SIZE_CONTENT);
lv_obj_set_height(ui_SenseVal, LV_SIZE_CONTENT);
lv_obj_set_x(ui_SenseVal, 30);
lv_obj_set_y(ui_SenseVal, 7);
lv_obj_set_align(ui_SenseVal, LV_ALIGN_CENTER);
lv_label_set_text(ui_SenseVal, "0");
lv_obj_set_style_text_color(ui_SenseVal, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_SenseVal, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
/* Create a dropdown menu for selecting chart domain within the "Settings" tab */
ui_ChartDomainDropdown = lv_dropdown_create(ui_SettingsTab_);
lv_dropdown_set_options(ui_ChartDomainDropdown, "Chart Time Domain\nChart Frequency Domain");
lv_obj_set_width(ui_ChartDomainDropdown, 238);
lv_obj_set_height(ui_ChartDomainDropdown, LV_SIZE_CONTENT);
lv_obj_set_x(ui_ChartDomainDropdown, -32);
lv_obj_set_y(ui_ChartDomainDropdown, 57);
lv_obj_set_align(ui_ChartDomainDropdown, LV_ALIGN_CENTER);
lv_obj_add_flag(ui_ChartDomainDropdown, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
}
/**
* @brief Initializes the "Chart" tab in the tab view widget.
*
* This function creates and configures the "Chart" tab, sets up a chart with multiple axes and series,
* and applies specific styles to the chart and its components.
*/
static void tab_chart_init(void)
{
/* Add a new tab named "Chart" to the tab view widget */
ui_ChartTab_ = lv_tabview_add_tab(ui_Tab, "Chart");
/* Remove various flags from the "Chart" tab to disable gesture, scrolling, and snapping effects */
lv_obj_remove_flag(ui_ChartTab_, LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE |
LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN);
/* Disable the scrollbar for the "Chart" tab */
lv_obj_set_scrollbar_mode(ui_ChartTab_, LV_SCROLLBAR_MODE_OFF);
/* Create a chart object within the "Chart" tab */
ui_Chart = lv_chart_create(ui_ChartTab_);
lv_obj_set_width(ui_Chart, 300);
lv_obj_set_height(ui_Chart, 200);
lv_obj_set_x(ui_Chart, -2);
lv_obj_set_y(ui_Chart, -1);
lv_obj_set_align(ui_Chart, LV_ALIGN_CENTER);
/* Enable overflow visibility for the chart and disable scrolling */
lv_obj_add_flag(ui_Chart, LV_OBJ_FLAG_OVERFLOW_VISIBLE);
lv_obj_remove_flag(ui_Chart, LV_OBJ_FLAG_SCROLLABLE);
/* Set the chart type to line and configure its range and point count */
lv_chart_set_type(ui_Chart, LV_CHART_TYPE_LINE);
lv_chart_set_point_count(ui_Chart, TIME_DOMAIN_CHART_LEN);
lv_chart_set_range(ui_Chart, LV_CHART_AXIS_PRIMARY_Y, 0, TIME_DOMAIN_MAX_VALUE);
/* Create and configure the X-axis scale of the chart */
ui_Chart_Xaxis = lv_scale_create(ui_Chart);
lv_scale_set_mode(ui_Chart_Xaxis, LV_SCALE_MODE_HORIZONTAL_BOTTOM);
lv_obj_set_size(ui_Chart_Xaxis, lv_pct(100), 50);
lv_obj_set_align(ui_Chart_Xaxis, LV_ALIGN_BOTTOM_MID);
lv_obj_set_y(ui_Chart_Xaxis, 50 + lv_obj_get_style_pad_bottom(ui_Chart, LV_PART_MAIN) + lv_obj_get_style_border_width(ui_Chart, LV_PART_MAIN));
lv_obj_set_style_line_width(ui_Chart_Xaxis, 0, LV_PART_MAIN);
lv_obj_set_style_line_width(ui_Chart_Xaxis, 1, LV_PART_ITEMS);
lv_obj_set_style_line_width(ui_Chart_Xaxis, 1, LV_PART_INDICATOR);
lv_scale_set_label_show(ui_Chart_Xaxis, false);
/* Create and configure the first Y-axis scale of the chart */
ui_Chart_Yaxis1 = lv_scale_create(ui_Chart);
lv_scale_set_mode(ui_Chart_Yaxis1, LV_SCALE_MODE_VERTICAL_LEFT);
lv_obj_set_size(ui_Chart_Yaxis1, 50, lv_pct(100));
lv_obj_set_align(ui_Chart_Yaxis1, LV_ALIGN_LEFT_MID);
lv_obj_set_x(ui_Chart_Yaxis1, -50 - lv_obj_get_style_pad_left(ui_Chart, LV_PART_MAIN) - lv_obj_get_style_border_width(ui_Chart, LV_PART_MAIN) + 2);
lv_obj_set_style_line_width(ui_Chart_Yaxis1, 0, LV_PART_MAIN);
lv_obj_set_style_line_width(ui_Chart_Yaxis1, 1, LV_PART_ITEMS);
lv_obj_set_style_line_width(ui_Chart_Yaxis1, 1, LV_PART_INDICATOR);
lv_obj_set_style_length(ui_Chart_Yaxis1, 0, LV_PART_ITEMS);
lv_obj_set_style_length(ui_Chart_Yaxis1, 0, LV_PART_INDICATOR);
lv_scale_set_total_tick_count(ui_Chart_Yaxis1, (5 > 0 ? 5 - 1 : 0) * 2 + 1);
lv_scale_set_major_tick_every(ui_Chart_Yaxis1, 2 >= 1 ? 2 : 1);
lv_scale_set_label_show(ui_Chart_Yaxis1, false);
/* Create and configure the second Y-axis scale of the chart */
ui_Chart_Yaxis2 = lv_scale_create(ui_Chart);
lv_scale_set_mode(ui_Chart_Yaxis2, LV_SCALE_MODE_VERTICAL_RIGHT);
lv_obj_set_size(ui_Chart_Yaxis2, 25, lv_pct(100));
lv_obj_set_align(ui_Chart_Yaxis2, LV_ALIGN_RIGHT_MID);
lv_obj_set_x(ui_Chart_Yaxis2, 25 + lv_obj_get_style_pad_right(ui_Chart, LV_PART_MAIN) + lv_obj_get_style_border_width(ui_Chart, LV_PART_MAIN) + 1);
lv_obj_set_style_line_width(ui_Chart_Yaxis2, 0, LV_PART_MAIN);
lv_obj_set_style_line_width(ui_Chart_Yaxis2, 1, LV_PART_ITEMS);
lv_obj_set_style_line_width(ui_Chart_Yaxis2, 1, LV_PART_INDICATOR);
lv_obj_set_style_length(ui_Chart_Yaxis2, 0, LV_PART_ITEMS);
lv_obj_set_style_length(ui_Chart_Yaxis2, 0, LV_PART_INDICATOR);
lv_scale_set_range(ui_Chart_Yaxis2, 0, 0);
lv_scale_set_total_tick_count(ui_Chart_Yaxis2, (0 > 0 ? 0 - 1 : 0) * 0 + 1);
lv_scale_set_major_tick_every(ui_Chart_Yaxis2, 0 >= 1 ? 0 : 1);
lv_scale_set_label_show(ui_Chart_Yaxis2, false);
/* Add two series to the chart and initialize them with empty data arrays */
ui_Chart_series_1 = lv_chart_add_series(ui_Chart, lv_color_hex(0x00FA1B), LV_CHART_AXIS_PRIMARY_Y);
ui_Chart_series_2 = lv_chart_add_series(ui_Chart, lv_color_hex(0xff2400), LV_CHART_AXIS_PRIMARY_Y);
static lv_coord_t ui_Chart_series_1_array[FREQ_DOMAIN_CHART_LEN] = { 0 };
static lv_coord_t ui_Chart_series_2_array[FREQ_DOMAIN_CHART_LEN] = { 0 };
lv_chart_set_ext_y_array(ui_Chart, ui_Chart_series_1, ui_Chart_series_1_array);
lv_chart_set_ext_y_array(ui_Chart, ui_Chart_series_2, ui_Chart_series_2_array);
/* Apply styles to the chart, including background color and outline properties */
lv_obj_set_style_bg_color(ui_Chart, lv_color_hex(0xFFFFFF), LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_Chart, 0, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_outline_pad(ui_Chart, LV_MAX3(50, 50, 25), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_outline_width(ui_Chart, -1, LV_PART_MAIN | LV_STATE_DEFAULT);
}
/**
* @brief Initializes event callbacks for UI components in the tab view.
*
* This function sets up event callbacks for various UI elements to handle user interactions and changes.
* The callbacks are triggered by specific events such as value changes and button clicks.
*/
static void tab_callbacks_init(void)
{
/* Add event callback for changes in the arc phase */
lv_obj_add_event_cb(ui_PhaseArc, arc_phase_changed_cb, LV_EVENT_VALUE_CHANGED, NULL);
/* Add event callback for changes in the depth bar */
lv_obj_add_event_cb(ui_DepthBar, depth_changed_cb, LV_EVENT_VALUE_CHANGED, NULL);
/* Add event callback for changes in the ground balance configuration */
lv_obj_add_event_cb(ui_GndBalanceConf, gnd_balance_changed_cb, LV_EVENT_VALUE_CHANGED, NULL);
/* Add event callback for clicking the ground balance set button */
lv_obj_add_event_cb(ui_GndBalanceButton, gnd_balance_set_cb, LV_EVENT_CLICKED, NULL);
/* Add event callback for changes in the sensitivity configuration */
lv_obj_add_event_cb(ui_SensConf_, sens_changed_cb, LV_EVENT_VALUE_CHANGED, NULL);
/* Add event callback for changes in the chart domain dropdown */
lv_obj_add_event_cb(ui_ChartDomainDropdown, chart_domain_changed_cb, LV_EVENT_VALUE_CHANGED, NULL);
}