Line meter material style broken in v7

Description

After updating to v7 the default style for a linemeter doesn’t match the expectation set by the docs.

What MCU/Processor/Board and compiler are you using?

Unix Micropython port

What do you experience?

Style like this (ignore label):
Screen Shot 2020-07-08 at 4.02.04 PM

In a previous version (before recent v7 merge of lv_micropython master), the default linemeter widget style reflected what is shown in the docs. After the merge, the style appears to be missing the theme defaults. I started looking through the underlying changes and noticed references to LV_DPX, which do not seem to be exposed to in lv_micropython, making an “easy fix” un-obvious to me.

What do you expect?

Style as shown @docs.lvgl.io/v7/en/html/widgets/linemeter.html#simple-line-meter

Code to reproduce

lmeter = lv.linemeter(lv.scr_act())
lmeter.set_range(0, 100)
lmeter.set_value(80)
lmeter.set_scale(240, 21)
lmeter.set_size(150, 150)
lmeter.align(None, lv.ALIGN.CENTER, 0, 0)

(Additional) code to workaround / fix:

# Highlighted meter line segments
lmeter.set_style_local_line_width(lmeter.PART.MAIN, lv.STATE.DEFAULT, 4)

# Unhighlighted meter line segments
lmeter.set_style_local_scale_end_line_width(lmeter.PART.MAIN, lv.STATE.DEFAULT, 3)

# Meter line segment length
lmeter.set_style_local_scale_width(lmeter.PART.MAIN, lv.STATE.DEFAULT, 10)

# Line segment offset from outer radius?
pad = 1
lmeter.set_style_local_pad_top(lmeter.PART.MAIN, lv.STATE.DEFAULT, pad)
lmeter.set_style_local_pad_left(lmeter.PART.MAIN, lv.STATE.DEFAULT, pad)
lmeter.set_style_local_pad_right(lmeter.PART.MAIN, lv.STATE.DEFAULT, pad)

Screenshot and/or video

See above.

Actually LV_DPX is available on Micropython on latest master branch.
Here is a usage example.

Here is the result of your script on the online simulator, without the “additional code to workaround / fix”:

image

Could you try again on latest version of lv_micropython master branch?

Ah, yes, it seems I missed lv.dpx - thank you for pointing this out.

At the risk of diverting the conversation, as of this writing I’m unable to build lv_micropython on master, which is not the case on the release/v7 branch. I’m running on Mac 10.13 (darwin 17.7.0) with system clang 9.0.0. Using the branch I am able to build, I get the result originally shown above, rather than the one the simulator is showing.

The master branch is supposed to be stable.
Could you share the build problem you are experiencing?

Sure, see the message below after running make -C ports/unix. I did make sure to verify this was only true after switching branches (by running a fresh build on either side of the switch) and re-running git submodules update --recursive:

LVGL-GEN build-standard/lvgl/lv_mpy.c
GEN build-standard/genhdr/mpversion.h
GEN build-standard/genhdr/moduledefs.h
GEN build-standard/genhdr/qstr.i.last
In file included from ../../lib/lv_bindings/driver/SDL/modSDL.c:8:
In file included from ../../lib/lv_bindings/driver/SDL/SDL_monitor.h:19:
In file included from ../../lib/lv_bindings/driver/SDL/lv_drv_conf.h:14:
In file included from ../../lib/lv_bindings/../../lib/lv_bindings/lvgl/lvgl.h:35:
In file included from ../../lib/lv_bindings/../../lib/lv_bindings/lvgl/src/lv_misc/lv_printf.h:61:
/usr/include/stdio.h:299:50: error: invalid token at start of a preprocessor expression
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
                                                 ^
1 error generated.

This could be related to this commit: https://github.com/lvgl/lv_binding_micropython/commit/65acfe607c950e8119f57b075144e33e39ad4a7c

As a workaround, try to comment out #define _POSIX_C_SOURCE in driver/SDL/modSDL.c.

@embeddedt - maybe this define should be inside #ifdef __EMSCRIPTEN__, I’m not sure what was its purpose.

Yes, it looks like that fixes the build for me. I still see the line meter style differs from the simulator though.

Here are a couple possible red herrings I see during the build:

CC ../../lib/lv_bindings/lvgl/src/lv_themes/lv_theme_material.c
../../lib/lv_bindings/lvgl/src/lv_themes/lv_theme_material.c:316:60: warning: comparison of constant
      50 with expression of type 'lv_disp_size_t' is always true
      [-Wtautological-constant-out-of-range-compare]
                           lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? LV_DPX(...
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~
../../lib/lv_bindings/lvgl/src/lv_themes/lv_theme_material.c:319:70: warning: comparison of constant
      50 with expression of type 'lv_disp_size_t' is always true
      [-Wtautological-constant-out-of-range-compare]
    lv_style_int_t pad_small_value = lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? L...
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

That’s strange.
You say you ran git submodules update --recursive and rebuilt lv_micropython, right?
Just to make sure, could you cd to lib/lv_bindings/lvgl and run git log -1?
I would expect the commit hash to be 416ef9e251d39dba291b86eab9ad7c1a22ff2e8d

You can also try to git pull on lib/lv_bindings/lvgl to get latest (master) version of lvgl, there seem to be some updates specifically for line meter, although I don’t think they are relevant to this problem.

I don’t think these are related to this problem, but LVGL maintainers should probably get aware of this.

@kisvegabor / @embeddedt maybe worth running clang on the CI with -Wall to identify problems that are not reported by gcc.

Yep, I’ve been making sure to re-run git submodules update --recursive each time.

Here’s what that gives me:

commit 416ef9e251d39dba291b86eab9ad7c1a22ff2e8d (HEAD)
Author: Gabor Kiss-Vamosi <REDACTED@gmail.com>
Date:   Thu Jul 9 14:41:24 2020 +0200

    fix chart series area invalidation

Just for kicks I did:

repos/lv_micropython/lib/lv_bindings/lvgl $ git checkout origin/master

and got this:

Previous HEAD position was 416ef9e2... fix chart series area invalidation
HEAD is now at 43a77d86... linemeter: fix arc drawing if the value is close to max value

I then proceeded with the build from there, with the same result.

It’s a required feature test macro for sigaction to be defined. It should work on all platforms with this fix.

@kdunn926 I really don’t know why you are seeing a difference in line meter style between the simulator and Mac.
When I build it on Linux I don’t experience this problem. The Micropython Unix port built on Linux yields the same results as the web simulator.

The only thing I can think of is some environment problem on Mac, partial build, or lv_conf.h which is not up to date.

Could you try cloning a fresh lv_micropython repo and try again?
Do you have access to a Linux machine where you can try to reproduce the problem and compare the results?

Another thing you can try is building an lvgl C application with the same lvgl submodule and see if this problem persists, to see if this problem is related to Micropython or to LVGL core.

1 Like

@amirgon, I did a fresh checkout and built with the same result. I was able to use the “PC simulator” lv_sim_eclipse_sdl to run lv_ex_linemeter_1(); and the style is correct under that configuration.