1.. zephyr:code-sample:: lvgl-accelerometer-chart
2   :name: LVGL line chart with accelerometer data
3   :relevant-api: display_interface sensor_interface
4
5   Display acceleration data on a real-time chart using LVGL.
6
7Overview
8********
9
10A sample application that demonstrates how to use LVGL and the :ref:`sensor` to
11display acceleration data on a line chart that is updated in real time.
12
13This sample creates a line chart with three series, one for each axis of the accelerometer. An LVGL
14timer fetches the latest acceleration data from the sensor every 20 ms (default value) and updates
15the chart. The update period is configurable, see
16:ref:`lvgl_accelerometer_chart_building_and_running` below.
17
18Requirements
19************
20
21* A board with a display.
22* A sensor that provides acceleration data (:c:enumerator:`SENSOR_CHAN_ACCEL_XYZ`) and available
23  under the ``&accel0`` Devicetree alias.
24
25.. note::
26
27   A Devicetree overlay declaring an emulated BMI160 accelerometer is provided for the
28   ``native_posix*`` and ``native_sim*`` board variants, making it possible to run this sample on
29   your local machine.
30
31.. _lvgl_accelerometer_chart_building_and_running:
32
33Building and Running
34********************
35
36The maximum number of points to display for each series and the sampling rate of the
37accelerometer can be configured using the :kconfig:option:`CONFIG_SAMPLE_CHART_POINTS_PER_SERIES`
38and :kconfig:option:`CONFIG_SAMPLE_ACCEL_SAMPLING_RATE` Kconfig options, respectively.
39
40The default sampling rate is 50 Hz, and the default maximum number of points per series is 50.
41
42The demo can be built as follows (note how in this particular case the sampling rate is set to a
43custom value of 20 Hz):
44
45.. zephyr-app-commands::
46   :zephyr-app: samples/modules/lvgl/accelerometer_chart
47   :host-os: unix
48   :board: native_sim
49   :gen-args: -DCONFIG_SAMPLE_ACCEL_SAMPLING_RATE=20
50   :goals: run
51   :compact:
52