| 92 | volatile bool kb_interrupt = false; |
| 93 | void IRAM_ATTR gpio_isr_handler(void *arg) { kb_interrupt = true; } |
| 94 | void _post_setup_gpio() { |
| 95 | // Initialize TCA8418 I2C keyboard controller |
| 96 | launcherConsolePrintf("%s\n", String("DEBUG: Cardputer ADV - Initializing TCA8418 keyboard").c_str()); |
| 97 | |
| 98 | // Use correct I2C pins for Cardputer ADV |
| 99 | launcherConsolePrintf("DEBUG: Initializing I2C with SDA=%d, SCL=%d\n", TCA8418_SDA_PIN, TCA8418_SCL_PIN); |
| 100 | Wire.begin(TCA8418_SDA_PIN, TCA8418_SCL_PIN); |
| 101 | launcherDelayMs(100); |
| 102 | |
| 103 | // Scan I2C bus to see what's available |
| 104 | launcherConsolePrintf("%s\n", String("DEBUG: Scanning I2C bus...").c_str()); |
| 105 | byte found_devices = 0; |
| 106 | for (byte i = 1; i < 127; i++) { |
| 107 | Wire.beginTransmission(i); |
| 108 | if (Wire.endTransmission() == 0) { |
| 109 | launcherConsolePrintf("DEBUG: Found I2C device at address 0x%02X\n", i); |
| 110 | found_devices++; |
| 111 | } |
| 112 | } |
| 113 | launcherConsolePrintf("DEBUG: Found %d I2C devices\n", found_devices); |
| 114 | |
| 115 | // Try to initialize TCA8418 |
| 116 | launcherConsolePrintf("DEBUG: Attempting to initialize TCA8418 at address 0x%02X\n", TCA8418_I2C_ADDR); |
| 117 | UseTCA8418 = tca.begin(TCA8418_I2C_ADDR, &Wire); |
| 118 | |
| 119 | if (!UseTCA8418) { |
| 120 | launcherConsolePrintf("%s\n", String("ADV : Failed to initialize TCA8418!").c_str()); |
| 121 | launcherConsolePrintf( |
| 122 | "%s\n", String("Probable standard Cardputer detected, switching to Keyboard library").c_str() |
| 123 | ); |
| 124 | Wire.end(); |
| 125 | Keyboard.begin(); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | tca.matrix(7, 8); |
| 130 | tca.flush(); |
| 131 | launcherGpioInput(11); |
| 132 | // TCA8418 INT is active-low; only the falling edge means "event available". |
| 133 | // FALLING avoids the spurious rising-edge ISR that fired after we cleared |
| 134 | // INT_STAT, which was resetting the sel/esc hold state one frame too early. |
| 135 | attachInterruptArg(digitalPinToInterrupt(11), gpio_isr_handler, nullptr, FALLING); |
| 136 | tca.enableInterrupts(); |
| 137 | } |
| 138 | |
| 139 | /********************************************************************* |
| 140 | ** Function: setBrightness |
nothing calls this directly
no test coverage detected