/*############################################################# Program Name : ex2_KEYPAD_DISCO_F429I_Simple2 Author : Grant Phillips Date Modified : 10/05/2016 Compiler : ARMmbed Tested On : STM32F4-Discovery Description : The same as ex1_KEYPAD_DISCO_F429I_Simple, but colors and keys are changed from the default values. Requirements : * STM32F4-Discovery Board Circuit : * NONE ##############################################################*/ // #include "mbed.h" #include "TS_DISCO_F429ZI.h" #include "LCD_DISCO_F429ZI.h" #include "KEYPAD_DISCO_F429ZI.h" KEYPAD_DISCO_F429ZI keypad; //create an array with the new required ASCII characters char newkeys[4][4] = {{'a' ,'b' ,'c' ,'d'}, //row0 {'e' ,'f' ,'g' ,'h'}, //row1 {'i' ,'k' ,'l' ,'m'}, //row2 {'!' ,'<' ,'>' ,'?'}}; //row3 int main() { char buf[20]; //string variable char k, key; keypad.SetBackColor(LCD_COLOR_LIGHTGRAY); //change background color for entire keypad keypad.SetMsgBoxForeColor(LCD_COLOR_MAGENTA); //change Message Box text color keypad.SetMsgBoxBackColor(LCD_COLOR_YELLOW); //change Message Box background color keypad.SetOutBoxForeColor(LCD_COLOR_DARKGREEN); //change Output Box text color keypad.SetOutBoxBackColor(LCD_COLOR_CYAN); //change Output Box background color keypad.SetKeyBackColor(LCD_COLOR_RED); //change Key background color keypad.SetKeyForeColor(LCD_COLOR_WHITE); //change Key text color keypad.SetKeyPressColor(LCD_COLOR_GREEN); //change Key pressed color keypad.SetKeys(newkeys); //change the keys' ASCII characters to the newkeys array keypad.Show(1, 1); //Display the keypad, enable the Message and Output Box areas keypad.WriteMsgBoxLine(0, "Press any key..."); //display a message in the keypad.WriteMsgBoxLine(1, "----------------"); //Message Box area of the keypad while(1) { k = keypad.ReadKey(); //read the current key pressed if(k != '\0') { //if a key is pressed key = k; //store the key in a variable do //read until key is released k = keypad.ReadKey(); while(k != '\0'); sprintf(buf, "%c was pressed", key); keypad.WriteOutBox(buf); //display result in Output Box area of keypad } } }