Example #1
0
 def __init__(self, scr=None):
     self.scr = scr if scr else lv.scr_act()
     self.hor_res = self.scr.get_width()
     self.ver_res = self.scr.get_height()
     self.cursor_style = lv.style_t()
     self.cursor_style.set_line_width(lv.STATE.DEFAULT,1)
     self.cursor_style.set_line_dash_gap(lv.STATE.DEFAULT, 5)
     self.cursor_style.set_line_dash_width(lv.STATE.DEFAULT, 1)
     self.cursor_hor = lv.line(self.scr)
     self.cursor_hor.add_style(lv.line.PART.MAIN, self.cursor_style)
     self.cursor_ver = lv.line(self.scr)
     self.cursor_ver.add_style(lv.line.PART.MAIN, self.cursor_style)
Example #2
0
 def __init__(self, scr=None):
     self.scr = scr if scr else lv.scr_act()
     self.hor_res = self.scr.get_width()
     self.ver_res = self.scr.get_height()
     self.cursor_style = lv.style_t()
     self.cursor_style.set_line_width(1)
     self.cursor_style.set_line_dash_gap(5)
     self.cursor_style.set_line_dash_width(1)
     self.cursor_hor = lv.line(self.scr)
     self.cursor_hor.add_style(self.cursor_style, lv.PART.MAIN)
     self.cursor_ver = lv.line(self.scr)
     self.cursor_ver.add_style(self.cursor_style, lv.PART.MAIN)
Example #3
0
def lv_line(screen):
    line_points = [[5,5], [70,70]]
    valid_pos = [lv.point_t(), lv.point_t(), lv.point_t(), lv.point_t(), lv.point_t(), lv.point_t(), lv.point_t()]
    valid_pos[0].x = 0
    valid_pos[0].y = 0
    valid_pos[1].x = 10
    valid_pos[1].y = 0
    valid_pos[2].x = 10
    valid_pos[2].y = 10
    valid_pos[3].x = 0
    valid_pos[3].y = 10
    valid_pos[4].x = 10
    valid_pos[4].y = 10
    valid_pos[5].x = 10
    valid_pos[5].y = 20
    valid_pos[6].x = 0
    valid_pos[6].y = 20

    line_style2 = lv.style_t()
    line_style2.init()
    line_style2.set_line_width(lv.STATE.DEFAULT, 8)
    line_style2.set_line_color(lv.STATE.DEFAULT, styles.LV_COLOR_BLUE)
    line_style2.set_line_rounded(lv.STATE.DEFAULT, True)

    cont_style = lv.style_t()
    cont_style.init()
    cont_style.set_border_opa(lv.STATE.DEFAULT, lv.OPA.TRANSP)
    cont_style.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.TRANSP)
    # cont_style.set_bg_color(lv.STATE.DEFAULT, styles.LV_COLOR_WATCH)

    cont = lv.cont(screen)
    #cont.add_style(cont.PART.MAIN, cont_style)
    cont.set_auto_realign(True)
    cont.set_size(200,65)
    cont.set_pos(20,85)
    #cont.align_origo(None, lv.ALIGN.CENTER, 0, 0)
    cont.set_fit(lv.FIT.NONE)
    # cont.set_layout(lv.LAYOUT.PRETTY_MID)
    cont.set_layout(lv.LAYOUT.ROW_MID)

    line = lv.line(cont)
    points = styles.get_line_pts_from_num(1, size=40)
    line.set_points(points, len(points))
    line.add_style(line.PART.MAIN, line_style2)
    line.align(None, lv.ALIGN.CENTER, 0, 0)

    line2 = lv.line(cont)
    points = styles.get_line_pts_from_num(2, size=40)
    line2.set_points(points, len(points))
    line2.add_style(line2.PART.MAIN, line_style2)
    line2.align(None, lv.ALIGN.CENTER, 0, 0)
Example #4
0
 def draw_melting_dash_line(self, y_point, melting_temp):
     """
     Draw melting temp with dashed line over the chart
     """
     # Container for dashed line
     style_cont = lv.style_t()
     lv.style_copy(style_cont, lv.style_transp)
     dashed_segments = 10
     dashed_cont = lv.cont(self.chart)
     dashed_cont.set_style(lv.line.STYLE.MAIN, style_cont)
     dashed_cont.set_width(GUI.CHART_WIDTH)
     # Draw dashed line
     style_dash_line = lv.style_t()
     lv.style_copy(style_dash_line, lv.style_transp)
     style_dash_line.line.color = lv.color_make(0xFF, 0x68, 0x33)
     style_dash_line.line.width = 3
     dash_width = int(GUI.CHART_WIDTH / (dashed_segments * 2 - 1))
     dashed_points = [
         {'x': 0, 'y': 0},
         {'x': dash_width, 'y': 0}
     ]
     dashed_line0 = lv.line(dashed_cont)
     dashed_line0.set_points(dashed_points, len(dashed_points))
     dashed_line0.set_style(lv.line.STYLE.MAIN, style_dash_line)
     dashed_line0.align(None, lv.ALIGN.IN_LEFT_MID, 0, 0)
     for i in range(dashed_segments - 1):
         dl_name = 'dashed_line' + str(i+1)
         parent_name = 'dashed_line' + str(i)
         locals()[dl_name] = lv.line(dashed_cont, dashed_line0)
         locals()[dl_name].align(None, lv.ALIGN.IN_LEFT_MID, dash_width * (i+1) * 2, 0)
     # Melting temp
     melt_label = lv.label(dashed_cont)
     melt_label.set_recolor(True)
     melt_label.set_text('#FF6833 ' + str(melting_temp) + '#')
     # Put above elements in place
     dashed_cont.align_origo(self.chart, lv.ALIGN.IN_BOTTOM_MID, 0, -y_point)
     melt_label.align(dashed_cont, lv.ALIGN.IN_TOP_LEFT, 8, 12)
     return dashed_cont
 def draw_profile_line(self, points):
     """
     Draw reflow temp profile over the chart per selection
     """
     style_line = lv.style_t()
     lv.style_copy(style_line, lv.style_transp)
     style_line.line.color = lv.color_make(0, 0x80, 0)
     style_line.line.width = 3
     style_line.line.rounded = 1
     style_line.line.opa = lv.OPA._40
     line = lv.line(self.chart)
     line.set_points(points, len(points))  # Set the points
     line.set_style(lv.line.STYLE.MAIN, style_line)
     line.align(self.chart, lv.ALIGN.IN_BOTTOM_MID, 0, 0)
     line.set_y_invert(True)
     return line
# Create an array for the points of the line
line_points = [{
    "x": 5,
    "y": 5
}, {
    "x": 70,
    "y": 70
}, {
    "x": 120,
    "y": 10
}, {
    "x": 180,
    "y": 60
}, {
    "x": 240,
    "y": 10
}]

# Create style
style_line = lv.style_t()
style_line.init()
style_line.set_line_width(8)
style_line.set_line_color(lv.palette_main(lv.PALETTE.BLUE))
style_line.set_line_rounded(True)

# Create a line and apply the new style
line1 = lv.line(lv.scr_act())
line1.set_points(line_points, 5)  # Set the points
line1.add_style(style_line, 0)
line1.center()
#!//opt/bin/lv_micropython -i
import time
import lvgl as lv
import display_driver

#
# Using the line style properties
#

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

style.set_line_color(lv.palette_main(lv.PALETTE.GREY))
style.set_line_width(6)
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}, {"x": 100, "y": 0}]

obj.set_points(p, 3)

obj.center()
Example #8
0
 def __init__(self, parent, points=None):
     # Pass in points as a list of tuples in the form:
     #       points = [(x1,y1),(x2,y2),(x3,y3)...]
     self.lv_obj = lv.line(parent)
     if points:
         self.set_line_points(points)
Example #9
0
# change the above to the path of your lv_micropython -i unix binary
#
import time
#
# initialize lvgl
#
import lvgl as lv
import display_driver
from lv_colors import lv_colors

LV_USE_LINE = 1

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

style.set_line_color(lv.STATE.DEFAULT, lv_colors.GRAY)
style.set_line_width(lv.STATE.DEFAULT, 6)
style.set_line_rounded(lv.STATE.DEFAULT, True)

if LV_USE_LINE:
    # Create an object with the new style
    obj = lv.line(lv.scr_act(), None)
    obj.add_style(lv.line.PART.MAIN, style)

    #static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}};
    p = [{"x": 10, "y": 30}, {"x": 30, "y": 50}, {"x": 100, "y": 0}]

    obj.set_points(p, 3)

    obj.align(None, lv.ALIGN.CENTER, 0, 0)
style_line1.line.width = 8
style_line1.line.rounded = 4
# Create new minute style (thick dark blue)
style_line2 = lv.style_t(style1)
style_line2.line.color = lv.color_make(227, 227, 227)
style_line2.line.width = 6
style_line2.line.rounded = 4
# Create new index style (thick dark blue)
style_line3 = lv.style_t(style1)
style_line3.line.color = lv.color_hex(0xffffff)
style_line3.line.width = 4
style_line3.line.rounded = 2

scr.set_style(style1)
# Copy the previous line and apply the new style
line1 = lv.line(scr)
line1.align(None, lv.ALIGN.CENTER, -20, -100)
line1.set_points(line_points1, len(line_points1))  # Set the points
line1.set_style(lv.line.STYLE.MAIN, style_line1)
# Copy the previous line and apply the new style
line2 = lv.line(scr)
line2.align(None, lv.ALIGN.CENTER, 0, -100)
line2.set_points(line_points2, len(line_points2))  # Set the points
line2.set_style(lv.line.STYLE.MAIN, style_line2)
# Copy the previous line and apply the new style
line3 = lv.line(scr)
line3.align(None, lv.ALIGN.CENTER, 0, -140)
line3.set_points(line_points3, len(line_points3))  # Set the points
line3.set_style(lv.line.STYLE.MAIN, style_line3)
# Copy the previous line and apply the new style
line4 = lv.line(scr)
Example #11
0
def draw_clock_digit(digit,
                     digit_container=None,
                     style=None,
                     start_x=0,
                     start_y=0,
                     width=20,
                     height=40):

    pts = []
    mid_width = int(width / 2)
    mid_height = int(height / 2)
    print('Building digit:', digit, 'at:', start_x, start_y)
    # Zero
    if digit == ':':
        half_mid = int(mid_height / 2)
        pts.append(
            lv.point_t({
                'x': start_x + mid_width,
                'y': start_y + half_mid
            }))
        pts.append(
            lv.point_t({
                'x': start_x + mid_width,
                'y': start_y + mid_height + half_mid
            }))

    elif digit.isdigit():
        num = int(digit)

        if num == 0:
            pts.append(lv.point_t({'x': start_x, 'y': start_y}))
            # Top horizontal -
            pts.append(lv.point_t({'x': start_x + width, 'y': start_y}))

            # Right vertical |
            pts.append(
                lv.point_t({
                    'x': start_x + width,
                    'y': start_y + height
                }))

            # Bottom horizontal _
            pts.append(lv.point_t({'x': start_x, 'y': start_y + height}))

            # Left Vertical |
            pts.append(lv.point_t({'x': start_x, 'y': start_y}))

        elif num == 1:
            pts.append(lv.point_t({'x': start_x + mid_width, 'y': start_y}))
            pts.append(
                lv.point_t({
                    'x': start_x + mid_width,
                    'y': start_y + height
                }))

        elif num == 2:
            pts.append(lv.point_t({'x': start_x, 'y': start_y}))
            # Top horizontal -
            pts.append(lv.point_t({'x': start_x + width, 'y': start_y}))

            # Right upper vertical |
            pts.append(
                lv.point_t({
                    'x': start_x + width,
                    'y': start_y + mid_height
                }))

            # Mid vertical -
            pts.append(lv.point_t({'x': start_x, 'y': start_y + mid_height}))

            # Left lower vertical |
            pts.append(lv.point_t({'x': start_x, 'y': start_y + height}))

            # Bottom horizontal _
            pts.append(
                lv.point_t({
                    'x': start_x + width,
                    'y': start_y + height
                }))

        elif num >= 3:
            pts.append(lv.point_t({'x': start_x, 'y': start_y}))
            # Top horizontal left -
            pts.append(lv.point_t({'x': start_x + width, 'y': start_y}))

            # Right upper vertical down |
            pts.append(
                lv.point_t({
                    'x': start_x + width,
                    'y': start_y + mid_height
                }))

            # Mid vertical left -
            pts.append(lv.point_t({'x': start_x, 'y': start_y + mid_height}))

            # Mid vertical right -
            pts.append(
                lv.point_t({
                    'x': start_x + width,
                    'y': start_y + mid_height
                }))

            # Left lower vertical down |
            pts.append(
                lv.point_t({
                    'x': start_x + width,
                    'y': start_y + height
                }))

            # Bottom horizontal left _
            pts.append(lv.point_t({'x': start_x, 'y': start_y + height}))

    if digit_container is not None:
        digit_line = lv.line(digit_container)
        digit_line.set_points(pts, len(pts))
        if style is not None:
            digit_line.add_style(digit_line.PART.MAIN, style)
        digit_line.align(None, lv.ALIGN.CENTER, 0, 0)

    return pts