AnsweredAssumed Answered

Como puedo configurar un teclado capacitivo?

Question asked by Javier Zuniga on Mar 11, 2015
Latest reply on Mar 13, 2015 by Javier Zuniga

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.

**

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

*/

Outcomes