9
9
*
10
10
* Requires BlueDisplay library.
11
11
*
12
- * Copyright (C) 2016-2022 Armin Joachimsmeyer
12
+ * Copyright (C) 2016-2025 Armin Joachimsmeyer
13
13
14
14
*
15
15
* This file is part of Arduino-RobotCar https://github.com/ArminJo/Arduino-RobotCar.
@@ -57,7 +57,7 @@ uint8_t sRobotCarDirection = DIRECTION_FORWARD; // DIRECTION_FORWARD or DIRECTIO
57
57
BDButton TouchButtonInfo;
58
58
59
59
BDSlider SliderSpeed;
60
- uint16_t sLastSpeedSliderValue = 0 ; // local storage for requested speed by speed slider
60
+ int16_t sLastSpeedSliderValue = 0 ; // local storage for requested speed by speed slider
61
61
62
62
BDSlider SliderSpeedRight;
63
63
BDSlider SliderSpeedLeft;
@@ -170,7 +170,7 @@ void readAndShowDistancePeriodically() {
170
170
#endif // defined(CAR_HAS_DISTANCE_SENSOR)
171
171
172
172
#if defined(CAR_HAS_DISTANCE_SERVO)
173
- void doUSServoPosition (BDSlider *aTheTouchedSlider, uint16_t aValue) {
173
+ void doUSServoPosition (BDSlider *aTheTouchedSlider, int16_t aValue) {
174
174
(void ) aTheTouchedSlider; // for the compiler to be happy
175
175
DistanceServoWriteAndWaitForStop (aValue);
176
176
}
@@ -300,7 +300,7 @@ void doCalibrate(BDButton *aTheTouchedButton, int16_t aValue) {
300
300
* Minimum Speed is 30 for USB power and no load, 50 for load
301
301
* Minimum Speed is 20 for 2 Lithium 18650 battery power and no load, 25 for load
302
302
*/
303
- void doSpeedSlider (BDSlider *aTheTouchedSlider, uint16_t aValue) {
303
+ void doSpeedSlider (BDSlider *aTheTouchedSlider, int16_t aValue) {
304
304
if (aValue != sLastSpeedSliderValue ) {
305
305
sLastSpeedSliderValue = aValue;
306
306
@@ -481,16 +481,15 @@ void initCommonGui() {
481
481
*/
482
482
SliderSpeed.init (0 , SLIDER_TOP_MARGIN, BUTTON_WIDTH_6, SPEED_SLIDER_SIZE, 200 , 0 , COLOR16_YELLOW, SLIDER_DEFAULT_BAR_COLOR,
483
483
FLAG_SLIDER_SHOW_VALUE, &doSpeedSlider);
484
- SliderSpeed.setScaleFactor ( 255.0 / SPEED_SLIDER_SIZE ); // Slider is virtually 2 times larger than displayed, values were divided by 2
484
+ SliderSpeed.setMinMaxValue ( 0 , 255 ); // Slider is virtually 2 times larger than displayed, values were divided by 2
485
485
486
486
SliderSpeedLeft.init (MOTOR_INFO_START_X, 0 , BUTTON_WIDTH_16, SPEED_SLIDER_SIZE / 2 , SPEED_SLIDER_SIZE / 2 - 1 , 0 ,
487
- SLIDER_DEFAULT_BACKGROUND_COLOR, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT,
488
- nullptr );
487
+ SLIDER_DEFAULT_BACKGROUND_COLOR, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT);
489
488
SliderSpeedLeft.setValueFormatString (" %3d" ); // Since we also send values grater 100
490
489
491
490
SliderSpeedRight.init (MOTOR_INFO_START_X + BUTTON_WIDTH_16 + 8 , 0 , BUTTON_WIDTH_16, SPEED_SLIDER_SIZE / 2 ,
492
491
SPEED_SLIDER_SIZE / 2 - 1 , 0 , SLIDER_DEFAULT_BACKGROUND_COLOR, SLIDER_DEFAULT_BAR_COLOR,
493
- FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT, nullptr );
492
+ FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT);
494
493
SliderSpeedRight.setValueFormatString (" %3d" );
495
494
496
495
#if defined(CAR_HAS_DISTANCE_SENSOR)
@@ -520,7 +519,7 @@ void initCommonGui() {
520
519
SliderDistanceServoPosition.init (POS_X_DISTANCE_POSITION_SLIDER - BUTTON_WIDTH_6, SLIDER_TOP_MARGIN, BUTTON_WIDTH_6,
521
520
US_SLIDER_SIZE, 90 , 90 , COLOR16_YELLOW, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE, &doUSServoPosition);
522
521
SliderDistanceServoPosition.setBarThresholdColor (COLOR16_BLUE);
523
- SliderDistanceServoPosition.setScaleFactor ( 180.0 / US_SLIDER_SIZE ); // Values from 0 to 180 degrees
522
+ SliderDistanceServoPosition.setMinMaxValue ( 0 , 180 ); // Values from 0 to 180 degrees
524
523
SliderDistanceServoPosition.setValueUnitString (" \xB0 " ); // \xB0 is degree character
525
524
#endif
526
525
@@ -535,7 +534,7 @@ void initCommonGui() {
535
534
SliderUSDistance.init (POS_X_US_DISTANCE_SLIDER - ((BUTTON_WIDTH_10 / 2 ) - 2 ), SLIDER_TOP_MARGIN + BUTTON_HEIGHT_8,
536
535
(BUTTON_WIDTH_10 / 2 ) - 2 , DISTANCE_SLIDER_SIZE,
537
536
FOLLOWER_DISPLAY_DISTANCE_TIMEOUT_CENTIMETER / DISTANCE_SLIDER_SCALE_FACTOR, 0 , SLIDER_DEFAULT_BACKGROUND_COLOR,
538
- SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT, nullptr );
537
+ SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT);
539
538
SliderUSDistance.setCaptionProperties (TEXT_SIZE_10, FLAG_SLIDER_VALUE_CAPTION_ALIGN_LEFT | FLAG_SLIDER_VALUE_CAPTION_BELOW, 2 ,
540
539
COLOR16_BLACK, COLOR16_WHITE);
541
540
SliderUSDistance.setCaption (" US" );
@@ -546,8 +545,7 @@ void initCommonGui() {
546
545
// Big US distance slider without caption but with cm units POS_X_THIRD_SLIDER because it is the position of the left edge
547
546
SliderUSDistance.init (POS_X_US_DISTANCE_SLIDER - BUTTON_WIDTH_10, SLIDER_TOP_MARGIN + BUTTON_HEIGHT_8, BUTTON_WIDTH_10,
548
547
DISTANCE_SLIDER_SIZE, FOLLOWER_DISPLAY_DISTANCE_TIMEOUT_CENTIMETER / DISTANCE_SLIDER_SCALE_FACTOR, 0 ,
549
- SLIDER_DEFAULT_BACKGROUND_COLOR, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT,
550
- nullptr );
548
+ SLIDER_DEFAULT_BACKGROUND_COLOR, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT);
551
549
SliderUSDistance.setValueUnitString (" cm" );
552
550
#endif
553
551
SliderUSDistance.setScaleFactor (DISTANCE_SLIDER_SCALE_FACTOR); // Slider is virtually 2 times larger, values were divided by 2
@@ -561,7 +559,7 @@ void initCommonGui() {
561
559
SliderIROrTofDistance.init (POS_X_THIRD_SLIDER - ((BUTTON_WIDTH_10 / 2 ) - 2 ), SLIDER_TOP_MARGIN + BUTTON_HEIGHT_8,
562
560
(BUTTON_WIDTH_10 / 2 ) - 2 , DISTANCE_SLIDER_SIZE,
563
561
FOLLOWER_DISPLAY_DISTANCE_TIMEOUT_CENTIMETER / DISTANCE_SLIDER_SCALE_FACTOR, 0 , SLIDER_DEFAULT_BACKGROUND_COLOR,
564
- SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT, nullptr );
562
+ SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE | FLAG_SLIDER_IS_ONLY_OUTPUT);
565
563
SliderIROrTofDistance.setScaleFactor (DISTANCE_SLIDER_SCALE_FACTOR); // Slider is virtually 2 times larger, values were divided by 2
566
564
SliderIROrTofDistance.setBarThresholdColor (DISTANCE_TIMEOUT_COLOR);
567
565
// Caption properties
@@ -576,20 +574,20 @@ void initCommonGui() {
576
574
577
575
#if defined(CAR_HAS_PAN_SERVO)
578
576
// left of SliderDistanceServoPosition
579
- SliderPan.init (POS_X_PAN_SLIDER - BUTTON_WIDTH_12, SLIDER_TOP_MARGIN, BUTTON_WIDTH_12, LASER_SLIDER_SIZE, 90 , 90 , COLOR16_YELLOW,
580
- SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE, &doHorizontalServoPosition);
577
+ SliderPan.init (POS_X_PAN_SLIDER - BUTTON_WIDTH_12, SLIDER_TOP_MARGIN, BUTTON_WIDTH_12, LASER_SLIDER_SIZE, 90 , 90 ,
578
+ COLOR16_YELLOW, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE, &doHorizontalServoPosition);
581
579
SliderPan.setBarThresholdColor (COLOR16_BLUE);
582
580
// scale slider values
583
- SliderPan.setScaleFactor ( 180.0 / LASER_SLIDER_SIZE ); // Values from 0 to 180 degrees
581
+ SliderPan.setMinMaxValue ( 0 , 180 ); // Values from 0 to 180 degrees
584
582
SliderPan.setValueUnitString (" \xB0 " ); // \xB0 is degree character
585
583
#endif
586
584
587
585
#if defined(CAR_HAS_TILT_SERVO)
588
586
SliderTilt.init (POS_X_TILT_SLIDER - BUTTON_WIDTH_12, SLIDER_TOP_MARGIN, BUTTON_WIDTH_12, LASER_SLIDER_SIZE, 90 ,
589
- TILT_SERVO_MIN_VALUE, COLOR16_YELLOW, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE, &doVerticalServoPosition);
587
+ TILT_SERVO_MIN_VALUE, COLOR16_YELLOW, SLIDER_DEFAULT_BAR_COLOR, FLAG_SLIDER_SHOW_VALUE, &doVerticalServoPosition);
590
588
SliderTilt.setBarThresholdColor (COLOR16_BLUE);
591
589
// scale slider values
592
- SliderTilt.setScaleFactor ( 180.0 / LASER_SLIDER_SIZE ); // Values from 0 to 180 degrees
590
+ SliderTilt.setMinMaxValue ( 0 , 180 ); // Values from 0 to 180 degrees
593
591
SliderTilt.setValueUnitString (" \xB0 " ); // \xB0 is degree character
594
592
#endif
595
593
0 commit comments