c. Alphanumeric Keyboard Input

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 14 - CleO Utility Widgets >

c. Alphanumeric Keyboard Input

This tutorial shows how to use the Alphanumeric Keyboard widget.The Keyboard() widget can be used to invoke the keyboard on the screen. You are required to pass text field which will store the text typed using the keyboard.

 

 

Command Prototype

 

uint16_t Keyboard(const char* Prompt,  textfield &AlphaNumeric);

 

Parameters

Description

Prompt

text displayed on top of the widget screen

AlphaNumeric

text field which contains text input from keyboard

 

 

Code

 

 

void setup()

{

/* Max allowed input length is 16 */

 textfield AlphaNumeric = { 16, "" };

 

/* Initialize CleO - needs to be done only once */

 CleO.begin();

 

/* Draw Keypad */

 char buf[20];

 sprintf(buf, "Keyboard - %d chars", AlphaNumeric.size);

 int16_t retcode = CleO.Keyboard(buf, AlphaNumeric);

 if (retcode == 1) // Cancel pressed

   strcpy(AlphaNumeric.text, ""); // erase text

 

/* Start building a screen frame */

 CleO.Start();

 

 CleO.StringExt(FONT_MEDIUM, 160, 240, LIGHT_GREEN, MM, 0, 0,

 AlphaNumeric.text);

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop() { }

 

 

Description

 

In the above code snippet, the struct shows the definition of the text field.

The Keyboard() command illustrates how to draw a text retrieved from the keyboard.

 

Note: Make sure to perform the screen calibration. For details, refer to Tutorial 19 - Miscellaneous Commands > a. Screen Calibration.

 

 

Output

 

Here is the output displayed upon executing the code snippet -

 

IMG_8415

 

3-AlphaNumericKeyboardInput