wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/KeypadSound/KeyPadSetUSBEvent

KeyPadSetUSBEvent

Set an event (callback) function to be called when character is received via USB keyboard.

void KeyPadSetUSBEvent(uint8 (*pUSBKeypadEvent)(uint 8 keyRcvd))

Parameters

uint8 (*pUSBKeypadEvent)(uint8 keyRcvd))

Return Value

  • void - does not return any value

Remarks

Applications must call OpenBeeper before the keypad or beeper devices may be used from the application. This function is useful if it is desired to disregard or modify certain characters received from an attached USB keyboard.

Examples

uint8 USBKeyRcvd(uint8 key)
{
   if(key >= 'a' && key <= 'z') // lower case key pressed
   { 
       return key - 'a' + 'A';  // convert to upper case
   }
   else
   {
       return key;
   }
}

void IndStartup(void)
{
    KeyPadSetUSBEvent(USBKeyRcvd);
    // ...

}

uint8 USBKeyRcvd(uint8 key)
{
   if((key >= '0' && key <= '9') || key == '\r') // Only allow numbers and carriage return
   { 
       return key;
   }
   else
   {
       return 0;
   }
}

void IndStartup(void)
{
    KeyPadSetUSBEvent(USBKeyRcvd);
    // ...

}

See Also

Last modified 7 years ago Last modified on 04/12/18 13:04:33
Note: See TracWiki for help on using the wiki.