Move all Rotary interrupt code to iRAM

Move all Rotary interrupt code to iRAM (#7410)
This commit is contained in:
Theo Arends 2020-01-03 17:07:40 +01:00
parent 8c2ff7237e
commit b82d1fdcc3
1 changed files with 21 additions and 28 deletions

View File

@ -36,41 +36,34 @@ struct ROTARY {
/********************************************************************************************/
void update_position(void)
{
uint8_t s;
/*
* https://github.com/PaulStoffregen/Encoder/blob/master/Encoder.h
*/
s = Rotary.state & 3;
if (digitalRead(pin[GPIO_ROT1A])) s |= 4;
if (digitalRead(pin[GPIO_ROT1B])) s |= 8;
switch (s) {
case 0: case 5: case 10: case 15:
break;
case 1: case 7: case 8: case 14:
Rotary.position++; break;
case 2: case 4: case 11: case 13:
Rotary.position--; break;
case 3: case 12:
Rotary.position = Rotary.position + 2; break;
default:
Rotary.position = Rotary.position - 2; break;
}
Rotary.state = (s >> 2);
}
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
void update_rotary(void) ICACHE_RAM_ATTR;
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
void update_rotary(void)
{
if (MI_DESK_LAMP == my_module_type){
if (MI_DESK_LAMP == my_module_type) {
if (LightPower()) {
update_position();
/*
* https://github.com/PaulStoffregen/Encoder/blob/master/Encoder.h
*/
uint8_t s = Rotary.state & 3;
if (digitalRead(pin[GPIO_ROT1A])) { s |= 4; }
if (digitalRead(pin[GPIO_ROT1B])) { s |= 8; }
switch (s) {
case 0: case 5: case 10: case 15:
break;
case 1: case 7: case 8: case 14:
Rotary.position++; break;
case 2: case 4: case 11: case 13:
Rotary.position--; break;
case 3: case 12:
Rotary.position = Rotary.position + 2; break;
default:
Rotary.position = Rotary.position - 2; break;
}
Rotary.state = (s >> 2);
}
}
}