def __init__(self):

	scr = lv.obj()

	# Create style for the Arcs - Hour
	styleHour = lv.style_t()
	lv.style_copy(styleHour, lv.style_plain)
	styleHour.line.color = lv.color_make(119,158,203) # Arc color
	styleHour.line.width = 8                      # Arc width

	# Create an Arc - Hour
	arcHour = lv.arc(scr)
	arcHour.set_style(lv.arc.STYLE.MAIN, styleHour)   # Use the new style
	arcHour.set_angles(45, 0)
	arcHour.set_size(300, 300)
	arcHour.align(None, lv.ALIGN.CENTER, 0, 0)

	# Create style for the Arcs - Minute
	styleMin = lv.style_t()
	lv.style_copy(styleMin, lv.style_plain)
	styleMin.line.color = lv.color_make(124,252,0) # Arc color
	styleMin.line.width = 8                      # Arc width

	# Create an Arc - Minute
	arcMin = lv.arc(scr)
	arcMin.set_style(lv.arc.STYLE.MAIN, styleMin)   # Use the new style
	arcMin.set_angles(45, 0)
	arcMin.set_size(380, 380)
	arcMin.align(None, lv.ALIGN.CENTER, 0, 0)

	# Create style for the Arcs - Second
	styleSecond = lv.style_t()
	lv.style_copy(styleSecond, lv.style_plain)
	styleSecond.line.color = lv.color_make(250,128,114) # Arc color
	styleSecond.line.width = 8                      # Arc width

	# Create an Arc - Minute
	arcSecond = lv.arc(scr)
	arcSecond.set_style(lv.arc.STYLE.MAIN, styleSecond)   # Use the new style
	arcSecond.set_angles(45, 0)
	arcSecond.set_size(220, 220)
	arcSecond.align(None, lv.ALIGN.CENTER, 0, 0)

	def event_handler(obj, event):
		lv.obj_del(scr)
		from secondScreen import secondScreen

	btn1 = lv.btn(scr)
	btn1.set_event_cb(event_handler)
	btn1.align(None, lv.ALIGN.CENTER, 0, 0)
	label = lv.label(btn1)
	label.set_text("Button")

	lv.scr_load(scr)
 def __init__(self, title, message, button_text="Cancel"):
     super().__init__(title, message, button_text=button_text)
     self.arc = lv.arc(self)
     self.start = 0
     self.end = 30
     self.arc.set_angles(self.start, self.end)
     self.arc.align(self, lv.ALIGN.CENTER, 0, -150)
     self.message.align(self.arc, lv.ALIGN.OUT_BOTTOM_MID, 0, 120)
     self.progress = add_label("", scr=self, style="title")
     self.progress.align(self.message, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)
     self.progress.set_recolor(True)
Exemple #3
0
    def add_loader(self, end_cb):
        arc = lv.arc(lv.scr_act(), None)
        arc.set_bg_angles(0, 0)
        arc.set_start_angle(270)
        arc.set_size(220, 220)
        self.theme.apply(arc, lv.THEME.ARC)
        self.log.debug("Starting loader anim")
        a = lv.anim_t()
        a.init()
        a.set_custom_exec_cb(lambda a, val: self.loader_anim_cb(a, arc, val))
        a.set_values(0, 110)
        a.set_time(2000)
        a.set_ready_cb(end_cb)
        lv.anim_t.start(a)

        return arc
def lv_arc(screen):

    # Create the arc object on lv screen, ie a lv.scr() object
    arc = lv.arc(screen)

    # Set arc size
    arc.set_size(150, 150)

    # Set arc background style color blue
    arc.add_style(arc.PART.BG, styles.gstyle_bg1)
    # Set arc indicator (i.e. line) style to color red
    arc.add_style(arc.PART.INDIC, styles.gstyle_line1)

    # Setup Angles, from docs:
    #  Zero degree is at the middle right (3 o'clock) of the object and the degrees are increasing
    #  in a clockwise direction. The angles should be in [0;360] range.
    #
    # Get background angle start and end in degrees
    start = arc.get_bg_angle_start()  # default is 135
    end = arc.get_bg_angle_end()  # default is 45

    # Set background angles
    #arc.set_bg_angles(180,max)
    # Set start angle of the arc (0-360 degrees)
    #arc.set_start_angle(0)

    # Get current value of arc
    # print(arc.get_value()) # default is 0
    # print(arc.get_min_value()) # default is 0
    # print(arc.get_max_value()) # default is 100

    # Set the current value (0-100)
    # A percentage of the arc foreground that is filled
    # Note: This doesnt work on micropython?
    # Examples:
    #    50 is 50% filled
    #    100 is 100% filled
    # arc.set_value(5)
    #
    # Or set the value base on end angle (0-360) degrees
    # Set end angle of the arc (0-360 degrees)
    arc.set_end_angle(200)
Exemple #5
0
def visuals_create(parent):
    page = lv.page.__cast__(parent)
    lv.page.set_scrl_layout(page, lv.LAYOUT.PRETTY_TOP)

    disp_size = display.get_size_category()

    grid_h_chart = lv.page.get_height_grid(page, 1, 1)
    if disp_size <= lv.DISP_SIZE.LARGE:
        grid_w_chart = lv.page.get_width_grid(page, 1, 1)
    else:
        grid_w_chart = lv.page.get_width_grid(page, 1, 2)

    chart = lv.chart(parent, None)
    chart.add_style(lv.chart.PART.BG, style_box)
    if disp_size <= lv.DISP_SIZE.SMALL:
        chart.set_style_local_text_font(lv.chart.PART.SERIES_BG,
                                        lv.STATE.DEFAULT,
                                        lv.theme_get_font_small())

    chart.set_drag_parent(True)
    chart.set_style_local_value_str(lv.cont.PART.MAIN, lv.STATE.DEFAULT,
                                    "Line chart")
    chart.set_width_margin(grid_w_chart)
    chart.set_height_margin(grid_h_chart)
    chart.set_div_line_count(3, 0)
    chart.set_point_count(8)
    chart.set_type(lv.chart.TYPE.LINE)

    if disp_size > lv.DISP_SIZE.SMALL:
        chart.set_style_local_pad_left(lv.chart.PART.BG, lv.STATE.DEFAULT,
                                       4 * (LV_DPI // 10))
        chart.set_style_local_pad_bottom(lv.chart.PART.BG, lv.STATE.DEFAULT,
                                         3 * (LV_DPI // 10))
        chart.set_style_local_pad_right(lv.chart.PART.BG, lv.STATE.DEFAULT,
                                        2 * (LV_DPI // 10))
        chart.set_style_local_pad_top(lv.chart.PART.BG, lv.STATE.DEFAULT,
                                      2 * (LV_DPI // 10))
        chart.set_y_tick_length(0, 0)
        chart.set_x_tick_length(0, 0)
        chart.set_y_tick_texts("600\n500\n400\n300\n200", 0,
                               lv.chart.AXIS.DRAW_LAST_TICK)
        chart.set_x_tick_texts("Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug", 0,
                               lv.chart.AXIS.DRAW_LAST_TICK)

    s1 = chart.add_series(LV_THEME_DEFAULT_COLOR_PRIMARY)
    s2 = chart.add_series(LV_THEME_DEFAULT_COLOR_SECONDARY)

    chart.set_next(s1, 10)
    chart.set_next(s1, 90)
    chart.set_next(s1, 30)
    chart.set_next(s1, 60)
    chart.set_next(s1, 10)
    chart.set_next(s1, 90)
    chart.set_next(s1, 30)
    chart.set_next(s1, 60)
    chart.set_next(s1, 10)
    chart.set_next(s1, 90)

    chart.set_next(s2, 32)
    chart.set_next(s2, 66)
    chart.set_next(s2, 5)
    chart.set_next(s2, 47)
    chart.set_next(s2, 32)
    chart.set_next(s2, 32)
    chart.set_next(s2, 66)
    chart.set_next(s2, 5)
    chart.set_next(s2, 47)
    chart.set_next(s2, 66)
    chart.set_next(s2, 5)
    chart.set_next(s2, 47)

    chart2 = lv.chart(parent, chart)
    chart2.set_type(lv.chart.TYPE.COLUMN)
    chart2.set_style_local_value_str(lv.cont.PART.MAIN, lv.STATE.DEFAULT,
                                     "Column chart")

    s1 = chart2.add_series(LV_THEME_DEFAULT_COLOR_PRIMARY)
    s2 = chart2.add_series(LV_THEME_DEFAULT_COLOR_SECONDARY)

    chart2.set_next(s1, 10)
    chart2.set_next(s1, 90)
    chart2.set_next(s1, 30)
    chart2.set_next(s1, 60)
    chart2.set_next(s1, 10)
    chart2.set_next(s1, 90)
    chart2.set_next(s1, 30)
    chart2.set_next(s1, 60)
    chart2.set_next(s1, 10)
    chart2.set_next(s1, 90)

    chart2.set_next(s2, 32)
    chart2.set_next(s2, 66)
    chart2.set_next(s2, 5)
    chart2.set_next(s2, 47)
    chart2.set_next(s2, 32)
    chart2.set_next(s2, 32)
    chart2.set_next(s2, 66)
    chart2.set_next(s2, 5)
    chart2.set_next(s2, 47)
    chart2.set_next(s2, 66)
    chart2.set_next(s2, 5)
    chart2.set_next(s2, 47)

    if disp_size <= lv.DISP_SIZE.SMALL:
        grid_w_meter = lv.page.get_width_grid(page, 1, 1)
    elif disp_size <= lv.DISP_SIZE.MEDIUM:
        grid_w_meter = lv.page.get_width_grid(page, 2, 1)
    else:
        grid_w_meter = lv.page.get_width_grid(page, 3, 1)

    meter_h = lv.page.get_height_fit(page)
    if grid_w_meter < meter_h:
        meter_size = grid_w_meter
    else:
        meter_size = meter_h

    lmeter = lv.linemeter(parent, None)
    lmeter.set_drag_parent(True)
    lmeter.set_value(50)
    lmeter.set_size(meter_size, meter_size)
    lmeter.add_style(lv.linemeter.PART.MAIN, style_box)
    lmeter.set_style_local_value_str(lv.linemeter.PART.MAIN, lv.STATE.DEFAULT,
                                     "Line meter")

    label = lv.label(lmeter, None)
    label.align(lmeter, lv.ALIGN.CENTER, 0, 0)
    label.set_style_local_text_font(lv.label.PART.MAIN, lv.STATE.DEFAULT,
                                    lv.theme_get_font_title())

    a_lm = lv.anim_t()
    a_lm.init()
    a_lm.set_custom_exec_cb(lambda a, val: linemeter_anim(a, lmeter, val))
    a_lm.set_values(0, 100)
    a_lm.set_time(4000)
    a_lm.set_playback_time(1000)
    a_lm.set_repeat_count(LV_ANIM_REPEAT_INFINITE)
    lv.anim_t.start(a_lm)

    gauge = lv.gauge(parent, None)
    gauge.set_drag_parent(True)
    gauge.set_size(meter_size, meter_size)
    gauge.add_style(lv.gauge.PART.MAIN, style_box)
    gauge.set_style_local_value_str(lv.gauge.PART.MAIN, lv.STATE.DEFAULT,
                                    "Gauge")

    label = lv.label(gauge, label)
    label.align(gauge, lv.ALIGN.CENTER, 0, grid_w_meter // 3)

    a_ga = lv.anim_t()
    a_ga.init()
    a_ga.set_custom_exec_cb(lambda a, val: linemeter_anim(a, lmeter, val))
    a_ga.set_values(0, 100)
    a_ga.set_time(4000)
    a_ga.set_playback_time(1000)
    a_ga.set_repeat_count(LV_ANIM_REPEAT_INFINITE)
    a_ga.set_custom_exec_cb(lambda a, val: gauge_anim(a, gauge, val))
    lv.anim_t.start(a_ga)

    arc = lv.arc(parent, None)
    arc.set_drag_parent(True)
    arc.set_bg_angles(0, 360)
    arc.set_rotation(270)
    arc.set_angles(0, 0)
    arc.set_size(meter_size, meter_size)
    arc.add_style(lv.arc.PART.BG, style_box)
    arc.set_style_local_value_str(lv.arc.PART.BG, lv.STATE.DEFAULT, "Arc")

    label = lv.label(arc)
    label.align(arc, lv.ALIGN.CENTER, 0, 0)

    a_arc = lv.anim_t()
    a_arc.init()
    a_arc.set_custom_exec_cb(lambda a_arc, val: anim_phase1(a_arc, arc, val))
    a_arc.set_values(0, 360)
    a_arc.set_ready_cb(lambda a: arc_phase1_ready_cb(a, arc))
    # a_arc.set_repeat_count(LV_ANIM_REPEAT_INFINITE)
    a_arc.set_time(1000)
    lv.anim_t.start(a_arc)

    # Create a bar and use the backgrounds value style property to display the current value
    bar_h = lv.cont(parent, None)
    bar_h.set_fit2(lv.FIT.NONE, lv.FIT.TIGHT)
    bar_h.add_style(lv.cont.PART.MAIN, style_box)
    bar_h.set_style_local_value_str(lv.cont.PART.MAIN, lv.STATE.DEFAULT, "Bar")

    if disp_size <= lv.DISP_SIZE.SMALL:
        bar_h.set_width(lv.page_get_width_grid(page, 1, 1))
    elif disp_size <= lv.DISP_SIZE.MEDIUM:
        bar_h.set_width(lv.page.get_width_grid(page, 2, 1))
    else:
        bar_h.set_width(lv.page.get_width_grid(parent, 3, 2))

    bar = lv.bar(bar_h, None)
    bar.set_width(lv.cont.get_width_fit(bar_h))
    bar.set_style_local_value_font(lv.bar.PART.BG, lv.STATE.DEFAULT,
                                   lv.theme_get_font_small())
    bar.set_style_local_value_align(lv.bar.PART.BG, lv.STATE.DEFAULT,
                                    lv.ALIGN.OUT_BOTTOM_MID)
    bar.set_style_local_value_ofs_y(lv.bar.PART.BG, lv.STATE.DEFAULT,
                                    LV_DPI // 20)
    bar.set_style_local_margin_bottom(lv.bar.PART.BG, lv.STATE.DEFAULT,
                                      LV_DPI // 7)
    bar.align(None, lv.ALIGN.CENTER, 0, 0)
    bar.set_value(30, lv.ANIM.OFF)

    led_h = lv.cont(parent, None)
    led_h.set_layout(lv.LAYOUT.PRETTY_MID)
    if disp_size <= lv.DISP_SIZE.SMALL:
        led_h.set_width(lv.page.get_width_grid(page, 1, 1))
    elif disp_size <= lv.DISP_SIZE.MEDIUM:
        led_h.set_width(lv.page.get_width_grid(page, 2, 1))
    else:
        led_h.set_width(lv.page.get_width_grid(page, 3, 1))

    led_h.set_height(lv.obj.get_height(lv.obj.__cast__(bar_h)))
    led_h.add_style(lv.cont.PART.MAIN, style_box)
    led_h.set_drag_parent(True)
    led_h.set_style_local_value_str(lv.cont.PART.MAIN, lv.STATE.DEFAULT,
                                    "LEDs")

    led = lv.led(led_h, None)
    led_size = lv.obj.get_height_fit(lv.obj.__cast__(led_h))
    led.set_size(led_size, led_size)
    led.off()

    led = lv.led(led_h, led)
    led.set_bright((LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN) // 2 +
                   LV_LED_BRIGHT_MIN)

    led = lv.led(led_h, led)
    led.on()

    if disp_size == lv.DISP_SIZE.MEDIUM:
        led_h.add_protect(lv.PROTECT.POS)
        led_h.align(
            bar_h, lv.ALIGN.OUT_BOTTOM_MID, 0,
            lv.obj.get_style_margin_top(lv.obj.__cast__(led_h),
                                        lv.obj.PART.MAIN) +
            lv.obj.get_style_pad_inner(parent, lv.page.PART.SCROLLABLE))

    task = lv.task_create_basic()
    task.set_cb(lambda task: bar_anim(task, bar))
    task.set_period(100)
    task.set_prio(lv.TASK_PRIO.LOWEST)
Exemple #6
0
    def arc_loader_cb(self,tim,arc):
        # print(tim,arc)
        self.a += 5

        arc.set_end_angle(self.a)

        if self.a >= 270 + 360:
            tim._del()


#
# Create an arc which acts as a loader.
#

# Create an Arc
arc = lv.arc(lv.scr_act())
arc.set_bg_angles(0, 360)
arc.set_angles(270, 270)
arc.center()

# create the loader
arc_loader = ArcLoader()

# Create an `lv_timer` to update the arc.

timer = lv.timer_create_basic()
timer.set_period(20)
timer.set_cb(lambda src: arc_loader.arc_loader_cb(timer,arc))
  

Exemple #7
0
    def createPage(self):
        global isStarted
        global isAnimationComplete
        global arc
        global anim
        global timeCount
        global currentSelect
        global minuteLabel
        global secondLabel
        global millionLabel
        global anim_timeline
        global startLabel
        global currentValue
        global timer_alive

        print("Enter Timer")

        # init scr
        scr = lv.obj()

        win = lv.obj(scr)
        win.set_size(scr.get_width(), scr.get_height())
        win.set_style_border_opa(0, 0)
        win.set_style_radius(0, 0)
        win.set_style_bg_color(lv.color_black(), 0)
        win.clear_flag(lv.obj.FLAG.SCROLLABLE)

        # back
        backImg = lv.img(win)
        backImg.set_src(RESOURCES_ROOT + "images/back.png")
        backImg.set_style_align(lv.ALIGN.LEFT_MID, 0)
        backImg.add_flag(lv.obj.FLAG.CLICKABLE)
        backImg.add_event_cb(lambda e: timer_back_click_callback(e, win),
                             lv.EVENT.CLICKED, None)
        backImg.add_event_cb(lambda e: timer_back_press_callback(e, backImg),
                             lv.EVENT.PRESSED, None)
        backImg.add_event_cb(lambda e: timer_back_release_callback(e, backImg),
                             lv.EVENT.RELEASED, None)
        backImg.set_ext_click_area(30)

        isStarted = False
        currentSelect = 0

        # count down
        func_col_dsc = [40, 5, 30, 5, 20, lv.GRID_TEMPLATE.LAST]
        func_row_dsc = [30, lv.GRID_TEMPLATE.LAST]

        timeContainer = lv.obj(win)
        timeContainer.set_style_bg_opa(0, 0)
        timeContainer.set_style_border_opa(0, 0)
        timeContainer.set_layout(lv.LAYOUT_GRID.value)
        timeContainer.set_style_grid_column_dsc_array(func_col_dsc, 0)
        timeContainer.set_style_grid_row_dsc_array(func_row_dsc, 0)
        timeContainer.set_grid_align(lv.GRID_ALIGN.SPACE_BETWEEN,
                                     lv.GRID_ALIGN.SPACE_BETWEEN)
        timeContainer.set_style_pad_all(0, 0)
        timeContainer.set_size(240, 70)
        timeContainer.center()

        minuteLabel = lv.label(timeContainer)
        minuteLabel.set_style_text_font(lv.font_montserrat_48, 0)
        minuteLabel.set_style_text_color(lv.color_white(), 0)
        minuteLabel.set_grid_cell(lv.GRID_ALIGN.START, 0, 1,
                                  lv.GRID_ALIGN.CENTER, 0, 1)

        signLabel = lv.label(timeContainer)
        signLabel.set_style_text_font(lv.font_montserrat_48, 0)
        signLabel.set_style_text_color(lv.color_white(), 0)
        signLabel.set_text(":")
        signLabel.set_grid_cell(lv.GRID_ALIGN.CENTER, 1, 1,
                                lv.GRID_ALIGN.CENTER, 0, 1)

        secondLabel = lv.label(timeContainer)
        secondLabel.set_style_text_font(lv.font_montserrat_48, 0)
        secondLabel.set_style_text_color(lv.color_white(), 0)
        secondLabel.set_grid_cell(lv.GRID_ALIGN.CENTER, 2, 1,
                                  lv.GRID_ALIGN.CENTER, 0, 1)

        signLabel = lv.label(timeContainer)
        signLabel.set_style_text_font(lv.font_montserrat_48, 0)
        signLabel.set_style_text_color(lv.color_white(), 0)
        signLabel.set_text(":")
        signLabel.set_grid_cell(lv.GRID_ALIGN.CENTER, 3, 1,
                                lv.GRID_ALIGN.CENTER, 0, 1)

        millionLabel = lv.label(timeContainer)
        millionLabel.set_style_text_font(lv.font_montserrat_36, 0)
        millionLabel.set_style_text_color(lv.color_white(), 0)
        millionLabel.set_grid_cell(lv.GRID_ALIGN.END, 4, 1,
                                   lv.GRID_ALIGN.START, 0, 1)

        setLabelValue(timeCount[currentSelect] * 60 * 50)

        startButton = lv.btn(win)
        startButton.align(lv.ALIGN.CENTER, 0, 40)
        startButton.set_size(126, 54)
        startButton.set_style_radius(45, lv.PART.MAIN)
        startButton.set_style_shadow_opa(0, 0)
        startButton.set_style_bg_color(lv.color_make(0xFF, 0xA8, 0x48),
                                       lv.PART.MAIN)
        startButton.align(lv.ALIGN.BOTTOM_LEFT, 12, -12)
        startButton.add_event_cb(start_button_event_handler, lv.EVENT.CLICKED,
                                 None)

        startLabel = lv.label(startButton)
        startLabel.set_text("START")
        startLabel.set_style_text_color(lv.color_black(), 0)
        startLabel.set_style_text_font(lv.font_montserrat_20, 0)
        startLabel.center()

        resetButton = lv.btn(win)
        resetButton.align(lv.ALIGN.CENTER, 0, 40)
        resetButton.set_size(126, 54)
        resetButton.set_style_radius(45, lv.PART.MAIN)
        resetButton.set_style_shadow_opa(0, 0)
        resetButton.set_style_bg_color(lv.color_white(), lv.PART.MAIN)
        resetButton.align(lv.ALIGN.BOTTOM_RIGHT, -12, -12)
        resetButton.add_event_cb(reset_button_event_handler, lv.EVENT.CLICKED,
                                 None)

        resetLabel = lv.label(resetButton)
        resetLabel.set_text("REST")
        resetLabel.set_style_text_color(lv.color_black(), 0)
        resetLabel.set_style_text_font(lv.font_montserrat_20, 0)
        resetLabel.center()

        # select time
        col_dsc = [75, 75, 75, 75, lv.GRID_TEMPLATE.LAST]
        row_dsc = [60, 80, 60, lv.GRID_TEMPLATE.LAST]
        funcContainer = lv.obj(win)
        funcContainer.set_layout(lv.LAYOUT_GRID.value)
        funcContainer.set_style_bg_opa(0, 0)
        funcContainer.set_style_border_opa(0, 0)
        funcContainer.set_style_grid_column_dsc_array(col_dsc, 0)
        funcContainer.set_style_grid_row_dsc_array(row_dsc, 0)
        funcContainer.set_grid_align(lv.GRID_ALIGN.SPACE_BETWEEN,
                                     lv.GRID_ALIGN.SPACE_BETWEEN)
        funcContainer.set_size(300, 90)
        funcContainer.set_style_align(lv.ALIGN.TOP_MID, 0)

        maxMillionSecond = timeCount[0] * 60 * 50
        arc[0] = lv.arc(funcContainer)
        arc[0].set_style_arc_color(lv.color_white(), lv.PART.INDICATOR)
        arc[0].set_style_arc_color(lv.color_make(0x33, 0x33, 0x33),
                                   lv.PART.MAIN)
        arc[0].set_range(0, maxMillionSecond)
        arc[0].set_size(55, 55)
        arc[0].set_rotation(90)
        arc[0].set_bg_angles(0, 360)
        arc[0].remove_style(None, lv.PART.KNOB)
        arc[0].set_value(maxMillionSecond)
        arc[0].set_style_arc_width(8, lv.PART.INDICATOR)
        arc[0].set_style_arc_width(8, lv.PART.MAIN)
        arc[0].set_grid_cell(lv.GRID_ALIGN.CENTER, 0, 1, lv.GRID_ALIGN.CENTER,
                             0, 1)
        arc[0].clear_flag(lv.obj.FLAG.CLICKABLE)
        totalTime = lv.label(funcContainer)
        totalTime.set_text(str(timeCount[0]))
        totalTime.set_style_text_font(lv.font_montserrat_18, 0)
        totalTime.set_style_text_color(lv.color_white(), 0)
        totalTime.set_grid_cell(lv.GRID_ALIGN.CENTER, 0, 1,
                                lv.GRID_ALIGN.CENTER, 0, 1)
        totalTime.add_flag(lv.obj.FLAG.CLICKABLE)
        totalTime.add_event_cb(lambda e: arc_event_handler(e, 0),
                               lv.EVENT.CLICKED, None)
        totalTime.set_ext_click_area(30)

        anim[0] = lv.anim_t()
        anim[0].init()
        anim[0].set_var(arc[0])
        anim[0].set_time(maxMillionSecond * 20)
        anim[0].set_values(maxMillionSecond, 0)
        anim[0].set_custom_exec_cb(lambda a1, val: set_time_value(arc[0], val))
        anim_timeline = lv.anim_timeline_create()
        lv.anim_timeline_add(anim_timeline, 0, anim[0])

        arc[1] = lv.arc(funcContainer)
        arc[1].set_style_arc_color(lv.color_white(), lv.PART.INDICATOR)
        arc[1].set_style_arc_color(lv.color_make(0x33, 0x33, 0x33),
                                   lv.PART.MAIN)
        arc[1].set_range(0, maxMillionSecond)
        arc[1].set_size(55, 55)
        arc[1].set_rotation(90)
        arc[1].set_bg_angles(0, 360)
        arc[1].remove_style(None, lv.PART.KNOB)
        arc[1].set_value(0)
        arc[1].set_style_arc_width(2, lv.PART.INDICATOR)
        arc[1].set_style_arc_width(2, lv.PART.MAIN)
        arc[1].set_grid_cell(lv.GRID_ALIGN.CENTER, 1, 1, lv.GRID_ALIGN.CENTER,
                             0, 1)
        arc[1].clear_flag(lv.obj.FLAG.CLICKABLE)
        totalTime = lv.label(funcContainer)
        totalTime.set_text(str(timeCount[1]))
        totalTime.set_style_text_font(lv.font_montserrat_18, 0)
        totalTime.set_style_text_color(lv.color_white(), 0)
        totalTime.set_grid_cell(lv.GRID_ALIGN.CENTER, 1, 1,
                                lv.GRID_ALIGN.CENTER, 0, 1)
        totalTime.add_flag(lv.obj.FLAG.CLICKABLE)
        totalTime.add_event_cb(lambda e: arc_event_handler(e, 1),
                               lv.EVENT.CLICKED, None)
        totalTime.set_ext_click_area(30)

        arc[2] = lv.arc(funcContainer)
        arc[2].set_style_arc_color(lv.color_white(), lv.PART.INDICATOR)
        arc[2].set_style_arc_color(lv.color_make(0x33, 0x33, 0x33),
                                   lv.PART.MAIN)
        arc[2].set_range(0, maxMillionSecond)
        arc[2].set_size(55, 55)
        arc[2].set_rotation(90)
        arc[2].set_bg_angles(0, 360)
        arc[2].remove_style(None, lv.PART.KNOB)
        arc[2].set_value(0)
        arc[2].set_style_arc_width(2, lv.PART.INDICATOR)
        arc[2].set_style_arc_width(2, lv.PART.MAIN)
        arc[2].set_grid_cell(lv.GRID_ALIGN.CENTER, 2, 1, lv.GRID_ALIGN.CENTER,
                             0, 1)
        arc[2].clear_flag(lv.obj.FLAG.CLICKABLE)
        totalTime = lv.label(funcContainer)
        totalTime.set_text(str(timeCount[2]))
        totalTime.set_style_text_font(lv.font_montserrat_18, 0)
        totalTime.set_style_text_color(lv.color_white(), 0)
        totalTime.set_grid_cell(lv.GRID_ALIGN.CENTER, 2, 1,
                                lv.GRID_ALIGN.CENTER, 0, 1)
        totalTime.add_flag(lv.obj.FLAG.CLICKABLE)
        totalTime.add_event_cb(lambda e: arc_event_handler(e, 2),
                               lv.EVENT.CLICKED, None)
        totalTime.set_ext_click_area(30)

        arc[3] = lv.arc(funcContainer)
        arc[3].set_style_arc_color(lv.color_white(), lv.PART.INDICATOR)
        arc[3].set_style_arc_color(lv.color_make(0x33, 0x33, 0x33),
                                   lv.PART.MAIN)
        arc[3].set_range(0, maxMillionSecond)
        arc[3].set_size(55, 55)
        arc[3].set_rotation(90)
        arc[3].set_bg_angles(0, 360)
        arc[3].remove_style(None, lv.PART.KNOB)
        arc[3].set_value(0)
        arc[3].set_style_arc_width(2, lv.PART.INDICATOR)
        arc[3].set_style_arc_width(2, lv.PART.MAIN)
        arc[3].set_grid_cell(lv.GRID_ALIGN.CENTER, 3, 1, lv.GRID_ALIGN.CENTER,
                             0, 1)
        arc[3].clear_flag(lv.obj.FLAG.CLICKABLE)
        totalTime = lv.label(funcContainer)
        totalTime.set_text(str(timeCount[3]))
        totalTime.set_style_text_font(lv.font_montserrat_18, 0)
        totalTime.set_style_text_color(lv.color_white(), 0)
        totalTime.set_grid_cell(lv.GRID_ALIGN.CENTER, 3, 1,
                                lv.GRID_ALIGN.CENTER, 0, 1)
        totalTime.add_flag(lv.obj.FLAG.CLICKABLE)
        totalTime.add_event_cb(lambda e: arc_event_handler(e, 3),
                               lv.EVENT.CLICKED, None)
        totalTime.set_ext_click_area(30)

        from smart_panel import needAnimation
        if (needAnimation):
            lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.MOVE_LEFT, 500, 0, True)
        else:
            lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.NONE, 0, 0, True)

        timer_alive = True
Exemple #8
0
#!/opt/bin/lv_micropython -i
import lvgl as lv
import display_driver
import time

# create an arc
arc = lv.arc(lv.scr_act(), None)
arc.set_end_angle(200)
arc.set_size(150, 150)
arc.align(None, lv.ALIGN.CENTER, 0, 0)
Exemple #9
0
label1 = lv.label(scr)
label2 = lv.label(scr)
label3 = lv.label(scr)
label4 = lv.label(scr)
label5 = lv.label(scr)
label6 = lv.label(scr)
label7 = lv.label(scr)
label8 = lv.label(scr)
label9 = lv.label(scr)
label10 = lv.label(scr)
label11 = lv.label(scr)
label12 = lv.label(scr)
label13 = lv.label(scr)
label14 = lv.label(scr)
#create arc
arc1 = lv.arc(scr)
arc2 = lv.arc(scr)
arc3 = lv.arc(scr)
#set style for label
lv.label.set_style(label1, 0, style1)
lv.label.set_style(label2, 0, style1)
lv.label.set_style(label3, 0, style1)
lv.label.set_style(label4, 0, style1)
lv.label.set_style(label5, 0, style1)
lv.label.set_style(label6, 0, style2)
lv.label.set_style(label7, 0, style2)
lv.label.set_style(label8, 0, style2)
lv.label.set_style(label9, 0, style3)
lv.label.set_style(label10, 0, style4)
lv.label.set_style(label11, 0, style5)
lv.label.set_style(label12, 0, style6)
Exemple #10
0
#!//opt/bin/lv_micropython -i
import time
import lvgl as lv
import display_driver

#
# Using the Arc style properties
#
style = lv.style_t()
style.init()

style.set_arc_color(lv.palette_main(lv.PALETTE.RED))
style.set_arc_width(4)

# Create an object with the new style
obj = lv.arc(lv.scr_act())
obj.add_style(style, 0)
obj.center()