Skip to content

Commit 3fa75d6

Browse files
committed
added ENCODER_INVERT_ROTATION_WHEN_REVERSED
1 parent 00116e3 commit 3fa75d6

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,15 @@ To change the configuration so that rotating the encoder clockwise increases spe
669669

670670
<hr style="height: 1px;">
671671

672+
### Direction of rotation of the encoder when the Loco is reversed
673+
674+
By default, when the loco is reversed, to increase the speed of the loco you need to rotate the encoder in the same direction as when the loco direction is forward. (See the previous heading.)
675+
If you wish to increase speed by rotating the encoder in the oposite direction when the direction is reverse' you can add the following define. Uncomment (remove the ``//``) following line in your ``config_buttons.h``.
676+
677+
``#define ENCODER_INVERT_ROTATION_WHEN_REVERSED true``
678+
679+
<hr style="height: 1px;">
680+
672681
### Optional Additional Buttons
673682

674683
The way to add additional buttons changed in version 1.83. The old way will continue to work but only the new way is described here.

WiTcontroller.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,12 @@ void rotary_loop() {
14371437
}
14381438

14391439
void encoderSpeedChange(bool rotationIsClockwise, int speedChange) {
1440+
#ifdef ENCODER_INVERT_ROTATION_WHEN_REVERSED
1441+
if (currentDirection[currentThrottleIndex] == Reverse) {
1442+
rotationIsClockwise = !rotationIsClockwise;
1443+
}
1444+
#endif
1445+
14401446
if (encoderRotationClockwiseIsIncreaseSpeed) {
14411447
if (rotationIsClockwise) {
14421448
speedUp(currentThrottleIndex, speedChange);

change_log.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Change Log
2+
### V1.104
3+
- Option to invert the meanaing of the encoder rotation when the loco is reversed ``#define ENCODER_INVERT_ROTATION_WHEN_REVERSED true``
24
### V1.103
35
- Option to bypass the initial WiFi scan ``#define BYPASS_WIFI_SCAN_ON_STARTUP true``
46
### V1.102

config_buttons_example.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
// #define ENCODER_ROTATION_CLOCKWISE_IS_INCREASE_SPEED false
1919

20+
// Choose if you want to invert the rotary encoder rotation when the direction is reversed
21+
// i.e. If the direction of the current loco is 'Rev', turning the encoder clockwise will decrease the speed instead of increase
22+
// (or the opposite direction if ENCODER_ROTATION_CLOCKWISE_IS_INCREASE_SPEED is true)
23+
// Uncomment the following line to enable this feature
24+
// #define ENCODER_INVERT_ROTATION_WHEN_REVERSED true
25+
2026
// Define what the rotary encoder button does. (Pushing down on the knob)
2127
// By default it will stop the loco if moving, then a second push will change the direction.
2228
// Uncomment and change the action if you wish it to do something else.

static.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const String appVersion = "v1.103";
1+
const String appVersion = "v1.104";
22
#ifndef CUSTOM_APPNAME
33
const String appName = "WiTcontroller";
44
#else

0 commit comments

Comments
 (0)