Skip to content

Commit

Permalink
Add rotary No Pullup GPIO selection
Browse files Browse the repository at this point in the history
Add rotary No Pullup GPIO selection ``Rotary A/B_n`` (#10407)
  • Loading branch information
arendst committed Jan 6, 2021
1 parent e3def2d commit f8de915
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
- Command ``RuleTimer0`` to access all RuleTimers at once (#10352)
- SPI display driver SSD1331 Color oled by Jeroen Vermeulen (#10376)
- IRremoteESP8266 library from v2.7.13 to v2.7.14
- Rotary No Pullup GPIO selection ``Rotary A/B_n`` (#10407)

### Breaking Changed
- Replaced MFRC522 13.56MHz rfid card reader GPIO selection from ``SPI CS`` by ``RC522 CS``
Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- Command ``SetOption119 1`` to remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic [#10355](https://github.com/arendst/Tasmota/issues/10355)
- Milliseconds to console output [#10152](https://github.com/arendst/Tasmota/issues/10152)
- Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196)
- Rotary No Pullup GPIO selection ``Rotary A/B_n`` [#10407](https://github.com/arendst/Tasmota/issues/10407)
- BSSID and Signal Strength Indicator to GUI wifi scan result [#10253](https://github.com/arendst/Tasmota/issues/10253)
- Support for P9813 RGB Led MOSFET controller [#10104](https://github.com/arendst/Tasmota/issues/10104)
- Support for GPIO option selection
Expand Down
14 changes: 12 additions & 2 deletions tasmota/support_rotary.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const uint8_t rotary_offset = 128;
const int8_t rotary_state_pos[16] = { 0, 1, -1, 2, -1, 0, -2, 1, 1, -2, 0, -1, 2, -1, 1, 0 };

struct ROTARY {
uint8_t no_pullup_mask_a = 0; // Rotary A pull-up bitmask flags
uint8_t no_pullup_mask_b = 0; // Rotary B pull-up bitmask flags
uint8_t model;
bool present;
} Rotary;
Expand All @@ -74,6 +76,14 @@ tEncoder Encoder[MAX_ROTARIES];

/********************************************************************************************/

void RotaryAPullupFlag(uint32 switch_bit) {
bitSet(Rotary.no_pullup_mask_a, switch_bit);
}

void RotaryBPullupFlag(uint32 switch_bit) {
bitSet(Rotary.no_pullup_mask_b, switch_bit);
}

bool RotaryButtonPressed(uint32_t button_index) {
if (!Rotary.present) { return false; }

Expand Down Expand Up @@ -136,8 +146,8 @@ void RotaryInit(void) {
Encoder[index].position = rotary_offset;
Encoder[index].pina = Pin(GPIO_ROT1A, index);
Encoder[index].pinb = Pin(GPIO_ROT1B, index);
pinMode(Encoder[index].pina, INPUT_PULLUP);
pinMode(Encoder[index].pinb, INPUT_PULLUP);
pinMode(Encoder[index].pina, bitRead(Rotary.no_pullup_mask_a, index) ? INPUT : INPUT_PULLUP);
pinMode(Encoder[index].pinb, bitRead(Rotary.no_pullup_mask_b, index) ? INPUT : INPUT_PULLUP);
if (0 == Rotary.model) {
attachInterruptArg(Encoder[index].pina, RotaryIsrArgMiDesk, &Encoder[index], CHANGE);
attachInterruptArg(Encoder[index].pinb, RotaryIsrArgMiDesk, &Encoder[index], CHANGE);
Expand Down
10 changes: 10 additions & 0 deletions tasmota/support_tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,16 @@ void GpioInit(void)
bitSet(TasmotaGlobal.gpio_optiona.data, mpin - AGPIO(GPIO_OPTION_A));
mpin = GPIO_NONE;
}
#ifdef ROTARY_V1
else if ((mpin >= AGPIO(GPIO_ROT1A_NP)) && (mpin < (AGPIO(GPIO_ROT1A_NP) + MAX_ROTARIES))) {
RotaryAPullupFlag(mpin - AGPIO(GPIO_ROT1A_NP));
mpin -= (AGPIO(GPIO_ROT1A_NP) - AGPIO(GPIO_ROT1A));
}
else if ((mpin >= AGPIO(GPIO_ROT1B_NP)) && (mpin < (AGPIO(GPIO_ROT1B_NP) + MAX_ROTARIES))) {
RotaryBPullupFlag(mpin - AGPIO(GPIO_ROT1B_NP));
mpin -= (AGPIO(GPIO_ROT1B_NP) - AGPIO(GPIO_ROT1B));
}
#endif // ROTARY_V1
else if ((mpin >= AGPIO(GPIO_SWT1_NP)) && (mpin < (AGPIO(GPIO_SWT1_NP) + MAX_SWITCHES))) {
SwitchPullupFlag(mpin - AGPIO(GPIO_SWT1_NP));
mpin -= (AGPIO(GPIO_SWT1_NP) - AGPIO(GPIO_SWT1));
Expand Down
2 changes: 1 addition & 1 deletion tasmota/xdrv_01_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ void ModuleSaveSettings(void)
} else {
if (ValidGPIO(i, template_gp.io[i])) {
Settings.my_gp.io[i] = WebGetGpioArg(i);
gpios += F(", " D_GPIO ); gpios += String(i); gpios += F(" "); gpios += String(Settings.my_gp.io[i]);
gpios += F(", "); gpios += String(i); gpios += F(" "); gpios += String(Settings.my_gp.io[i]);
}
}
}
Expand Down

0 comments on commit f8de915

Please sign in to comment.