Пример #1
0
def widget_new(type, parm = None):
    config = sys.modules['llvgl'].config        
    content = config["win"].get_content()
    lv_obj = None
    if type == TYPE.LABEL:    
        lv_obj = lv.label(content)
    elif type == TYPE.BUTTON:    
        lv_obj = lv.btn(content)
        # buttons don't scale with the content by default
        lv_obj.set_fit(lv.FIT.TIGHT)  # MAX, NONE, PARENT, TIGHT
    elif type == TYPE.SWITCH:    
        lv_obj = lv.switch(content)
    elif type == TYPE.SLIDER:    
        lv_obj = lv.slider(content)
        # sliders default width is too wide for the 240x320 screen
        lv_obj.set_width(180)
    elif type == TYPE.CHECKBOX:    
        lv_obj = lv.checkbox(content)
    elif type == TYPE.LED:    
        lv_obj = lv.led(content)
        # leds default size is a little big for the 240x320 screen
        lv_obj.set_size(30,30)
    elif type == TYPE.GAUGE:    
        lv_obj = lv.gauge(content)
    elif type == TYPE.CHART:
        lv_obj = lv.chart(content)
        # leds default size is a little big for the 240x320 screen
        lv_obj.set_size(180,180)
    elif type == TYPE.DROPDOWN:
        lv_obj = lv.dropdown(content)
    else:
        print("Unknown type:", type);
        return None

    # add new object to internal list
    obj =  { "lv_obj": lv_obj, "type": type }    
    config["objects"].append(obj)

    # set optional parameter if widget support
    if type == TYPE.LABEL or type == TYPE.BUTTON or type == TYPE.CHECKBOX:    
        widget_set_text(obj, parm)
    elif type == TYPE.SWITCH or type == TYPE.LED or type == TYPE.SLIDER:    
        widget_set_value(obj, parm)    
    
    # install default event handler
    lv_obj.set_event_cb(lambda o, e: on_event(obj, e))

    return obj
Пример #2
0
style.body.padding.left = 10  # Scale line length
style.body.padding.inner = 8  # Scale label padding
style.body.border.color = lv.color_hex3(0x333)  # Needle middle circle color
style.line.width = 3
style.text.color = lv.color_hex3(0x333)
style.line.color = lv.color_hex3(0xF00)  # Line color after the critical value

# Describe the color for the needles
needle_colors = [
    lv.color_make(0x00, 0x00, 0xFF),
    lv.color_make(0xFF, 0xA5, 0x00),
    lv.color_make(0x80, 0x00, 0x80)
]

# Create a gauge
gauge1 = lv.gauge(lv.scr_act())
gauge1.set_style(lv.gauge.STYLE.MAIN, style)
gauge1.set_needle_count(len(needle_colors), needle_colors)
gauge1.set_size(150, 150)
gauge1.align(None, lv.ALIGN.CENTER, 0, 20)

# Set the values
gauge1.set_value(0, 10)
gauge1.set_value(1, 20)
gauge1.set_value(2, 30)

# **********************************
#   End your codes here.
# **********************************

Пример #3
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)
Пример #4
0
from lv_colors import lv_colors

LV_USE_GAUGE = 1
style = lv.style_t()
style.init()

# Set a background color and a radius
style.set_radius(lv.STATE.DEFAULT, 5)
style.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER)
style.set_bg_color(lv.STATE.DEFAULT, lv_colors.SILVER)

# Set some paddings
style.set_pad_inner(lv.STATE.DEFAULT, 20)
style.set_pad_top(lv.STATE.DEFAULT, 20)
style.set_pad_left(lv.STATE.DEFAULT, 5)
style.set_pad_right(lv.STATE.DEFAULT, 5)

style.set_scale_end_color(lv.STATE.DEFAULT, lv_colors.RED)
style.set_line_color(lv.STATE.DEFAULT, lv_colors.WHITE)
style.set_scale_grad_color(lv.STATE.DEFAULT, lv_colors.BLUE)
style.set_line_width(lv.STATE.DEFAULT, 2)
style.set_scale_end_line_width(lv.STATE.DEFAULT, 4)
style.set_scale_end_border_width(lv.STATE.DEFAULT, 4)

# Gauge has a needle but for simplicity its style is not initialized here
if LV_USE_GAUGE:
    # Create an object with the new style*/
    obj = lv.gauge(lv.scr_act(), None)
    obj.add_style(lv.gauge.PART.MAIN, style)
    obj.align(None, lv.ALIGN.CENTER, 0, 0)
Пример #5
0
def m4():

    position = 0

    scr = lv.obj()
    lv.scr_load(scr)

    #container for drop and switch
    cont = lv.cont(scr)
    cont.set_auto_realign(True)
    cont.set_fit2(lv.FIT.PARENT, lv.FIT.TIGHT)
    cont.set_layout(lv.LAYOUT.PRETTY_MID)
    cont.align(scr, lv.ALIGN.IN_TOP_MID, 0, 0)
    cont.set_style_local_radius(0, 0, 0)

    #dropdown - event

    def drop_event(obj, event):

        if event == lv.EVENT.VALUE_CHANGED:

            position = drop.get_selected()
            print("changing trigger position to {}".format(str(position)))
            m4_1(position)  #call to refresh roller position

    #dropdown
    drop = lv.dropdown(cont)
    drop.set_style_local_border_post(lv.BORDER_SIDE.NONE, lv.BORDER_SIDE.NONE,
                                     lv.BORDER_SIDE.NONE)
    drop.set_options(
        "Trigger 1\nTrigger 2\nTrigger 3\nTrigger 4\nTrigger 5\nTrigger 6\nTrigger 7\nTrigger 8\nTrigger 9\n Trigger 10"
    )
    drop.set_event_cb(drop_event)

    #tabview

    tab = lv.tabview(scr)
    tab.align(cont, lv.ALIGN.OUT_BOTTOM_MID, 0, 0)

    tab1 = tab.add_tab("Time")
    tab2 = tab.add_tab("Auto")
    tab3 = tab.add_tab("Switches")
    tab4 = tab.add_tab("Desc")

    ####Tab 1

    #label
    lbl1 = lv.label(cont)
    lbl1.set_text("Arm?")

    #switch
    switch = lv.switch(cont)

    lbl2 = lv.label(tab1)
    lbl2.set_text("Set time to begin trigger :")

    lbl2.align(tab1, lv.ALIGN.IN_TOP_MID, 0, 10)

    #contain - sort vert
    cont2 = lv.cont(tab1)
    cont2.align(lbl2, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)
    cont2.set_auto_realign(True)
    cont2.set_layout(lv.LAYOUT.ROW_MID)
    cont2.set_fit(lv.FIT.TIGHT)

    roller_hour = lv.roller(cont2)
    roller_hour.set_options(
        "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23",
        lv.roller.MODE.NORMAL)
    roller_minute = lv.roller(cont2)
    roller_minute.set_options(
        "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59",
        lv.roller.MODE.NORMAL)
    roller_sec = lv.roller(cont2)
    roller_sec.set_options(
        "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59",
        lv.roller.MODE.NORMAL)

    btn = lv.btn(cont2)
    lbl_btn = lv.label(btn)
    lbl_btn.set_text("SET")

    #duration

    lbl3 = lv.label(tab1)
    lbl3.set_text("Set duration for trigger : ")
    lbl3.align(cont2, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)

    cont3 = lv.cont(tab1)
    cont3.align(lbl3, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)
    cont3.set_auto_realign(True)
    cont3.set_layout(lv.LAYOUT.ROW_MID)
    cont3.set_fit(lv.FIT.TIGHT)

    roller_hour_dur = lv.roller(cont3)
    roller_hour_dur.set_options(
        "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23",
        lv.roller.MODE.NORMAL)
    roller_minute_dur = lv.roller(cont3)
    roller_minute_dur.set_options(
        "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59",
        lv.roller.MODE.NORMAL)
    roller_sec_dur = lv.roller(cont3)
    roller_sec_dur.set_options(
        "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59",
        lv.roller.MODE.NORMAL)

    #button (set timer) - event

    def btn_event(obj, event):

        if obj == btn and event == lv.EVENT.CLICKED:

            position = drop.get_selected()

            trigger[position].bhour = roller_hour.get_selected()
            trigger[position].bminute = roller_minute.get_selected()
            trigger[position].bsecond = roller_sec.get_selected()

            print("btn - event : position {}, bhour {}, bminute {}, bsec{}".
                  format(str(position), str(roller_hour.get_selected()),
                         str(roller_minute.get_selected()),
                         str(roller_sec.get_selected())))

        if obj == btn2 and event == lv.EVENT.CLICKED:

            position = drop.get_selected()

            trigger[position].hourdur = roller_hour_dur.get_selected()
            trigger[position].minutedur = roller_minute_dur.get_selected()
            trigger[position].seconddur = roller_sec_dur.get_selected()

            print("btn2 - event")

        if obj == switch and event == lv.EVENT.VALUE_CHANGED:

            position = drop.get_selected()
            trigger[position].isArmed = switch.get_state()

            print("Arming trigger {}".format(switch.get_state()))

        if obj == btn_t4_1 and event == lv.EVENT.CLICKED:
            m5()

    btn2 = lv.btn(cont3)
    lbl_btn2 = lv.label(btn2)
    lbl_btn2.set_text("SET")

    #button event call
    btn.set_event_cb(btn_event)
    btn2.set_event_cb(btn_event)
    switch.set_event_cb(btn_event)

    def m4_1(_position):  #run after dropdown selected or pos 0 default

        position = _position
        print("M4_1() calling position {}".format(position))

        roller_hour.set_selected(trigger[position].bhour, lv.ANIM.ON)
        roller_minute.set_selected(trigger[position].bminute, lv.ANIM.ON)
        roller_sec.set_selected(trigger[position].bsecond, lv.ANIM.ON)

        roller_hour_dur.set_selected(trigger[position].hourdur, lv.ANIM.ON)
        roller_minute_dur.set_selected(trigger[position].minutedur, lv.ANIM.ON)
        roller_sec_dur.set_selected(trigger[position].seconddur, lv.ANIM.ON)

        #set proper state of switch

        if switch.get_state() != trigger[position].isArmed:
            switch.toggle(lv.ANIM.ON)

    m4_1(position)

    #####Tab 2 - Automation

    tab2.set_height(320)

    lbl_t2 = lv.label(tab2)
    lbl_t2.align(tab1, lv.ALIGN.IN_TOP_MID, 210, 10)
    lbl_t2.set_text("Automatic trigger disable settings")

    cont3 = lv.cont(tab2)
    cont3.set_auto_realign(True)
    cont3.set_layout(lv.LAYOUT.PRETTY_MID)
    cont3.align(lbl_t2, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)
    cont3.set_fit2(lv.FIT.TIGHT, lv.FIT.TIGHT)

    lbl_t2_2 = lv.label(cont3)
    lbl_t2_2.set_text("Enable Flow Sensor")

    switch_t2_1 = lv.switch(cont3)

    lbl_t2_3 = lv.label(cont3)
    lbl_t2_3.set_text("Enable Rain Sensor")

    switch_t2_2 = lv.switch(cont3)

    lbl_t2_4 = lv.label(cont3)
    lbl_t2_4.set_text("Enable MET weather API")

    switch_t2_3 = lv.switch(cont3)

    lbl_t2_5 = lv.label(cont3)
    lbl_t2_5.set_text("Enable Soil Sensor")

    switch_t2_4 = lv.switch(cont3)

    gauge_t2 = lv.gauge(tab2)
    gauge_t2.align(cont3, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)

    ####Tab 3 - Switches

    tab3.set_height(320)
    lbl_t3 = lv.label(tab3)
    lbl_t3.align(tab3, lv.ALIGN.IN_TOP_MID, -80, 10)
    lbl_t3.set_text("Assign Pin to be triggered")

    #page4 = lv.page(tab3)
    #page4.set_auto_realign(True)
    #page4.align(lbl_t3, lv.ALIGN.OUT_BOTTOM_MID,0,10)
    #page4.set_size(290,800)

    btnmtx_t3 = lv.btnmatrix(tab3)
    btnmtx_t3.align(lbl_t3, lv.ALIGN.OUT_BOTTOM_MID, 0, 0)
    btnmtx_t3.set_width(250)
    btnmtx_t3.set_height(600)

    btn_map_t3 = [
        "3.3v", "GND", "\n", "EN", "23", "\n", "36", "22", "\n", "39", "01",
        "\n", "34", "03", "\n", "35", "21", "\n", "32", "GND", "\n", "33",
        "19", "\n", "25", "18", "\n", "26", "05", "\n", "27", "17", "\n", "14",
        "16", "\n", "12", "04", "\n", "GND", "00", "\n", "13", "02", "\n",
        "09", "15", "\n", "10", "08", "\n", "11", "07", "\n", "VIN", "06", ""
    ]

    btnmtx_t3.set_map(btn_map_t3)
    btnmtx_t3.set_btn_ctrl_all(btnmtx_t3.CTRL.CHECKABLE)

    btn_t3_save = lv.btn(tab3)
    btn_t3_save.align(btnmtx_t3, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)
    lbl_btn_t3_save = lv.label(btn_t3_save)
    lbl_btn_t3_save.set_text("Save Toggles")

    #### Tab 4 Description

    btn_t4_1 = lv.btn(tab4)
    btn_t4_1.align(tab4, lv.ALIGN.CENTER, 0, 0)
    btn_t4_1.set_event_cb(btn_event)
    lbl_btn_t4_1 = lv.label(btn_t4_1)
    lbl_btn_t4_1.set_text(lv.SYMBOL.HOME)
    def __init__(self):
        scr = lv.obj()

        #############################create a gauge#################################
        # Create a style
        style = lv.style_t()
        lv.style_copy(style, lv.style_pretty_color)
        style.body.main_color = lv.color_hex3(
            0x666)  # Line color at the beginning
        style.body.grad_color = lv.color_hex3(0x666)  # Line color at the end
        style.body.padding.left = 10  # Scale line length
        style.body.padding.inner = 8  # Scale label padding
        style.body.border.color = lv.color_hex3(
            0x333)  # Needle middle circle color
        style.line.width = 3
        style.text.color = lv.color_hex3(0x333)
        style.line.color = lv.color_hex3(
            0xF00)  # Line color after the critical value

        # Describe the color for the needles
        needle_colors = [
            lv.color_make(0x00, 0x00, 0xFF),
            lv.color_make(0xFF, 0xA5, 0x00),
            lv.color_make(0x80, 0x00, 0x80)
        ]

        # Create a gauge
        gauge1 = lv.gauge(scr)
        gauge1.set_style(lv.gauge.STYLE.MAIN, style)
        gauge1.set_needle_count(len(needle_colors), needle_colors)
        gauge1.set_size(200, 200)
        gauge1.align(None, lv.ALIGN.CENTER, 0, -50)

        # Set the values
        gauge1.set_value(0, 10)
        gauge1.set_value(1, 20)
        gauge1.set_value(2, 30)

        #################################explanation of needle############################
        # Create a style for the LED

        #color for LED 1
        style_led1 = lv.style_t()
        lv.style_copy(style_led1, lv.style_pretty_color)
        style_led1.body.radius = 800  # large enough to draw a circle
        style_led1.body.main_color = lv.color_make(0x00, 0x00, 0xFF)
        style_led1.body.border.width = 3
        style_led1.body.border.opa = lv.OPA._30
        style_led1.body.shadow.width = 5

        # Create a LED 1
        led1 = lv.led(scr)
        led1.set_style(lv.led.STYLE.MAIN, style_led1)
        led1.align(None, lv.ALIGN.CENTER, -40, 40)
        led1.on()

        btnLED1 = lv.btn(scr)
        btnLED1.align(lv.scr_act(), lv.ALIGN.CENTER, 30, 60)
        btnLED1.set_size(70, 30)
        labelLED1 = lv.label(btnLED1)
        labelLED1.set_text("Battery")

        #color for LED 2
        style_led2 = lv.style_t()
        lv.style_copy(style_led2, lv.style_pretty_color)
        style_led2.body.radius = 800  # large enough to draw a circle
        style_led2.body.main_color = lv.color_make(0xFF, 0xA5, 0x00)
        style_led2.body.border.width = 3
        style_led2.body.border.opa = lv.OPA._30
        style_led2.body.shadow.width = 5

        # Create a LED 2
        led2 = lv.led(scr)
        led2.set_style(lv.led.STYLE.MAIN, style_led2)
        led2.align(None, lv.ALIGN.CENTER, -40, 85)
        led2.on()

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

        btnLED2 = lv.btn(scr)
        btnLED2.align(lv.scr_act(), lv.ALIGN.CENTER, 30, 105)
        btnLED2.set_size(70, 30)
        labelLED2 = lv.label(btnLED2)
        labelLED2.set_text("Memory")
        btnLED2.set_event_cb(event_handler)
        #color for LED 3
        style_led3 = lv.style_t()
        lv.style_copy(style_led3, lv.style_pretty_color)
        style_led3.body.radius = 800  # large enough to draw a circle
        style_led3.body.main_color = lv.color_make(0x80, 0x00, 0x80)
        style_led3.body.border.width = 3
        style_led3.body.border.opa = lv.OPA._30
        style_led3.body.shadow.width = 5

        # Create a LED 3
        led3 = lv.led(scr)
        led3.set_style(lv.led.STYLE.MAIN, style_led3)
        led3.align(None, lv.ALIGN.CENTER, -40, 130)
        led3.on()

        btnLED3 = lv.btn(scr)
        btnLED3.align(lv.scr_act(), lv.ALIGN.CENTER, 30, 150)
        btnLED3.set_size(70, 30)
        labelLED3 = lv.label(btnLED3)
        labelLED3.set_text("RAM")

        lv.scr_load(scr)