Skip to content

ersel/arduino-simple-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino Simple Input Output Library

A simple input output library to use Arduino with keypad and LCD.

Arduino IO Demo

Features

Allows adding static labels and/or input fields to a specified line on LCD.
Input Fields can be either numeric, alphabetic or both.
Any number of labels/input fields can be added to an input line if they fit on the LCD screen.
Labels/Input fields can be added to a specific position or to first avaliable space on screen.
Input fields can be read as integers or char arrays.
Reading input can be enabled/disabled at any time.
Cyclic rotation allows jumping cursor between input fields. Such as last input field to first and vice versa.
Smart input mode remembers the input mode user left the the input field while using alphanumeric input fields.

Configuration & Set-up

In InputLine.h
Include the libraries you use with your LCD and KeyPad.
On Line: 9 Update SCREENCOLUMNSIZE to match your LCD screen's column number.
On Line: 49 Update the paramaters' types in the constructor definition according to your LCD and KeyPad Classes.
On Line 71 and 72 update keypad and lcd types according to your LCD and Keypad Classes.

In InputLine.cpp
On Line 14: Update the constructor according to changes you made to Line 49 on InputLine.h
Update the implementation of these functions according to methods avaliable in your LCD, KeyPad classes:
InputLine::void lcdSetCursor(int col, int row)
InputLine:: void lcdPrint(char c)
InputLine:: char keyPadReadKey()

Usage & Public Methods

Example usage can be seen in InputLineExample.ino file.

Constructor: Initializes a new input line
InputLine(int inputRow, bool cyclicRotation, LiquidCrystal *lcdRef, Keypad_I2C *kpd)
inputRow: Which line of LCD should be used for input line
cyclicRotation: When set to true enables cursor to jump from last input field to first one and vice versa
*lcdRef: Reference to LCD instance
*kpd: Reference to KeyPad instance

addLabel: Adds a new static label to input line, returns true if succeeds.
bool addLabel(char* text)
bool addLabel(int start, char* text)
start: Start position of label on LCD. If omitted label is added to first avaliable space.
text: A char* paramater and adds the label to first avaliable space.

addInputField: Adds a new input field to input line, returns true if succeeds.
bool addInputField(int length, int inputMode)
bool addInputField(int start, int length, int inputMode)
start: Start position of input field on LCD. If omitted field is added to first avaliable space.
length: Length of input field, please note starting element is included in length as well.
inputMode: Input mode for input field. Possible values: 0=Numeric, 1=Alphabetic

Adding AlphaNumeric Input Fields:
bool addInputField(int length, int inputMode, int defaultInputMode, bool smartInputType)
bool addInputField(int start, int length, int inputMode, int defaultInputMode, bool smartInputType)
start: Start position of input field on LCD. If omitted field is added to first avaliable space.
length: Length of input field, please note starting element is included in length as well.
inputMode: While adding alphanumeric input fields inputMode parameter must be 3.
defaultInputMode: Initial input mode of input field can be set to 0 for numeric or 1 for alphabetic input. smartInputType: If set to true, remembers the input mode the user letf the field and when returned continues from that mode.

readInput: Reads keypad and prints to lcd. Should be called in the loop() body of arduino program.

enableInput: Enables/Disables reading input from user.
void enableInput(bool enable)
enable: If set to true, enables reading input from user.

getFieldAsCharArr: Return char* from the specified input field.
char* getInputFieldAsCharArr(int fieldNo)
fieldNo: Input field's number. Input Fields can be accessed in the same order they are added. First input field is 1.

getFieldAsInt: Returns integer from the specified input field. If field contains non-numeric characters returns null.
int getInputFieldAsInt(int fieldNo)
fieldNo: Input field's number. Input Fields can be accessed in the same order they are added. First input field is 1.

Notes

I have developed this library to make it easier to develop more user oriented applications using LCD and KeyPad with Arduino.
I have tested the library on Arduino Uno R3, it should work on other versions as well.
If you have found any bugs, have some improvement ideas or need help setting/porting the library drop a comment on the repository.
Enjoy, happy developing :)

About

A simple input output library to use Arduino with keypad and LCD.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages