Como puedo configurar un teclado capacitivo?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Como puedo configurar un teclado capacitivo?

Jump to solution
741 Views
javierzuniga
Contributor I

He trabajado con el profesor expert para configurar dos teclas, una que haga que un led se ilumine y la otra lo apague, lo que quiero es simplemente que cuando pulso una tecla el led se mantenga encendido el tiempo que la estoy pulsando, pero una vez que retiro el dedo deje de estar iluminado. El codigo del events.c que creo que es donde hay que programar esto es el siguiente: /*

/* ###################################################################

**     Filename    : Events.c

**     Project     : prueba teclado

**     Processor   : MKL25Z128VLK4

**     Component   : Events

**     Version     : Driver 01.00

**     Compiler    : GNU C Compiler

**     Date/Time   : 2015-03-11, 13:36, # CodeGen: 13

**     Abstract    :

**         This is user's event module.

**         Put your event handler code here.

**     Settings    :

**     Contents    :

**         TSS1_fOnFault   - void TSS1_fOnFault(byte u8FaultElecNum);

**         TSS1_fOnInit    - void TSS1_fOnInit(void);

**         TSS1_fCallBack0 - void TSS1_fCallBack0(TSS_CONTROL_ID u8ControlId);

**         TSS1_fCallBack1 - void TSS1_fCallBack1(TSS_CONTROL_ID u8ControlId);

**         Cpu_OnNMIINT    - void Cpu_OnNMIINT(void);

**

** ###################################################################*/

/*!

** @file Events.c

** @version 01.00

** @brief

**         This is user's event module.

**         Put your event handler code here.

*/        

/*!

**  @addtogroup Events_module Events module documentation

**  @{

*/        

/* MODULE Events */

#include "Cpu.h"

#include "Events.h"

#ifdef __cplusplus

extern "C" {

#endif

/* User includes (#include below this line is not maintained by Processor Expert) */

/*

** ===================================================================

**     Event       :  TSS1_fOnFault (module Events)

**

**     Component   :  TSS1 [TSS_Library]

**     Description :

**         This callback function is called by TSS after Fault

**         occurence. This event is enabled always and depends on

**         selection 'generate code' if the callback is used.

**         The default CallBack Name is automatically generated with

**         automatic prefix update by current Component Name. User can

**         define own name, but then the automatic name update is not

**         functional.

**         Option is available from TSS3.0 version.

**     Parameters  :

**         NAME            - DESCRIPTION

**         u8FaultElecNum  - The value defines

**                           electrode number on which measurement fault

**                           occured.

**     Returns     : Nothing

** ===================================================================

*/

void TSS1_fOnFault(byte u8FaultElecNum)

{

  /* If large or small capacitor fault  */

  if(tss_CSSys.Faults.ChargeTimeout || tss_CSSys.Faults.SmallCapacitor)

  {

    /* Write your code here ... */

  }

  /* If data corruption fault  */

  if(tss_CSSys.Faults.DataCorruption)

  {

    /* Write your code here ... */

  }

  /* If small trigger period fault  */

  if(tss_CSSys.Faults.SmallTriggerPeriod)

  {

    /* Write your code here ... */

  }

  /* Clear the fault flags */

  (void) TSS_SetSystemConfig(System_Faults_Register, 0x00);

  (void) u8FaultElecNum;

  return;

}

/*

** ===================================================================

**     Event       :  TSS1_fOnInit (module Events)

**

**     Component   :  TSS1 [TSS_Library]

**     Description :

**         This callback function is automatically called during the

**         TSS Init function execution. The function is intended for

**         implementation of peripherals initialization. TSS Component

**         automatically enables clock for all used TSS peripherals in

**         the internal function TSS_InitDevices which is called by

**         this callback.

**         This event is enabled always and depends on selection

**         'generate code' if the callback is used.

**         The default CallBack Name is automatically generated with

**         automatic prefix update by current Component Name. User can

**         define own name, but then the automatic name update is not

**         functional.

**     Parameters  : None

**     Returns     : Nothing

** ===================================================================

*/

void TSS1_fOnInit(void)

{

  TSS1_InitDevices();

  /* Write your code here ... */

}

/*

** ===================================================================

**     Event       :  TSS1_fCallBack0 (module Events)

**

**     Component   :  TSS1 [TSS_Library]

**     Description :

**         Callback definition for Control 0. This event is enabled

**         only if Control 0 is enabled.

**         The default CallBack Name is automatically generated with

**         automatic prefix update by current Component Name. User can

**         define own name, but then the automatic name update is not

**         functional.

**     Parameters  :

**         NAME            - DESCRIPTION

**         u8ControlId     - Valid unique Identifier of

**                           the Control which generated the CallBack

**                           function. This Id can be used for finding

**                           of Callback's source Control.

**     Returns     : Nothing

** ===================================================================

*/

void TSS1_fCallBack0(TSS_CONTROL_ID u8ControlId)

{

  UINT8 u8Event; /* 8 bits local variable used to store the event information */

 

  while (!TSS_KEYPAD_BUFFER_EMPTY(TSS1_cKey0))  /* While unread events are in the buffer */

  {

    TSS_KEYPAD_BUFFER_READ(u8Event,TSS1_cKey0); /* Read the buffer and store the event in the u8Event variable */

    (void) u8Event;

   

  }

  (void) u8ControlId;

  LED1_Put(0);

  return;

}

/*

** ===================================================================

**     Event       :  TSS1_fCallBack1 (module Events)

**

**     Component   :  TSS1 [TSS_Library]

**     Description :

**         Callback definition for Control 1. This event is enabled

**         only if Control 1 is enabled.

**         The default CallBack Name is automatically generated with

**         automatic prefix update by current Component Name. User can

**         define own name, but then the automatic name update is not

**         functional.

**     Parameters  :

**         NAME            - DESCRIPTION

**         u8ControlId     - Valid unique Identifier of

**                           the Control which generated the CallBack

**                           function. This Id can be used for finding

**                           of Callback's source Control.

**     Returns     : Nothing

** ===================================================================

*/

void TSS1_fCallBack1(TSS_CONTROL_ID u8ControlId)

{

  UINT8 u8Event; /* 8 bits local variable used to store the event information */

  while (!TSS_KEYPAD_BUFFER_EMPTY(TSS1_cKey1))  /* While unread events are in the buffer */

  {

    TSS_KEYPAD_BUFFER_READ(u8Event,TSS1_cKey1); /* Read the buffer and store the event in the u8Event variable */ //almacena el valor del buffer en el u8eVent

    /* Write your code here ... */

    (void) u8Event;

  }

  (void) u8ControlId;

  LED1_Put(1);

  return;

  LED1_Off();

}

/*

** ===================================================================

**     Event       :  Cpu_OnNMIINT (module Events)

**

**     Component   :  Cpu [MKL25Z128LK4]

*/

/*!

**     @brief

**         This event is called when the Non maskable interrupt had

**         occurred. This event is automatically enabled when the [NMI

**         interrupt] property is set to 'Enabled'.

*/

/* ===================================================================*/

void Cpu_OnNMIINT(void)

{

  /* Write your code here ... */

}

/* END Events */

#ifdef __cplusplus

}  /* extern "C" */

#endif

/*!

** @}

*/

/*

** ###################################################################

**

**     This file was created by Processor Expert 10.3 [05.09]

**     for the Freescale Kinetis series of microcontrollers.

**

** ###################################################################

*/

0 Kudos
1 Solution
581 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi Javier

Please check the attached file, this is a CW 10.6 that set 2 electrodes on the freedom KL25, One electrode turn the red led only if the electrode is touched, and the other tootle the green led.

Por favor checa el ejemplo adjunto, es un codigo en CW 10.6 que usa los electrodos del freedom kl25 con uno prendes el led rojo solo cuando esta tocado el electrodo, con el otro electrodo cambias el estado del led verde, si esta prendido lo apaga, si esta apagado lo prende.

Cualquier duda con gusto te puedo ayudar.


Have a great day,
Vicente

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
582 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi Javier

Please check the attached file, this is a CW 10.6 that set 2 electrodes on the freedom KL25, One electrode turn the red led only if the electrode is touched, and the other tootle the green led.

Por favor checa el ejemplo adjunto, es un codigo en CW 10.6 que usa los electrodos del freedom kl25 con uno prendes el led rojo solo cuando esta tocado el electrodo, con el otro electrodo cambias el estado del led verde, si esta prendido lo apaga, si esta apagado lo prende.

Cualquier duda con gusto te puedo ayudar.


Have a great day,
Vicente

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
581 Views
javierzuniga
Contributor I

Thank you Pedro. I solved the problem, it was really helpful!!:smileyhappy: can i ask you something more? how can i use the ports B 16,17 (slider sensors) and B18,19 (leds) and ports A 0,3, A4(CPU) as a external capacitance sensors inputs like with the others pins?

And what is different between adding a led or a pin to swich on a led?

Thank you very much.

0 Kudos