Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RA8875_KeyPadDemo PUB_RA8875_Keypad IAC_Final_Monil_copy
Diff: Keypad.h
- Revision:
- 1:7feeebbd8367
- Parent:
- 0:9b0b4ae5b47a
- Child:
- 2:6d05764dfde7
--- a/Keypad.h Mon Feb 08 02:38:43 2016 +0000 +++ b/Keypad.h Fri Mar 04 12:23:44 2016 +0000 @@ -4,6 +4,17 @@ #include "mbed.h" #include "RA8875.h" +// OK, these key assignments are a bit odd looking. The value are mapped to the character set of the RA8875 +// internal font. The selected characters shown various symbols - left arrow for the <bs>, up arrow for <shift> +// and so on. They then have to be mapped to legitimate characters as needed. + +#define KYBD_SYM_ENTER 0x1C ///< This is a symbol in the RA8875 character set that looks most like <enter>, so it used to detect enter +#define KYBD_SYM_ESCAPE 0x15 ///< This is a symbol in the RA8875 character set that is used to show and detect escape +#define KYBD_SYM_BS 0x1B ///< This is a symbol in the RA8875 character set that is used to show and detect backspace +#define KYBD_SYM_SHIFT 0x18 ///< This is a symbol in the RA8875 character set that is used to show and detect shift +#define KYBD_SYM_TAB 0x1A ///< This is a symbol in the RA8875 character set that is used to show and detect tab (which translates to <space> + + /// A QWERTY keypad, intended to be coupled with the touchscreen, provides /// on-screen data entry. /// @@ -18,6 +29,23 @@ /// class Keypad { public: + + /// keyboard definition structure, used to define a keyboard. + typedef struct { + loc_t x; ///< left edge of keypad. typically 0 to +n. negative is translated to zero. + loc_t y; ///< top edge of keypad. typically 0 to +n, and more typically in the bottom half of the screen height. + /// negative number allows keypad to size from the bottom of the screen upward. + dim_t width; ///< width of keypad. be sure that the keys can fit. zero is translated to screen-width. + dim_t height; ///< height of keypad. be sure the number of rows will fit, based on the desired key height. + /// zero number allows keypad to size from the bottom of the screen upward. + int rows; ///< number of rows to show. + int cols; ///< number of columns (keys) in the longest row + + const char * keydef1; ///< pointer to the base keyboard data stream + const char * keydef2; ///< pointer to an alternate keyboard data stream (e.g. after <shift> is activated) + } keyboard_t; + + /// Instantiator the Keypad object. /// /// Shows a keypad like this: @@ -43,11 +71,33 @@ /// ~Keypad(); - /// get a string of text entered on the onscreen keypad. + /// Select a keyboard to use. + /// + /// This selects the internally defined keyboard (when NULL) or a user defined + /// keyboard. + /// + /// @param[in] keyboard is a pointer to a @ref keyboard_t data structure. + /// @param[in] enter_key is the character used to complete the entry + /// @param[in] esc_key is the character used to abandon the entry + /// @returns true if it was accepted. + /// @returns false if it could not be accepted (no known reason to return false at this time). + /// + bool SetKeyboard(const keyboard_t * kbd = NULL, char enter_key = KYBD_SYM_ENTER, char esc_key = KYBD_SYM_ESCAPE); + + /// Get a handle to the keyboard currently in use. + /// + /// This returns a handle to the currently active keyboard. If you first SelectKeyboard(NULL), + /// and then call GetKeyboard(), it will return a handle to the built-in keyboard. + /// + /// @returns a handle to the currently active keyboard. + /// + const keyboard_t * GetKeyboard(void) { return kbd; } + + /// Get a string of text entered on the onscreen keypad. /// /// text entry is terminated by <enter> or <esc>. /// - /// @param[inout] buffer is the provided buffer into which the string is written. + /// @param[in,out] buffer is the provided buffer into which the string is written. /// @param[in] size is the size of the buffer. /// @param[in] prompt is the optional text to prompt the user. /// @param[in] mask is the optional character, if non-zero, that is used to obscure @@ -105,7 +155,16 @@ /// void ShowBufferMetrics(void); + /// Compute the coordinates for the keypad + /// + /// @returns rect_t for the keypad. + /// + rect_t ComputeKeypadRect(void); + RA8875 & ra; + const keyboard_t * kbd; + char enter_key; + char esc_key; bool shift; char * pStart; char * pNext;