/* Get active tab index (0, 1, 2, 3) */
uint32_t active = lv_tabview_get_tab_active(tabview);
/* Only update active tab's chart */
switch(active) {
case 0: update_bar_chart(); break;
case 1: update_area_chart(); break;
case 2: update_scatter_chart(); break;
case 3: update_line_chart(); break;
}
/* Benefits:
* - Only 1 chart updated per timer tick instead of 4
* - ~75% reduction in CPU/GPU usage
* - Smoother animations on active tab
* - Battery saving on portable devices
*/
/* Pattern:
* 1. Read all sensors (cheap operation)
* 2. Check active tab
* 3. Update only that tab's widgets
*/
/* Scatter chart shows motion pattern over time:
*
* - Each point represents Roll/Pitch at one moment
* - Trail of 30 points shows recent history
* - Center (100,100) = board is level
* - Movement creates pattern showing tilt behavior
*
* Use cases:
* - Gesture recognition
* - Motion analysis
* - Balance training feedback
*/
/* Bar chart with 3 colored series:
*
* - Each series = one axis (X, Y, Z)
* - Each series has 1 point (current value)
* - Colors distinguish axes clearly
* - Good for comparing values at same moment
*
* Note: Use lv_chart_set_value_by_id() for bar charts
* (not set_next_value which shifts data)
*/
lv_chart_set_value_by_id(chart, series, 0, value); /* Index 0 */
lv_chart_refresh(chart); /* Force redraw */