I was trying to update the chart values dynamically. I was able to update the value using slider as an input to the graph.
I was thinking if there is a way to remove slider out of the picture and update the chart directly using mouse as an input?
I am attaching code snippet I tried for your reference.
static void event_handler(lv_obj_t* obj, lv_event_t event){
if(event == LV_EVENT_VALUE_CHANGED)
{
#if DEBUG
printf("Value: %d\n", lv_spinbox_get_value(obj));
#endif
arr[0] = lv_spinbox_get_value(obj);
lv_chart_set_points(chart, ser1, (lv_coord_t*)arr);
lv_chart_refresh(chart);
}
}
....
/*Create a chart*/
chart = lv_chart_create(tab2, NULL);
lv_obj_set_size(chart, 200, 150);
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, 0);
lv_chart_set_type(chart, LV_CHART_TYPE_POINT | LV_CHART_TYPE_LINE); /*Show lines and points too*/
lv_chart_set_series_opa(chart, LV_OPA_70); /*Opacity of the data series*/
lv_chart_set_series_width(chart, 4);
lv_chart_set_range(chart, 0, 100);
spinbox = lv_spinbox_create(tab2, NULL);
lv_spinbox_set_digit_format(spinbox, 3, 0);
lv_spinbox_set_range(spinbox, 0, 100);
lv_spinbox_set_padding_left(spinbox, 6);
lv_spinbox_step_prev(spinbox);
lv_obj_set_width(spinbox, 100);
lv_obj_align(spinbox, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(spinbox, event_handler);
btn7 = lv_btn_create(tab2, NULL);
lv_obj_set_event_cb(btn7, event_handler);
lv_obj_align(btn7, NULL, LV_ALIGN_CENTER, 100, 20);
lv_obj_set_size(btn7, 28, 28);
lv_obj_t* label6 = lv_label_create(btn7, NULL);
lv_label_set_text(label6, "+");
btn8 = lv_btn_create(tab2, NULL);
lv_obj_set_event_cb(btn8, event_handler);
// lv_obj_align(btn8, NULL, LV_ALIGN_IN_TOP_LEFT, 60, 140);
lv_obj_align(btn8, NULL, LV_ALIGN_CENTER, -28, 20);
lv_obj_set_size(btn8, 28, 28);
lv_obj_t* label7 = lv_label_create(btn8, NULL);
lv_label_set_text(label7, "-");
/*Add two data series*/
ser1 = lv_chart_add_series(chart, LV_COLOR_RED);
lv_chart_init_points(chart, ser1, 0);
lv_chart_refresh(chart);
....