chore(style): remove the trailing space from all source files (#3188)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2022-03-21 18:25:51 +08:00
committed by GitHub
parent 46bd054ad4
commit 4c4f954059
223 changed files with 1719 additions and 1719 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
Start animation on an event
Start animation on an event
""""""""""""""""""""""""""""
.. lv_example:: anim/lv_example_anim_1
@@ -14,4 +14,4 @@ Animation timeline
"""""""""""""""""""
.. lv_example:: anim/lv_example_anim_timeline_1
:language: c
+1 -1
View File
@@ -4,7 +4,7 @@ def anim_x_cb(label, v):
def sw_event_cb(e,label):
sw = e.get_target()
if sw.has_state(lv.STATE.CHECKED):
if sw.has_state(lv.STATE.CHECKED):
a = lv.anim_t()
a.init()
a.set_var(label)
+8 -8
View File
@@ -37,7 +37,7 @@ class LvExampleAnim_3():
self.a.set_custom_exec_cb(lambda a,val: self.anim_x_cb(self.anim_obj,val))
self.a.set_path_cb(self.anim_path_bezier3_cb)
self.refer_chart_cubic_bezier()
def page_obj_init(self,par):
self.anim_obj = lv.obj(par)
self.anim_obj.set_size(30, 30)
@@ -45,14 +45,14 @@ class LvExampleAnim_3():
self.anim_obj.clear_flag(lv.obj.FLAG.SCROLLABLE)
self.anim_obj.set_style_bg_color(lv.palette_main(lv.PALETTE.RED), lv.PART.MAIN)
self.anim_obj.set_grid_cell(lv.GRID_ALIGN.START, 0, 1,lv.GRID_ALIGN.START, 0, 1)
self.p1_label = lv.label(par)
self.p2_label = lv.label(par)
self.p1_label.set_text("p1:0")
self.p2_label.set_text("p2:0")
self.p1_label.set_grid_cell(lv.GRID_ALIGN.START, 0, 1,lv.GRID_ALIGN.START, 1, 1)
self.p2_label.set_grid_cell(lv.GRID_ALIGN.START, 0, 1,lv.GRID_ALIGN.START, 2, 1)
self.p1_slider = lv.slider(par)
self.p2_slider = lv.slider(par)
self.p1_slider.set_range(0, 1024)
@@ -63,14 +63,14 @@ class LvExampleAnim_3():
self.p2_slider.add_event_cb(self.slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
self.p1_slider.set_grid_cell(lv.GRID_ALIGN.STRETCH, 1, 1,lv.GRID_ALIGN.START, 1, 1)
self.p2_slider.set_grid_cell(lv.GRID_ALIGN.STRETCH, 1, 1,lv.GRID_ALIGN.START, 2, 1)
self.run_btn = lv.btn(par)
self.run_btn.add_event_cb(self.run_btn_event_handler, lv.EVENT.CLICKED, None)
btn_label = lv.label(self.run_btn)
btn_label.set_text(lv.SYMBOL.PLAY)
btn_label.center()
self.run_btn.set_grid_cell(lv.GRID_ALIGN.STRETCH, 2, 1,lv.GRID_ALIGN.STRETCH, 1, 2)
self.chart = lv.chart(par)
self.chart.set_style_pad_all(0, lv.PART.MAIN)
self.chart.set_style_size(0, lv.PART.INDICATOR)
@@ -80,7 +80,7 @@ class LvExampleAnim_3():
self.chart.set_range(lv.chart.AXIS.PRIMARY_X, 0, 1024)
self.chart.set_point_count(CHART_POINTS_NUM)
self.chart.set_grid_cell(lv.GRID_ALIGN.STRETCH, 0, 3,lv.GRID_ALIGN.STRETCH, 3, 1)
def refer_chart_cubic_bezier(self):
for i in range(CHART_POINTS_NUM+1):
t = i * (1024 // CHART_POINTS_NUM)
@@ -90,7 +90,7 @@ class LvExampleAnim_3():
def slider_event_cb(self,e):
slider = e.get_target()
if slider == self.p1_slider:
label = self.p1_label
self.p1 = slider.get_value()
@@ -101,7 +101,7 @@ class LvExampleAnim_3():
label.set_text("p1: {:d}".format(self.p2))
self.refer_chart_cubic_bezier()
def run_btn_event_handler(self,e):
+20 -20
View File
@@ -10,41 +10,41 @@ class LV_ExampleAnimTimeline_1(object):
self.par = lv.scr_act()
self.par.set_flex_flow(lv.FLEX_FLOW.ROW)
self.par.set_flex_align(lv.FLEX_ALIGN.SPACE_AROUND, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
self.btn_run = lv.btn(self.par)
self.btn_run.add_event_cb(self.btn_run_event_handler, lv.EVENT.VALUE_CHANGED, None)
self.btn_run.add_flag(lv.obj.FLAG.IGNORE_LAYOUT)
self.btn_run.add_flag(lv.obj.FLAG.CHECKABLE)
self.btn_run.align(lv.ALIGN.TOP_MID, -50, 20)
self.label_run = lv.label(self.btn_run)
self.label_run.set_text("Run")
self.label_run.center()
self.btn_del = lv.btn(self.par)
self.btn_del.add_event_cb(self.btn_del_event_handler, lv.EVENT.CLICKED, None)
self.btn_del.add_flag(lv.obj.FLAG.IGNORE_LAYOUT)
self.btn_del.align(lv.ALIGN.TOP_MID, 50, 20)
self.label_del = lv.label(self.btn_del)
self.label_del.set_text("Stop")
self.label_del.center()
self.slider = lv.slider(self.par)
self.slider.add_event_cb(self.slider_prg_event_handler, lv.EVENT.VALUE_CHANGED, None)
self.slider.add_flag(lv.obj.FLAG.IGNORE_LAYOUT)
self.slider.align(lv.ALIGN.BOTTOM_RIGHT, -20, -20)
self.slider.set_range(0, 65535)
self.obj1 = lv.obj(self.par)
self.obj1.set_size(self.obj_width, self.obj_height)
self.obj2 = lv.obj(self.par)
self.obj2.set_size(self.obj_width, self.obj_height)
self.obj3 = lv.obj(self.par)
self.obj3.set_size(self.obj_width, self.obj_height)
self.anim_timeline = None
def set_width(self,obj, v):
@@ -54,7 +54,7 @@ class LV_ExampleAnimTimeline_1(object):
obj.set_height(v)
def anim_timeline_create(self):
# obj1
# obj1
self.a1 = lv.anim_t()
self.a1.init()
self.a1.set_values(0, self.obj_width)
@@ -62,7 +62,7 @@ class LV_ExampleAnimTimeline_1(object):
self.a1.set_custom_exec_cb(lambda a,v: self.set_width(self.obj1,v))
self.a1.set_path_cb(lv.anim_t.path_overshoot)
self.a1.set_time(300)
self.a2 = lv.anim_t()
self.a2.init()
self.a2.set_values(0, self.obj_height)
@@ -70,8 +70,8 @@ class LV_ExampleAnimTimeline_1(object):
self.a2.set_custom_exec_cb(lambda a,v: self.set_height(self.obj1,v))
self.a2.set_path_cb(lv.anim_t.path_ease_out)
self.a2.set_time(300)
# obj2
# obj2
self.a3=lv.anim_t()
self.a3.init()
self.a3.set_values(0, self.obj_width)
@@ -79,7 +79,7 @@ class LV_ExampleAnimTimeline_1(object):
self.a3.set_custom_exec_cb(lambda a,v: self.set_width(self.obj2,v))
self.a3.set_path_cb(lv.anim_t.path_overshoot)
self.a3.set_time(300)
self.a4 = lv.anim_t()
self.a4.init()
self.a4.set_values(0, self.obj_height)
@@ -87,8 +87,8 @@ class LV_ExampleAnimTimeline_1(object):
self.a4.set_custom_exec_cb(lambda a,v: self.set_height(self.obj2,v))
self.a4.set_path_cb(lv.anim_t.path_ease_out)
self.a4.set_time(300)
# obj3
# obj3
self.a5 = lv.anim_t()
self.a5.init()
self.a5.set_values(0, self.obj_width)
@@ -96,7 +96,7 @@ class LV_ExampleAnimTimeline_1(object):
self.a5.set_custom_exec_cb(lambda a,v: self.set_width(self.obj3,v))
self.a5.set_path_cb(lv.anim_t.path_overshoot)
self.a5.set_time(300)
self.a6 = lv.anim_t()
self.a6.init()
self.a6.set_values(0, self.obj_height)
@@ -104,7 +104,7 @@ class LV_ExampleAnimTimeline_1(object):
self.a6.set_custom_exec_cb(lambda a,v: self.set_height(self.obj3,v))
self.a6.set_path_cb(lv.anim_t.path_ease_out)
self.a6.set_time(300)
# Create anim timeline
print("Create new anim_timeline")
self.anim_timeline = lv.anim_timeline_create()
@@ -114,7 +114,7 @@ class LV_ExampleAnimTimeline_1(object):
lv.anim_timeline_add(self.anim_timeline, 200, self.a4)
lv.anim_timeline_add(self.anim_timeline, 400, self.a5)
lv.anim_timeline_add(self.anim_timeline, 400, self.a6)
def slider_prg_event_handler(self,e):
slider = e.get_target()
@@ -129,7 +129,7 @@ class LV_ExampleAnimTimeline_1(object):
btn = e.get_target()
if not self.anim_timeline:
self.anim_timeline_create()
reverse = btn.has_state(lv.STATE.CHECKED)
lv.anim_timeline_set_reverse(self.anim_timeline,reverse)
lv.anim_timeline_start(self.anim_timeline)
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -16,4 +16,4 @@ Event bubbling
.. lv_example:: event/lv_example_event_3
:language: c
+2 -2
View File
@@ -9,14 +9,14 @@ class Event_1():
btn.set_size(100, 50)
btn.center()
btn.add_event_cb(self.event_cb, lv.EVENT.CLICKED, None)
label = lv.label(btn)
label.set_text("Click me!")
label.center()
def event_cb(self,e):
print("Clicked")
btn = e.get_target()
label = btn.get_child(0)
label.set_text(str(self.cnt))
+1 -1
View File
@@ -7,7 +7,7 @@ def event_cb(e,label):
elif code == lv.EVENT.LONG_PRESSED:
label.set_text("The last button event:\nLV_EVENT_LONG_PRESSED")
elif code == lv.EVENT.LONG_PRESSED_REPEAT:
label.set_text("The last button event:\nLV_EVENT_LONG_PRESSED_REPEAT")
label.set_text("The last button event:\nLV_EVENT_LONG_PRESSED_REPEAT")
btn = lv.btn(lv.scr_act())
btn.set_size(100, 50)
btn.center()
+1 -1
View File
@@ -28,5 +28,5 @@ for i in range(30):
label = lv.label(btn)
label.set_text(str(i))
label.center()
cont.add_event_cb(event_cb, lv.EVENT.CLICKED, None)
+1 -1
View File
@@ -15,4 +15,4 @@ Create a slider and write its value on a label
.. lv_example:: get_started/lv_example_get_started_3
:language: c
@@ -7,7 +7,7 @@ def slider_event_cb(evt):
#
# Create a slider and write its value on a label.
#
# Create a slider in the center of the display
slider = lv.slider(lv.scr_act())
slider.set_width(200) # Set the width
+5 -5
View File
@@ -9,29 +9,29 @@ Arrange items in rows with wrap and even spacing
.. lv_example:: layouts/flex/lv_example_flex_2
:language: c
Demonstrate flex grow
"""""""""""""""""""""""
.. lv_example:: layouts/flex/lv_example_flex_3
:language: c
Demonstrate flex grow.
"""""""""""""""""""""""
.. lv_example:: layouts/flex/lv_example_flex_4
:language: c
Demonstrate column and row gap style properties
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.. lv_example:: layouts/flex/lv_example_flex_5
:language: c
RTL base direction changes order of the items
"""""""""""""""""""""""""""""""""""""""""""""""
.. lv_example:: layouts/flex/lv_example_flex_6
:language: c
+1 -1
View File
@@ -12,7 +12,7 @@ cont.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
for i in range(20):
obj = lv.obj(cont)
obj.set_size(70, lv.SIZE.CONTENT)
label = lv.label(obj)
label.set_text(str(i))
label.center()
+5 -5
View File
@@ -9,29 +9,29 @@ Demonstrate cell placement and span
.. lv_example:: layouts/grid/lv_example_grid_2
:language: c
Demonstrate grid's "free unit"
""""""""""""""""""""""""""""""
.. lv_example:: layouts/grid/lv_example_grid_3
:language: c
Demonstrate track placement
"""""""""""""""""""""""""""
.. lv_example:: layouts/grid/lv_example_grid_4
:language: c
Demonstrate column and row gap
""""""""""""""""""""""""""""""
.. lv_example:: layouts/grid/lv_example_grid_5
:language: c
Demonstrate RTL direction on grid
""""""""""""""""""""""""""""""""""
.. lv_example:: layouts/grid/lv_example_grid_6
:language: c
+1 -1
View File
@@ -20,7 +20,7 @@ for i in range(9):
# Set span to 1 to make the cell 1 column/row sized
obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1,
lv.GRID_ALIGN.STRETCH, row, 1)
label = lv.label(obj)
label.set_text("{:d},{:d}".format(col, row))
label.center()
+1 -1
View File
@@ -29,7 +29,7 @@ except:
wink_argb = lv.img_dsc_t({
'data_size': len(png_data),
'data': png_data
'data': png_data
})
img2 = lv.img(lv.scr_act())
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -1,17 +1,17 @@
Touchpad monkey example
Touchpad monkey example
"""""""""""""""""""
.. lv_example:: others/monkey/lv_example_monkey_1
:language: c
Encoder monkey example
Encoder monkey example
"""""""""""""""""""
.. lv_example:: others/monkey/lv_example_monkey_2
:language: c
Button monkey example
Button monkey example
"""""""""""""""""""
.. lv_example:: others/monkey/lv_example_monkey_3
+1 -1
View File
@@ -1,5 +1,5 @@
Simple snapshot example
Simple snapshot example
"""""""""""""""""""
.. lv_example:: others/snapshot/lv_example_snapshot_1
+5 -5
View File
@@ -1,5 +1,5 @@
Nested scrolling
Nested scrolling
""""""""""""""""
.. lv_example:: scroll/lv_example_scroll_1
@@ -19,15 +19,15 @@ Styling the scrollbars
""""""""""""""""""""""""
.. lv_example:: scroll/lv_example_scroll_4
:language: c
Right to left scrolling
""""""""""""""""""""""""
.. lv_example:: scroll/lv_example_scroll_5
:language: c
Translate on scroll
""""""""""""""""""""""""
.. lv_example:: scroll/lv_example_scroll_6
:language: c
+1 -1
View File
@@ -21,7 +21,7 @@ panel.set_scroll_snap_x(lv.SCROLL_SNAP.CENTER)
panel.set_flex_flow(lv.FLEX_FLOW.ROW)
panel.center()
for i in range(10):
for i in range(10):
btn = lv.btn(panel)
btn.set_size(150, 100)
+2 -2
View File
@@ -20,7 +20,7 @@ class ScrollExample_3():
float_btn.set_style_radius(lv.RADIUS.CIRCLE, 0)
float_btn.set_style_bg_img_src(lv.SYMBOL.PLUS, 0)
float_btn.set_style_text_font(lv.theme_get_font_large(float_btn), 0)
def float_btn_event_cb(self,e,list):
code = e.get_code()
float_btn = e.get_target()
@@ -32,7 +32,7 @@ class ScrollExample_3():
float_btn.move_foreground()
list_btn.scroll_to_view(lv.ANIM.ON)
scroll_example_3 = ScrollExample_3()
+3 -3
View File
@@ -7,7 +7,7 @@ def scroll_event_cb(e):
cont_y_center = cont_a.y1 + cont_a.get_height() // 2
r = cont.get_height() * 7 // 10
child_cnt = cont.get_child_cnt()
for i in range(child_cnt):
child = cont.get_child(i)
@@ -20,7 +20,7 @@ def scroll_event_cb(e):
diff_y = abs(diff_y)
# Get the x of diff_y on a circle.
# If diff_y is out of the circle use the last point of the circle (the radius)
if diff_y >= r:
x = r
@@ -56,7 +56,7 @@ cont.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
for i in range(20):
btn = lv.btn(cont)
btn.set_width(lv.pct(100))
label = lv.label(btn)
label.set_text("Button " + str(i))
+16 -16
View File
@@ -28,64 +28,64 @@ Shadow styles
.. lv_example:: styles/lv_example_style_5
:language: c
Image styles
""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_6
:language: c
Arc styles
""""""""""""""""""""""""
.. lv_example:: style/lv_example_style_7
:language: c
Text styles
""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_8
:language: c
Line styles
""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_9
:language: c
Transition
""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_10
:language: c
Using multiple styles
""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_11
:language: c
Local styles
""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_12
:language: c
Add styles to parts and states
"""""""""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_13
:language: c
Extending the current theme
""""""""""""""""""""""""""""""""""
.. lv_example:: styles/lv_example_style_14
:language: c
+10 -10
View File
@@ -12,16 +12,16 @@ class NewTheme(lv.theme_t):
self.style_btn.set_border_color(lv.palette_darken(lv.PALETTE.GREEN, 3))
self.style_btn.set_border_width(3)
# This theme is based on active theme
# This theme is based on active theme
th_act = lv.theme_get_from_obj(lv.scr_act())
# This theme will be applied only after base theme is applied
self.set_parent(th_act)
self.set_parent(th_act)
class ExampleStyle_14:
def __init__(self):
#
#
# Extending the current theme
#
@@ -30,23 +30,23 @@ class ExampleStyle_14:
label = lv.label(btn)
label.set_text("Original theme")
self.new_theme_init_and_set()
btn = lv.btn(lv.scr_act())
btn.align(lv.ALIGN.BOTTOM_MID, 0, -20)
label = lv.label(btn)
label.set_text("New theme")
def new_theme_apply_cb(self, th, obj):
print(th,obj)
if obj.get_class() == lv.btn_class:
obj.add_style(self.th_new.style_btn, 0)
def new_theme_init_and_set(self):
print("new_theme_init_and_set")
# Initialize the new theme from the current theme
# Initialize the new theme from the current theme
self.th_new = NewTheme()
self.th_new.set_apply_cb(self.new_theme_apply_cb)
lv.disp_get_default().set_theme(self.th_new)
+2 -2
View File
@@ -11,10 +11,10 @@ try:
except:
print("Could not find img_cogwheel_argb.png")
sys.exit()
img_cogwheel_argb = lv.img_dsc_t({
'data_size': len(png_data),
'data': png_data
'data': png_data
})
#
+2 -2
View File
@@ -12,8 +12,8 @@ style.set_line_rounded(True)
# Create an object with the new style
obj = lv.line(lv.scr_act())
obj.add_style(style, 0)
p = [ {"x":10, "y":30},
{"x":30, "y":50},
p = [ {"x":10, "y":30},
{"x":30, "y":50},
{"x":100, "y":0}]
obj.set_points(p, 3)
+1 -1
View File
@@ -1,5 +1,5 @@
Simple Animation Image
Simple Animation Image
""""""""""""""""
.. lv_example:: widgets/animimg/lv_example_animimg_1
@@ -13,10 +13,10 @@ try:
except:
print("Could not find animimg001.png")
sys.exit()
anim_imgs[0] = lv.img_dsc_t({
'data_size': len(anim001_data),
'data': anim001_data
'data': anim001_data
})
try:
@@ -25,10 +25,10 @@ try:
except:
print("Could not find animimg002.png")
sys.exit()
anim_imgs[1] = lv.img_dsc_t({
'data_size': len(anim002_data),
'data': anim002_data
'data': anim002_data
})
try:
@@ -37,10 +37,10 @@ try:
except:
print("Could not find animimg003.png")
sys.exit()
anim_imgs[2] = lv.img_dsc_t({
'data_size': len(anim003_data),
'data': anim003_data
'data': anim003_data
})
animimg0 = lv.animimg(lv.scr_act())
+2 -2
View File
@@ -1,12 +1,12 @@
Simple Arc
Simple Arc
""""""""""""""""
.. lv_example:: widgets/arc/lv_example_arc_1
:language: c
:description: A simple example to demonstrate the use of an arc.
Loader with Arc
Loader with Arc
""""""""""""""""
.. lv_example:: widgets/arc/lv_example_arc_2
+2 -2
View File
@@ -4,7 +4,7 @@
class ArcLoader():
def __init__(self):
self.a = 270
def arc_loader_cb(self,tim,arc):
# print(tim,arc)
self.a += 5
@@ -33,5 +33,5 @@ arc_loader = ArcLoader()
timer = lv.timer_create_basic()
timer.set_period(20)
timer.set_cb(lambda src: arc_loader.arc_loader_cb(timer,arc))
+6 -6
View File
@@ -1,27 +1,27 @@
Simple Bar
Simple Bar
""""""""""""""""
.. lv_example:: widgets/bar/lv_example_bar_1
:language: c
Styling a bar
""""""""""""""""
.. lv_example:: widgets/bar/lv_example_bar_2
:language: c
Temperature meter
""""""""""""""""""
.. lv_example:: widgets/bar/lv_example_bar_3
:language: c
Stripe pattern and range value
""""""""""""""""""""""""""""""""
.. lv_example:: widgets/bar/lv_example_bar_4
:language: c
Bar with LTR and RTL base direction
""""""""""""""""""""""""""""""""""""
@@ -33,4 +33,4 @@ Custom drawer to show the current value
.. lv_example:: widgets/bar/lv_example_bar_6
:language: c
+3 -3
View File
@@ -8,9 +8,9 @@ def get_icon(filename,xres,yres):
with open(sdl_filename,'rb') as f:
icon_data = f.read()
except:
print("Could not find image file: " + filename)
print("Could not find image file: " + filename)
return None
icon_dsc = lv.img_dsc_t(
{
"header": {"always_zero": 0, "w": xres, "h": yres, "cf": lv.img.CF.TRUE_COLOR_ALPHA},
@@ -42,4 +42,4 @@ bar.set_value(90, lv.ANIM.OFF)
bar.set_start_value(20, lv.ANIM.OFF)
+2 -2
View File
@@ -1,5 +1,5 @@
Simple Buttons
Simple Buttons
""""""""""""""""
.. lv_example:: widgets/btn/lv_example_btn_1
@@ -11,7 +11,7 @@ Styling buttons
.. lv_example:: widgets/btn/lv_example_btn_2
:language: c
Gummy button
""""""""""""""""
+1 -1
View File
@@ -5,7 +5,7 @@ def event_handler(evt):
print("Clicked event seen")
elif code == lv.EVENT.VALUE_CHANGED:
print("Value changed seen")
# create a simple button
btn1 = lv.btn(lv.scr_act())
+3 -3
View File
@@ -1,19 +1,19 @@
Simple Button matrix
Simple Button matrix
""""""""""""""""""""""
.. lv_example:: widgets/btnmatrix/lv_example_btnmatrix_1
:language: c
Custom buttons
Custom buttons
""""""""""""""""""""""
.. lv_example:: widgets/btnmatrix/lv_example_btnmatrix_2
:language: c
Pagination
Pagination
""""""""""""""""""""""
.. lv_example:: widgets/btnmatrix/lv_example_btnmatrix_3
@@ -12,10 +12,10 @@ try:
except:
print("Could not find star.png")
sys.exit()
img_star_argb = lv.img_dsc_t({
'data_size': len(png_data),
'data': png_data
'data': png_data
})
def event_cb(e):
@@ -44,7 +44,7 @@ def event_cb(e):
dsc.rect_dsc.bg_color = lv.palette_darken(lv.PALETTE.RED, 3)
else:
dsc.rect_dsc.bg_color = lv.palette_main(lv.PALETTE.RED)
dsc.label_dsc.color = lv.color_white()
elif dsc.id == 3:
dsc.label_dsc.opa = lv.OPA.TRANSP # Hide the text if any
+1 -1
View File
@@ -1,5 +1,5 @@
Calendar with header
Calendar with header
""""""""""""""""""""""
.. lv_example:: widgets/calendar/lv_example_calendar_1
@@ -5,10 +5,10 @@ def event_handler(evt):
if code == lv.EVENT.VALUE_CHANGED:
source = evt.get_current_target()
date = lv.calendar_date_t()
if source.get_pressed_date(date) == lv.RES.OK:
if source.get_pressed_date(date) == lv.RES.OK:
calendar.set_today_date(date.year, date.month, date.day)
print("Clicked date: %02d.%02d.%02d"%(date.day, date.month, date.year))
calendar = lv.calendar(lv.scr_act())
calendar.set_size(200, 200)
+1 -1
View File
@@ -1,5 +1,5 @@
Drawing on the Canvas and rotate
Drawing on the Canvas and rotate
""""""""""""""""""""""""""""""""""
.. lv_example:: widgets/canvas/lv_example_canvas_1
@@ -1,6 +1,6 @@
CANVAS_WIDTH = 50
CANVAS_HEIGHT = 50
LV_COLOR_CHROMA_KEY = lv.color_hex(0x00ff00)
LV_COLOR_CHROMA_KEY = lv.color_hex(0x00ff00)
def LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h):
return int(((w / 8) + 1) * h)
@@ -13,7 +13,7 @@ def LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h):
#
# Create a transparent canvas with Chroma keying and indexed color format (palette).
#
#
# Create a button to better see the transparency
btn=lv.btn(lv.scr_act())
+9 -9
View File
@@ -1,41 +1,41 @@
Line Chart
Line Chart
""""""""""
.. lv_example:: widgets/chart/lv_example_chart_1
:language: c
Faded area line chart with custom division lines
Faded area line chart with custom division lines
"""""""""""""""""""""""""""""""""""""""""""""""""""
.. lv_example:: widgets/chart/lv_example_chart_2
:language: c
Axis ticks and labels with scrolling
""""""""""""""""""""""""""""""""""""
.. lv_example:: widgets/chart/lv_example_chart_3
:language: c
Show the value of the pressed points
""""""""""""""""""""""""""""""""""""""
.. lv_example:: widgets/chart/lv_example_chart_4
:language: c
Display 1000 data points with zooming and scrolling
""""""""""""""""""""""""""""""""""""""""""""""""""""
.. lv_example:: widgets/chart/lv_example_chart_5
:language: c
Show cursor on the clicked point
"""""""""""""""""""""""""""""""""""
.. lv_example:: widgets/chart/lv_example_chart_6
:language: c
Scatter chart
"""""""""""""""""""""""""""""""""""
+2 -2
View File
@@ -1,10 +1,10 @@
def draw_event_cb(e):
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
if dsc.part == lv.PART.TICKS and dsc.id == lv.chart.AXIS.PRIMARY_X:
if dsc.part == lv.PART.TICKS and dsc.id == lv.chart.AXIS.PRIMARY_X:
month = ["Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"]
# dsc.text is defined char text[16], I must therefore convert the Python string to a byte_array
dsc.text = bytes(month[dsc.value],"ascii")
dsc.text = bytes(month[dsc.value],"ascii")
#
# Add ticks and labels to the axis and demonstrate scrolling
#
+6 -6
View File
@@ -18,7 +18,7 @@ def event_cb(e):
chart.get_point_pos_by_id(series[i], id, p)
value = series_points[i][id]
buf = lv.SYMBOL.DUMMY + "$" + str(value)
draw_rect_dsc = lv.draw_rect_dsc_t()
draw_rect_dsc.init()
draw_rect_dsc.bg_color = lv.color_black()
@@ -26,7 +26,7 @@ def event_cb(e):
draw_rect_dsc.radius = 3
draw_rect_dsc.bg_img_src = buf
draw_rect_dsc.bg_img_recolor = lv.color_white()
a = lv.area_t()
coords = lv.area_t()
chart.get_coords(coords)
@@ -34,14 +34,14 @@ def event_cb(e):
a.x2 = coords.x1 + p.x + 20
a.y1 = coords.y1 + p.y - 30
a.y2 = coords.y1 + p.y - 10
clip_area = lv.area_t.__cast__(e.get_param())
lv.draw_rect(a, clip_area, draw_rect_dsc)
elif code == lv.EVENT.RELEASED:
chart.invalidate()
#
#
# Add ticks and labels to the axis and demonstrate scrolling
#
+1 -1
View File
@@ -59,7 +59,7 @@ def slider_y_event_cb(e):
# Display 1000 data points with zooming and scrolling.
# See how the chart changes drawing mode (draw only vertical lines) when
# the points get too crowded.
# Create a chart
chart = lv.chart(lv.scr_act())
chart.set_size(200, 150)
+14 -14
View File
@@ -1,5 +1,5 @@
class ExampleChart_6():
def __init__(self):
self.last_id = -1
#
@@ -9,21 +9,21 @@ class ExampleChart_6():
chart = lv.chart(lv.scr_act())
chart.set_size(200, 150)
chart.align(lv.ALIGN.CENTER, 0, -10)
chart.set_axis_tick(lv.chart.AXIS.PRIMARY_Y, 10, 5, 6, 5, True, 40)
chart.set_axis_tick(lv.chart.AXIS.PRIMARY_X, 10, 5, 10, 1, True, 30)
chart.add_event_cb(self.event_cb, lv.EVENT.ALL, None)
chart.refresh_ext_draw_size()
self.cursor = chart.add_cursor(lv.palette_main(lv.PALETTE.BLUE), lv.DIR.LEFT | lv.DIR.BOTTOM)
self.ser = chart.add_series(lv.palette_main(lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y)
self.ser_p = []
for i in range(10):
self.ser_p.append(lv.rand(10,90))
self.ser.y_points = self.ser_p
self.ser.y_points = self.ser_p
newser = chart.get_series_next(None)
# print("length of data points: ",len(newser.points))
@@ -32,8 +32,8 @@ class ExampleChart_6():
label = lv.label(lv.scr_act())
label.set_text("Click on a point")
label.align_to(chart, lv.ALIGN.OUT_TOP_MID, 0, -5)
def event_cb(self,e):
code = e.get_code()
@@ -46,7 +46,7 @@ class ExampleChart_6():
p = lv.point_t()
chart.get_point_pos_by_id(self.ser, self.last_id, p)
chart.set_cursor_point(self.cursor, None, self.last_id)
elif code == lv.EVENT.DRAW_PART_END:
# print("EVENT.DRAW_PART_END")
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
@@ -57,25 +57,25 @@ class ExampleChart_6():
if dsc.part == lv.PART.CURSOR and dsc.p1 and dsc.p2 and dsc.p1.y == dsc.p2.y and self.last_id >= 0:
v = self.ser_p[self.last_id]
# print("value: ",v)
value_txt = str(v)
size = lv.point_t()
lv.txt_get_size(size, value_txt, lv.font_default(), 0, 0, lv.COORD.MAX, lv.TEXT_FLAG.NONE)
a = lv.area_t()
a.y2 = dsc.p1.y - 5
a.y1 = a.y2 - size.y - 10
a.x1 = dsc.p1.x + 10
a.x2 = a.x1 + size.x + 10
draw_rect_dsc = lv.draw_rect_dsc_t()
draw_rect_dsc.init()
draw_rect_dsc.bg_color = lv.palette_main(lv.PALETTE.BLUE)
draw_rect_dsc.radius = 3
lv.draw_rect(a, dsc.clip_area, draw_rect_dsc)
draw_label_dsc = lv.draw_label_dsc_t()
draw_label_dsc.init()
draw_label_dsc.color = lv.color_white()
+5 -5
View File
@@ -12,7 +12,7 @@ def draw_event_cb(e):
# print("cnt: ",cnt)
# Make older value more transparent
dsc.rect_dsc.bg_opa = (lv.OPA.COVER * dsc.id) // (cnt - 1)
# Make smaller values blue, higher values red
# x_array = chart.get_x_array(ser)
# y_array = chart.get_y_array(ser)
@@ -23,11 +23,11 @@ def draw_event_cb(e):
# print("p_act", p_act)
x_opa = (x_array[p_act] * lv.OPA._50) // 200
y_opa = (y_array[p_act] * lv.OPA._50) // 1000
dsc.rect_dsc.bg_color = lv.palette_main(lv.PALETTE.RED).color_mix(
lv.palette_main(lv.PALETTE.BLUE),
x_opa + y_opa)
def add_data(timer,chart):
# print("add_data")
x = lv.rand(0,200)
@@ -38,7 +38,7 @@ def add_data(timer,chart):
x_array.append(x)
y_array.pop(0)
y_array.append(y)
#
# A scatter chart
#
@@ -66,7 +66,7 @@ y_array = []
for i in range(50):
x_array.append(lv.rand(0, 200))
y_array.append(lv.rand(0, 1000))
ser.x_points = x_array
ser.y_points = y_array
+1 -1
View File
@@ -81,7 +81,7 @@ def lv_example_chart_8():
stacked_area_chart.obj.set_div_line_count(5, 7)
stacked_area_chart.obj.add_event_cb( draw_event_cb, lv.EVENT.DRAW_PART_BEGIN, None)
# Set range to 0 to 100 for percentages. Draw ticks
# Set range to 0 to 100 for percentages. Draw ticks
stacked_area_chart.obj.set_range(lv.chart.AXIS.PRIMARY_Y,0,100)
stacked_area_chart.obj.set_axis_tick(lv.chart.AXIS.PRIMARY_Y, 3, 0, 5, 1, True, 30)
@@ -1,7 +1,7 @@
def event_handler(e):
code = e.get_code()
obj = e.get_target()
if code == lv.EVENT.VALUE_CHANGED:
if code == lv.EVENT.VALUE_CHANGED:
option = " "*10 # should be large enough to store the option
obj.get_selected_str(option, len(option))
# .strip() removes trailing spaces
@@ -12,10 +12,10 @@ try:
except:
print("Could not find img_caret_down.png")
sys.exit()
img_caret_down_argb = lv.img_dsc_t({
'data_size': len(png_data),
'data': png_data
'data': png_data
})
def event_cb(e):

Some files were not shown because too many files have changed in this diff Show More