Skip to content

KrisKasprzak/ILI9341_t3_Keypad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keyboard (numbers and characters) for Teensy MCU's

Latest version 2.0

Version History

1.0 2/12/2023 kasprzak initial code
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

  1. ILI9341_t3


header image header image
Watch this YouTube Video for a demonstration: https://youtu.be/PrSxA_QEzuk

Library highlights

  1. Simple to implement library
  2. Users can include both input types in the same program
  3. The keyboard includes all charaters, upper and lower case as well as all special symbols.
  4. The keyboard colors can be configured, but due to size, it will consume the entire screen
  5. The number pad can be configured for both colors and button sizes
  6. Both classes require a custom for for a better visual experience
  7. Both classes can allow hidden character input for password entry
  8. Both classes can allow initial instruction text in the input field
  9. Both classes can allow a predefined input
  10. The number input can handle decimal and negative number inputs and can enable or disabled
  11. The library handles button presses, hence why you pass in the Touch object

General implementation


  1. 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

Caution


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);

Example Screenshots



header image header image header image header image header image header image header image header image header image header image

About

Classes to create a number pad and a full keyboard for the ILI9341_t3 display driver

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages