Latest version 2.0
1.1 2/21/2023 kasprzak fixed number overrun issue
2.0 3/14/2023 kasprzak fixed fonts for MEGA
3.0 3/14/2024 kasprzak complete rewrite to support ESP32
4.0 5/1/2024 kasprzak added corner rounding added trailing zero removal, removed dependency on special controls library
This library includes 2 classes for getting user input using a 0-9 digit number pad and a full keyboard. This library is for the ILI9341_t3 driver to drive common 2.8" LCF displays, and also requires touch screen capability. This library is dependent on
- ILI9341_t3
Watch this YouTube Video for a demonstration:
https://youtu.be/PrSxA_QEzuk
- Simple to implement library
- Users can include both input types in the same program
- The keyboard includes all charaters, upper and lower case as well as all special symbols.
- The keyboard colors can be configured, but due to size, it will consume the entire screen
- The number pad can be configured for both colors and button sizes
- Both classes require a custom for for a better visual experience
- Both classes can allow hidden character input for password entry
- Both classes can allow initial instruction text in the input field
- Both classes can allow a predefined input
- The number input can handle decimal and negative number inputs and can enable or disabled
- The library handles button presses, hence why you pass in the Touch object
- include the library
#include "ILI9341_t3.h"
#include "font_Arial.h"
#include "ILI9341_t3_Keypad.h"
#include "XPT2046_Touchscreen.h"
2. create a display object
3. create a touch object
4. create the keyboard and / or numberpad object
NumberPad MyNumberPad(&Display, &Touch);
or...
Keyboard MyKeyboard(&Display, &Touch);
6. In setup, initialize the objects, and optionally specify any options
MyNumberPad.init(ILI9341_BLACK, ILI9341_WHITE, ILI9341_BLUE, ILI9341_NAVY, ILI9341_WHITE, ILI9341_CYAN, ILI9341_YELLOW, FONT_BUTTON);
// MyNumberPad.enableDecimal(bool State); // disable / enable decimal point (enabled by default)
// MyNumberPad.enableNegative(bool State); // disable / enable negative sign (enabled by default)
// MyNumberPad.setMinMax(float MininumValue, float MaximumValue); // want bound checks?
// use the value property to set the initial value if desired
// MyNumberPad.value = 3.14159;
MyKeyboard.init(ILI9341_BLACK, ILI9341_WHITE, ILI9341_BLUE, ILI9341_NAVY, ILI9341_WHITE, ILI9341_CYAN, ILI9341_YELLOW, FONT_BUTTON);
// MyKeyboard.setDisplayColor(uint16_t TextColor, uint16_t BackColor); change colors
// MyKeyboard.hideInput(); // for expanded password input _
// MyKeyboard.setInitialText(const char *Text); // maybe show and ip address format
// MyKeyboard.setInitialText("IP 111.222.333.444");
// optional to populate the input box
// strcpy(MyKeyboard.data, "TEXT");
7. When ready get user input
MyNumberPad.getInput(); // this will display the key pad control
or
MyKeyboard.getInput(); // this will display the key pad control
8. Once the user completes input, read the results
Serial.println(MyNumberPad.value);
note that the data type is a float so you will need to recast if an int is desired
Serial.println((int) MyNumberPad.value);
or
Serial.println(MyKeyboard.data);
the data property is a char
If your touch screen is not being mapped to where you pressed you will probably need to adjust the screen mapping in the .cpp file. This mapping is used to account for touch difference in displays. There is a mapping function for both classes. Once you tweak one, the same map can be used for the other.
BtnX = map(p.x, 3975, 169, 0, 320);
BtnY = map(p.y, 3850, 304, 0, 240);