With some projects you need the possibility to enter configuration data. Such as URL addresses, network names, passwords and much more. The easiest way to do this is via the Arduino IDE's serial monitor, but it requires a connection to the PC via USB.
The new function of the HCScreen library described here enables data to be entered using a keyboard shown on the TFT display, which is controlled using the JoyStick.
The keyboard has two layouts for lowercase letters and numbers as well as uppercase letters and special characters. Switching is also done via the keyboard.
Using the control buttons marked in color in the picture, letters entered to the left of the cursor can be deleted, the cursor can be moved to the right or left, toggle between lower and upper case letters and the entry can be completed.
All other keys are inserted directly at the cursor position. The current input is shown above the keyboard, the cursor is indicated by a colored line. The currently selected key is identified by a colored rectangle.
With the function setKeyboardColor (a, b, c) the colors can be set:
- a = color for key name and grid lines
- b = color for the background
- c = color for the cursor and the rectangle around the selected key
With the initKeyboard function (default), the keyboard on the display is switched on and the transferred string is used as the default value.
In order for the keyboard to work, the joystick functions of the library must be used. When the enter key is clicked, the callback function passed in initJoy () is called and the entered text can be called using the getKeyResult () function.
To query the joystick status, the function handleJoy () must be called in the main loop.
The library can be fromHCScreen librarycan be downloaded. In the Arduino IDE, simply import the ZIP file from the download in the library manager.
The sample program ESP32_Control_CenterKey shows the function of the keyboard.