@@ -16,9 +16,12 @@ void PageIndicator::Create() {
1616 lv_obj_set_style_local_line_width (pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3 );
1717 lv_obj_set_style_local_line_color (pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
1818 lv_line_set_points (pageIndicatorBase, pageIndicatorBasePoints, 2 );
19+ SetPageIndicatorPosition (nCurrentScreen);
20+ }
1921
22+ void PageIndicator::SetPageIndicatorPosition (uint8_t position) {
2023 const int16_t indicatorSize = LV_VER_RES / nScreens;
21- const int16_t indicatorPos = indicatorSize * nCurrentScreen ;
24+ const int16_t indicatorPos = indicatorSize * position ;
2225
2326 pageIndicatorPoints[0 ].x = LV_HOR_RES - 1 ;
2427 pageIndicatorPoints[0 ].y = indicatorPos;
@@ -31,13 +34,7 @@ void PageIndicator::Create() {
3134 lv_line_set_points (pageIndicator, pageIndicatorPoints, 2 );
3235}
3336
34- void PageIndicator::Delete () {
35- lv_obj_del (pageIndicatorBase);
36- lv_obj_del (pageIndicator);
37- }
38-
3937void PageIndicator::SetCurrentScreen (uint8_t nScreen) {
40- Delete ();
41- nCurrentScreen = nScreen;
42- Create ();
38+ lv_obj_del (pageIndicator);
39+ SetPageIndicatorPosition (nScreen);
4340}
0 commit comments