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
Revision 6:4da6fa0fe51b, committed 2016-11-13
- Comitter:
- WiredHome
- Date:
- Sun Nov 13 02:05:41 2016 +0000
- Parent:
- 5:7ccb8f7386fa
- Commit message:
- Add ability to pre-initialize the data entry buffer
Changed in this revision
| Keypad.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Keypad.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7ccb8f7386fa -r 4da6fa0fe51b Keypad.cpp
--- a/Keypad.cpp Sat Nov 12 20:09:21 2016 +0000
+++ b/Keypad.cpp Sun Nov 13 02:05:41 2016 +0000
@@ -138,12 +138,12 @@
}
void Keypad::DrawKeypad(void) {
- dim_t fW;
+ //dim_t fW;
dim_t fH;
dim_t kW; // key width
dim_t kH; // key Height
- fW = ra.fontwidth();
+ //fW = ra.fontwidth();
fH = ra.fontheight();
kH = fH + 4;
@@ -214,13 +214,20 @@
ra.SetTextCursorControl(RA8875::UNDER);
}
-bool Keypad::GetString(char * buffer, size_t size, const char * prompt, char mask, bool auto_close) {
+
+bool Keypad::GetString(char * buffer, size_t size, const char * prompt, bool initFromBuffer, char mask, bool auto_close) {
point_t point = {0, 0};
bool success = false;
pStart = pNext = buffer;
bufSize = size;
DrawInputPanel(prompt);
+ if (initFromBuffer && strlen(buffer) < size) {
+ ra.SetTextCursor(userText);
+ ra.puts(buffer);
+ userText = ra.GetTextCursor();
+ pNext += strlen(buffer);
+ }
ShowBufferMetrics();
while (1) {
if (touch == ra.TouchPanelReadable(&point)) {
@@ -234,7 +241,6 @@
do {
is = ra.TouchPanelReadable(NULL);
//printf("is: %d\r\n", is);
-
} while (is != no_touch);
DrawKey(touchRect, key);
}
diff -r 7ccb8f7386fa -r 4da6fa0fe51b Keypad.h
--- a/Keypad.h Sat Nov 12 20:09:21 2016 +0000
+++ b/Keypad.h Sun Nov 13 02:05:41 2016 +0000
@@ -124,7 +124,9 @@
/// @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. It defaults
- /// to no prompp.
+ /// to no prompt.
+ /// @param[in] initFromBuffer causes initial text from buffer to seed the data entry.
+ /// If this is true and if the strlen(buffer) < size, it will be shown.
/// @param[in] mask is the optional character, if non-zero, that is used to obscure
/// the text entry - for password purposes. It defaults to not hidden.
/// @param[in] autoclose is an optional parameter to erase the keyboard when done.
@@ -133,7 +135,8 @@
/// @returns true if text was entered.
/// @returns false if text was not entered (e.g. <esc> pressed).
///
- bool GetString(char * buffer, size_t size, const char * prompt = NULL, char mask = 0, bool autoclose = true);
+ bool GetString(char * buffer, size_t size, const char * prompt = NULL,
+ bool initFromBuffer = false, char mask = 0, bool autoclose = true);
/// Erase the area where the keypad panel was drawn
///