void part2_ex10_real_scale_gauge(void)
{
/* ===== HARDWARE INITIALIZATION ===== */
#ifdef CYBSP_ENABLED
aic_sensors_init();
aic_tilt_init(NULL); /* Initialize Complementary Filter with defaults */
#endif
/* ===== Background ===== */
lv_obj_set_style_bg_color(lv_screen_active(),
lv_color_hex(0x1a1a2e), LV_PART_MAIN);
/* ===== Title ===== */
lv_obj_t * title = lv_label_create(lv_screen_active());
lv_label_set_text(title, "Part 2 Ex10: Scale Gauge (Pitch Angle)");
lv_obj_set_style_text_color(title, lv_color_hex(0xFFFFFF), 0);
lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 10);
/*=========================================================================
* Create Scale - Following lv_example_scale_4 pattern
*=========================================================================*/
ex10_scale = lv_scale_create(lv_screen_active());
lv_obj_set_size(ex10_scale, 200, 200);
lv_scale_set_label_show(ex10_scale, true);
lv_scale_set_mode(ex10_scale, LV_SCALE_MODE_ROUND_OUTER);
lv_obj_align(ex10_scale, LV_ALIGN_CENTER, 0, 0);
/* Range: 0-100 */
lv_scale_set_total_tick_count(ex10_scale, 21);
lv_scale_set_major_tick_every(ex10_scale, 5);
/* Tick length styling */
lv_obj_set_style_length(ex10_scale, 5, LV_PART_ITEMS); /* Minor tick */
lv_obj_set_style_length(ex10_scale, 10, LV_PART_INDICATOR); /* Major tick */
lv_scale_set_range(ex10_scale, 0, 100);
/* Custom labels for gauge */
static const char * custom_labels[] = {"0", "25", "50", "75", "100", NULL};
lv_scale_set_text_src(ex10_scale, custom_labels);
/*=========================================================================
* Indicator style (Major ticks) - Blue color
*=========================================================================*/
static lv_style_t ex10_indicator_style;
lv_style_init(&ex10_indicator_style);
/* Label style properties */
lv_style_set_text_font(&ex10_indicator_style, LV_FONT_DEFAULT);
lv_style_set_text_color(&ex10_indicator_style,
lv_palette_darken(LV_PALETTE_BLUE, 3));
/* Major tick properties */
lv_style_set_line_color(&ex10_indicator_style,
lv_palette_darken(LV_PALETTE_BLUE, 3));
lv_style_set_width(&ex10_indicator_style, 10); /* Tick length */
lv_style_set_line_width(&ex10_indicator_style, 2); /* Tick width */
lv_obj_add_style(ex10_scale, &ex10_indicator_style, LV_PART_INDICATOR);
/*=========================================================================
* Minor ticks style - Lighter blue
*=========================================================================*/
static lv_style_t ex10_minor_ticks_style;
lv_style_init(&ex10_minor_ticks_style);
lv_style_set_line_color(&ex10_minor_ticks_style,
lv_palette_lighten(LV_PALETTE_BLUE, 2));
lv_style_set_width(&ex10_minor_ticks_style, 5); /* Tick length */
lv_style_set_line_width(&ex10_minor_ticks_style, 2); /* Tick width */
lv_obj_add_style(ex10_scale, &ex10_minor_ticks_style, LV_PART_ITEMS);
/*=========================================================================
* Main arc/line style
*=========================================================================*/
static lv_style_t ex10_main_line_style;
lv_style_init(&ex10_main_line_style);
lv_style_set_arc_color(&ex10_main_line_style,
lv_palette_darken(LV_PALETTE_BLUE, 3));
lv_style_set_arc_width(&ex10_main_line_style, 3);
lv_obj_add_style(ex10_scale, &ex10_main_line_style, LV_PART_MAIN);
/*=========================================================================
* Section: High zone (75-100) - Red color
*=========================================================================*/
lv_scale_section_t * high_section = lv_scale_add_section(ex10_scale);
lv_scale_section_set_range(high_section, 75, 100);
static lv_style_t ex10_high_section_main_style;
lv_style_init(&ex10_high_section_main_style);
lv_style_set_arc_color(&ex10_high_section_main_style,
lv_palette_main(LV_PALETTE_RED));
lv_style_set_arc_width(&ex10_high_section_main_style, 3);
lv_scale_section_set_style(high_section, LV_PART_MAIN,
&ex10_high_section_main_style);
static lv_style_t ex10_high_section_indicator_style;
lv_style_init(&ex10_high_section_indicator_style);
lv_style_set_line_color(&ex10_high_section_indicator_style,
lv_palette_darken(LV_PALETTE_RED, 3));
lv_style_set_text_color(&ex10_high_section_indicator_style,
lv_palette_darken(LV_PALETTE_RED, 3));
lv_scale_section_set_style(high_section, LV_PART_INDICATOR,
&ex10_high_section_indicator_style);
static lv_style_t ex10_high_section_items_style;
lv_style_init(&ex10_high_section_items_style);
lv_style_set_line_color(&ex10_high_section_items_style,
lv_palette_main(LV_PALETTE_RED));
lv_scale_section_set_style(high_section, LV_PART_ITEMS,
&ex10_high_section_items_style);
/*=========================================================================
* Needle Line - Shows current value position
*=========================================================================*/
ex10_needle_line = lv_line_create(ex10_scale);
/* Needle style - Orange color for visibility */
static lv_style_t ex10_needle_style;
lv_style_init(&ex10_needle_style);
lv_style_set_line_width(&ex10_needle_style, 2); /* Thin needle */
lv_style_set_line_color(&ex10_needle_style,
lv_palette_main(LV_PALETTE_ORANGE));
lv_style_set_line_rounded(&ex10_needle_style, true);
lv_obj_add_style(ex10_needle_line, &ex10_needle_style, 0);
/* Set initial needle position */
lv_scale_set_line_needle_value(ex10_scale, ex10_needle_line,
ex10_needle_length, 50);
/*=========================================================================
* Value label (center of gauge)
*=========================================================================*/
ex10_value_label = lv_label_create(lv_screen_active());
lv_label_set_text(ex10_value_label, "50");
lv_obj_set_style_text_color(ex10_value_label,
lv_color_hex(0xFFFFFF), 0);
lv_obj_set_style_text_font(ex10_value_label,
&lv_font_montserrat_24, 0);
lv_obj_align(ex10_value_label, LV_ALIGN_CENTER, 0, 0);
/*=========================================================================
* Pitch angle label - shows actual degrees
*=========================================================================*/
ex10_raw_label = lv_label_create(lv_screen_active());
lv_label_set_text(ex10_raw_label, "Pitch: 0.0 deg");
lv_obj_set_style_text_color(ex10_raw_label,
lv_color_hex(0x00FF00), 0);
lv_obj_align(ex10_raw_label, LV_ALIGN_CENTER, 0, 120);
/*=========================================================================
* Description labels
*=========================================================================*/
lv_obj_t * desc = lv_label_create(lv_screen_active());
lv_label_set_text(desc, "[Part II] Complementary Filter (Accel + Gyro)\n"
"Tilt board forward/backward to move the needle");
lv_obj_set_style_text_color(desc, lv_color_hex(0xAAAAAA), 0);
lv_obj_set_style_text_align(desc, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_align(desc, LV_ALIGN_BOTTOM_MID, 0, -25);
/*=========================================================================
* Footer
*=========================================================================*/
aic_create_footer(lv_screen_active());
/*=========================================================================
* Timer for Tilt Analysis updates (100ms = 10 Hz)
*=========================================================================*/
ex10_timer = lv_timer_create(ex10_timer_cb, 100, NULL);
printf("[Part2] Ex10: Scale Gauge (Pitch Angle) "
"with Complementary Filter\r\n");
}