Attempting to create a simple scale using ver 9.2 with Arduino Giga Shield.
Goal is simple bar with different colors for different sections of the bar.
Similar to Scale Example 2 in the widget examples.
I can have success with the mode set to VERTCIAL MODE… and can create multiple sections with different styles including line width, color, etc.
But if I take the same code and change the mode to HORIZONTAL_MORE… I lose the sytle for the sections wrt the LC_PART_MAIN - the main line style. Ar at least it no longer shows.
Here is the code that does not show the section style correctly: If you change the mode to “VERTICAL…” it works properly.
#include “Arduino_H7_Video.h”
#include “Arduino_GigaDisplayTouch.h”
#include “lvgl.h”
Arduino_H7_Video Display(800, 480, GigaDisplayShield); /* Arduino_H7_Video Display(1024, 768, USBCVideo); /
Arduino_GigaDisplayTouch TouchDetector;
/*
- A simple horizontal scale - just a bar really
*/
void setup() {
Display.begin();
TouchDetector.begin();
lv_obj_t* screen = lv_obj_create(lv_scr_act());
lv_obj_set_size(screen, Display.width(), Display.height());
lv_obj_t* scale = lv_scale_create(lv_screen_active());
lv_obj_set_size(scale, 300, 200);
lv_scale_set_label_show(scale, false);
lv_scale_set_mode(scale, LV_SCALE_MODE_HORIZONTAL_BOTTOM);
lv_obj_center(scale);
lv_scale_set_total_tick_count(scale, 21);
lv_scale_set_major_tick_every(scale, 5);
lv_scale_set_range(scale, 0, 100);
static lv_style_t main_line_style;
lv_style_init(&main_line_style);
/* Main line properties */
lv_style_set_line_color(&main_line_style, lv_palette_main(LV_PALETTE_GREEN));
lv_style_set_line_width(&main_line_style, 40); // main line width
lv_obj_add_style(scale, &main_line_style, LV_PART_MAIN);
/* Add a section */
static lv_style_t section_main_line_style;
lv_style_init(§ion_main_line_style);
/* Main line properties */
lv_style_set_line_color(§ion_main_line_style, lv_palette_main(LV_PALETTE_RED));
lv_style_set_line_width(§ion_main_line_style, 40); /main line width in section/
/* Configure section styles /
lv_scale_section_t section = lv_scale_add_section(scale);
lv_scale_section_set_range(section, 75, 100);
lv_scale_section_set_style(section, LV_PART_MAIN, §ion_main_line_style);
}
void loop() {
lv_timer_handler();
}
Any suggestions, help much appreciated.