Skip to content

Instantly share code, notes, and snippets.

@stepansnigirev
Last active November 19, 2019 23:33
Show Gist options
  • Save stepansnigirev/7aaa86cbad9565da3a8239392359ef5d to your computer and use it in GitHub Desktop.
Save stepansnigirev/7aaa86cbad9565da3a8239392359ef5d to your computer and use it in GitHub Desktop.
# Load the default display driver
import imp, sys
sys.path.append('https://raw.githubusercontent.com/littlevgl/lv_binding_micropython/master/lib')
import display_driver
import utime as time
# Display a button with a label
import lvgl as lv
lv.init()
scr = lv.obj()
# Load the screen
lv.scr_load(scr)
# Create a chart
chart = lv.chart(lv.scr_act())
chart.set_size(200, 150)
chart.align(None, lv.ALIGN.CENTER, 0, 0)
chart.set_type(lv.chart.TYPE.POINT | lv.chart.TYPE.LINE) # Show lines and points too
chart.set_series_opa(lv.OPA._70) # Opacity of the data series
chart.set_series_width(4) # Line width and point radious
chart.set_range(0, 100)
# Add two data series
ser1 = chart.add_series(lv.color_make(0xFF,0,0))
ser2 = chart.add_series(lv.color_make(0,0x80,0))
# Set points on 'dl1'
points = [10, 10, 10, 10, 10, 10, 10, 30, 70, 90]
for p in points:
chart.set_next(ser1, p)
# Set points on 'dl2'
points = [90, 70, 65, 65, 65, 65, 65, 65, 65, 65]
for p in points:
chart.set_next(ser2, p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment