no pending press && ((buttonNumber & 0x80) == 0 )) // or more button changes are detected || (returnValue.ButtonNumber == 0) ) // safety in case interrupt and data mismatch or code bug { // No more button notification pending g_prop.HasPendingInterrupt = false; } else { DEBUG_BUTTON16(Serial.println("not Clearing interrupt")); } g_prop.IgnoreNextEvent = digitalRead(g_prop.SdoPin) == LOW; // If the pin is still low at the end of reading, ignore next event which is for data finished raise DEBUG_BUTTON16(Serial.print(g_prop.IgnoreNextEvent ? "Ignoring next event\n\r" : "Not ignoring\n\r")); // All the data has been read. Now reactivate the interrupt SetInterruptHandler(); #endif DEBUG_BUTTON16(Serial.print("currValue : ")); DEBUG_BUTTON16(Serial.println(currValue)); DEBUG_BUTTON16(Serial.print("Changes : ")); DEBUG_BUTTON16(Serial.println(changes)); DEBUG_BUTTON16(Serial.print("Button N : ")); DEBUG_BUTTON16(Serial.println(buttonNumber)); DEBUG_BUTTON16(Serial.print("Unhandled : ")); DEBUG_BUTTON16(Serial.println(g_prop.UnhandledButtonPresses)); DEBUG_BUTTON16(Serial.print("ButtonRelease : ")); DEBUG_BUTTON16(Serial.println(returnValue.IsButtonReleased)); DEBUG_BUTTON16(Serial.print("buttonNumber : ")); DEBUG_BUTTON16(Serial.println(buttonNumber)); DEBUG_BUTTON16(Serial.print("Pending interrupts :")); DEBUG_BUTTON16(Serial.println(g_prop.HasPendingInterrupt)); return returnValue; } #if defined(INT0_PIN) || defined(INT1_PIN) static bool HasEvent() { #if defined(INT0_PIN) if( INT0_PIN == g_prop.SdoPin ) { return g_prop.HasPendingInterrupt; } #endif #if defined(INT1_PIN) if( INT1_PIN == g_prop.SdoPin ) { return g_prop.HasPendingInterrupt; } #endif return true; } #endif }; CTtP229TouchButton::CTtp229Prop CTtP229TouchButton::g_prop; CTtP229TouchButton g_ttp229Button; #define TTP16Button g_ttp229Button #pragma pack(pop) void setup() { Serial.begin(115200); DEBUG_STATUS(Serial.println("====================================")); DEBUG_STATUS(Serial.println("Teste do Teclado Capacitivo Iniciado")); DEBUG_STATUS(Serial.println("====================================")); TTP16Button.Configure(7, 2); } void TestStatus() { uint8_t buttonNumber = TTP16Button.GetButtonStatus(); if( 0 != buttonNumber ) { DEBUG_STATUS(Serial.print("Tecla Acionada : ")); DEBUG_STATUS(Serial.println(buttonNumber)); } delayMicroseconds(2500); // TTP229 document says it will reset the output if 2ms idle + little bit safety } void TestEvent() { #if defined(INT0_PIN) || defined(INT1_PIN) if( TTP16Button.HasEvent()) #endif { CTtp229ButtonEvent buttonEvent = TTP16Button.GetButtonEvent(); if( 0 != buttonEvent.ButtonNumber ) { if( buttonEvent.IsButtonReleased ) { DEBUG_STATUS(Serial.print("Tecla Liberada : ")); } else { DEBUG_STATUS(Serial.print("Tecla Acionada : ")); } DEBUG_STATUS(Serial.println(buttonEvent.ButtonNumber)); } else { #if defined(INT0_PIN) || defined(INT1_PIN) // DEBUG_STATUS(Serial.println("Are you not using interrupt? Should never come here for interrupt based system.")); #endif } //Serial.print("CurrentTime : "); Serial.println(millis()); delayMicroseconds(2500); // TTP229 document says it will reset the output if 2ms idle + little bit safety. Not required if using interrupts } } void loop() { //TestStatus(); TestEvent(); } Agora que voce ja sabe como configurar seu Teclado Touch Digital Capacitivo 16 Teclas Ttp229 como um dispositivo de entrada para seus projetos, conte-nos sobre suas experiencias com os produtos da nossa loja.Dados Tecnicos:Tamanho PCB: 49,3 x 64,5 mm.Quantidade de teclas: 16.Comunicacao: I2C.Voltagem de operacao: 2,5V a 5V DCPode configurar a velocidade de resposta, e formato de saidaIndicador LED Ate a proxima postagem!