this giant function is an unfortunate consequence of Arduino's attachInterrupt function not supporting any way to pass a pointer or other context to the attached function.
| 388 | // attachInterrupt function not supporting any way to pass a pointer |
| 389 | // or other context to the attached function. |
| 390 | static uint8_t attach_interrupt(uint8_t pin, Encoder_internal_state_t *state) { |
| 391 | switch (pin) { |
| 392 | #ifdef CORE_INT0_PIN |
| 393 | case CORE_INT0_PIN: |
| 394 | interruptArgs[0] = state; |
| 395 | attachInterrupt(0, isr0, CHANGE); |
| 396 | break; |
| 397 | #endif |
| 398 | #ifdef CORE_INT1_PIN |
| 399 | case CORE_INT1_PIN: |
| 400 | interruptArgs[1] = state; |
| 401 | attachInterrupt(1, isr1, CHANGE); |
| 402 | break; |
| 403 | #endif |
| 404 | #ifdef CORE_INT2_PIN |
| 405 | case CORE_INT2_PIN: |
| 406 | interruptArgs[2] = state; |
| 407 | attachInterrupt(2, isr2, CHANGE); |
| 408 | break; |
| 409 | #endif |
| 410 | #ifdef CORE_INT3_PIN |
| 411 | case CORE_INT3_PIN: |
| 412 | interruptArgs[3] = state; |
| 413 | attachInterrupt(3, isr3, CHANGE); |
| 414 | break; |
| 415 | #endif |
| 416 | #ifdef CORE_INT4_PIN |
| 417 | case CORE_INT4_PIN: |
| 418 | interruptArgs[4] = state; |
| 419 | attachInterrupt(4, isr4, CHANGE); |
| 420 | break; |
| 421 | #endif |
| 422 | #ifdef CORE_INT5_PIN |
| 423 | case CORE_INT5_PIN: |
| 424 | interruptArgs[5] = state; |
| 425 | attachInterrupt(5, isr5, CHANGE); |
| 426 | break; |
| 427 | #endif |
| 428 | #ifdef CORE_INT6_PIN |
| 429 | case CORE_INT6_PIN: |
| 430 | interruptArgs[6] = state; |
| 431 | attachInterrupt(6, isr6, CHANGE); |
| 432 | break; |
| 433 | #endif |
| 434 | #ifdef CORE_INT7_PIN |
| 435 | case CORE_INT7_PIN: |
| 436 | interruptArgs[7] = state; |
| 437 | attachInterrupt(7, isr7, CHANGE); |
| 438 | break; |
| 439 | #endif |
| 440 | #ifdef CORE_INT8_PIN |
| 441 | case CORE_INT8_PIN: |
| 442 | interruptArgs[8] = state; |
| 443 | attachInterrupt(8, isr8, CHANGE); |
| 444 | break; |
| 445 | #endif |
| 446 | #ifdef CORE_INT9_PIN |
| 447 | case CORE_INT9_PIN: |