January 3, 2021, 10:47pm
I am using lv gauge and would like to disable the critical color. Setting the critical value to max+1 doesn’t help.
lv_gauge_set_range(lv_guage, min, max);
What MCU/Processor/Board and compiler are you using?
What LVGL version are you using?
#define LVGL_VERSION_MAJOR 7
#define LVGL_VERSION_MINOR 5
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO “dev” What do you want to achieve?
Eliminate the different color on the last major tick. (see screenshot in image below)
What have you tried so far?
Setting critical value to max + 1;
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
/*You code here*/
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.
Looks like a bug to me… I think setting the critical value to
max has to be allowed, otherwise there is no way of disabling it without changing styles.
@kisvegabor Can you take a look at this?
In the meantime, you can use this workaround when creating the gauge:
lv_obj_set_style_local_scale_end_color(lv_guage, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex3(0x888));
lv_obj_set_style_local_scale_end_color(lv_guage, LV_GAUGE_PART_MAJOR, LV_STATE_DEFAULT, lv_color_hex3(0x888));
January 4, 2021, 2:02am
@embeddedt. A side question if I may, how the color and other look and feel parameters of the critical range of a gauge are set?
The documentation mentions a few gauge ‘parts’ but none of them seem to be related to the ‘critical’ section of scale. (I tried to include here a link to the lvgl official Gauge documentation but this forum tool doesn’t let me. That’s strange. Please search for it yourself).
(If i can set it to match the color and line width of the rest of the gauge’s scale, I can make it ‘disappears’, as a workaround).
The style properties relating to the gauge are here and there is an example of how to use them:
January 4, 2021, 3:08am
@embeddedt. I read your posts again. I think I have all the information to make the end/critical region tick look like the normal one. Will try and will report here.
January 4, 2021, 6:01am
Adding this to the gauge’s initialization hid the problem and gauges look now as intended. Thanks. I had to reduce the major ticks to 5 to match my gauge’s style.
I couldn’t figure out a way to do the same via one of the gauge’s styles rather than having to set it ‘locally’ per instance.
It’s mostly just changing the
lv_style_set. Remove the part from the individual property set calls, as style objects don’t have a part associated with them. Then, call
lv_obj_add_style(gauge, LV_GAUGE_PART_MAJOR, &style);.