Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
The official first GitHub commit of the LiquidCrystal NKC v21.302 Arduino Library on October 29th, 2021
  • Loading branch information
domiluci committed Oct 29, 2021
0 parents commit 8e8699e
Show file tree
Hide file tree
Showing 16 changed files with 3,336 additions and 0 deletions.
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
///////////////////////////////////////////////////////////////
// LiquidCrystal NKC v0.21.299 ////////////////////////////////
// Developer: Dominic Luciano /////////////////////////////////
///////////////////////////////////////////////////////////////

NKC Electronics Serial LCD Module Library for the Arduino IDE
This Library is Compatible with the Arduino IDE v1.0 to v2.0+

// DESCRIPTION ////////////////////////////////////////////////
While not very mainstream, the Longtech & NKC Electronics LCD
display boasts a myriad of features over and above the generic
I2C backpacks typically used to simplify 8-bit LCD connection,
such as the capability to command the display not just via I2C
but also over RS232 (with just a single wire), as well as over
an everyday SPI bus. This NKC LCD also provides fully digital
control over the brightness and contrast, doing away with trim
pots for contrast adjustment, and providing backlight settings
beyond just "ON" and "OFF".

But the bragging rights go beyond the mere NKC display itself.
This LiquidCrystal NKC library is built to work with the same
commands as the LiquidCrystal and LiquidCrystal I2C libraries,
but also retains alias commands to remain compatible with the
original SerialLCD library. So little to no code will require
rewriting or reworking.

However, many extensions to the basic commands were integrated
into this LiquidCrystal NKC library. And there are many future
additions and expansions planned, so make sure to keep your LC
NKC library updated to take advantage of all those features!

NOTE: Some features are still being developed and perfected &
may not work properly or as expected. Please make sure to post
and report all bugs on the official GitHub repository, located
at: https://www.guthub.com/domiluci/LiquidCrystal_NKC. Thanks!

// GENERAL USAGE //////////////////////////////////////////////

// CONSTRUCTOR //
// Interface, I2C Address/Baud Rate, Columns, Rows
Ex: LC_NKC lcd(I2C, 0x28, 20, 4)
Ex: LC_NKC lcd(RS232, 9600, 20, 4)

// COMMANDS //
- Initialize the LCD with .init() or .begin()
- Turn the display on/off with .on() or .off()
- Alternatively, you may use .display() or .noDisplay
- Toggle the backlight with .backlight() or .noBacklight()
- Or toggle the backlight with .setBacklight(HIGH or LOW)
- Set it to specific level with .setBacklightBrightness(1 to 8)
- Set the display's contrast with .setContrast(1 to 40)
- Clear the entire display with .clear()
- Clear a single position with .clear(column, row)
- Clear many spaces with .clear(start column, end column, row)
- Clear an entire line/row with .clear(row)
- Reset the cursor to 0, 0 with .home()
- Set the cursor's position with .setCursor(column, row)
- Write a single character to the display with .write()
- Print a char or string to the LCD with .print()
- The function .printstr() does the same thing
- Store up to 8 unique characters to LCD with .createChar()
- Use .cursorOn() or .cursorOff() to toggle the cursor
- Using .cursor() and .noCursor() alias does the same thing
- Turn the blinking cursor on/off with .blinkOn() & .blinkOff()
- Do the same with .blink(true) and .blink(false)
- Or use .blink() and .noBlink() to stay compatible
- To move cursor left/right a spot, use .left() or .right()
- To move it more, use .left(columns) or .right(columns)
- Backspace the cursor with .backspace()
- Shift the whole display with .shiftLeft() and .shiftRight()
- Shift more with .shiftLeft(columns) and .shiftRight(columns)
- Or use .scrollDisplayLeft() or .scrollDisplayRight() and...
- .scrollDisplayLeft(columns) or .scrollDisplayRight(columns)

// WHAT'S NEXT ////////////////////////////////////////////////

Currently, an expanded LiquidCrystal library is in development
that will combine support for all LCD displays, including this
NKC Serial LCD display. A universal LCD library will not only
make it easier to switch between different LCD displays while
eliminating time wasted on reconfiguring and recoding projects,
but it will also create a standardized set of commands for all
LCD displays of all interface types. Not to mention expand on
all current commands, providing easier, simpler functionality
with more power and flexibility, all while requiring less code
to implement and execute.

As for this LiquidCrystal NKC library, it will continue to be
updated and maintained, even after completion of the expanded
LiquidCrystal library. More additions will be coming soon. So
make sure you keep your copy of the LiquidCrystal NKC library
up-to-date to score on all those fresh features ASAP. And stay
tuned to the other repositories for the all new, all universal
LiquidCrystal library coming soon!
205 changes: 205 additions & 0 deletions examples/FullDemo_I2C/FullDemo_I2C.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
// OVERVIEW //////////////////////////////////////
// LiquidCrystal NKC: Library for Arduino
// Full Arduino IDE Demonstration Sketch
// Sketch v21.302 by Dominic M. Luciano
//
// This sketch is intended to highlight & display
// the major functions of the LiquidCrystal NKC
// library and their potential uses and usages in
// conjunction with an NKC Electronics Serial LCD
// display module running in I2C mode
//////////////////////////////////////////////////
// CONNECTIONS ///////////////////////////////////
// LCD PIN 2 [VSS] -> ARDUINO UNO GND
// LCD PIN 3 [VDD] -> ARDUINO UNO +5V
// LCD PIN 7 [SCL] -> ARDUINO UNO PIN A5 [SCL]
// LCD PIN 8 [SDA] -> ARDUINO UNO PIN A4 [SDA]
//////////////////////////////////////////////////

#include <Wire.h>
#include <LiquidCrystal_NKC.h>

// DECLARATIONS //////////////////////////////////
// Constructor & Parameters //
// Interface, I2C Address, Columns, Rowa
LC_NKC lcd(I2C, 0x28, 20, 4);

// General Variables //
// Strings We'll Use Shortly
String ChangingToday = "Changing Today";
String EvolvingTomorrow = "Evolving Tomorrow";

// Custom Character Arrays //
byte heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};

void setup() {

// Initialize LCD Module
lcd.init();

// Turn On LCD Backlight
lcd.backlight();
// Or Use: lcd.setBacklight(HIGH);

// Create New Character From Earlier Byte Array
// We'll Use This Later On
lcd.createChar(0, heart);

}

void loop() {

// Set Cursor to "Col 0, Row 0" (1st Col, 1st Row)
lcd.home(); // Or Use: lcd.setCursor(0, 0);

// Clear The Entire LCD
lcd.clear();

// Set Cursor to "Col 4, Row 1" (5th Col, 2nd Row)
lcd.setCursor(4, 1);

// Print "Hello, World" to the LCD
lcd.print("Hello, World");
delay(2000);

// Clear LCD From Cols 4 to 16 on Row 1 (5th-17th Column, 2nd Row)
lcd.clear(4, 16, 1);
delay(250);

// Display the LCD Firmware's Version
lcd.displayVersion();
delay(2000);

// Clear The Entire LCD
lcd.clear();
delay(250);

// Display the LCD's Current I2C Address
lcd.displayI2CAddress();
delay(2000);

// Clear Entire LCD
lcd.clear();
delay(250);

// Set Cursor Back to "0, 0"
lcd.home();

// Print Some Text...
lcd.print("LiquidCrystal NKC");

// Set Cursor To "Col 0, Row 1" (1st Col, 2nd Row)
lcd.setCursor(0, 1);
lcd.print("By Dominic Luciano");
delay(2000);

// Set Cursor To "Col 0, Row 2" (1st Col, 3rd Row)
lcd.setCursor(0, 2);
lcd.print("GitHub.com/DomiLuci");
delay(2000);

// Set Cursor To "0, 2"
lcd.setCursor(0, 3);

//Turn LCD Blinking Cursor On
lcd.blink();
// or use: lcd.blinkOn();
// or use: lcd.blink(true);

// And For My Next Trick...
// Making Text Appear Behind A Blinking Cursor
for (byte i = 0; i <= 18; i++) {
// Print Each Letter of the String At Index "i"
lcd.print(String(ChangingToday.charAt(i)));
// Cursor Must Be Reset After Each Letter to Col "i"
lcd.setCursor(i, 3);
// Move the Blinking Cursor One Spot Right Every 100ms
lcd.right();
delay(100);
}
delay(1000);

// Making Text Appear Behind A Blinking Cursor
// ...In Reverse
for (byte i = 19; i <= 19; i--) {
// Print Each Letter of the String At Index "i"
lcd.print(String(EvolvingTomorrow.charAt(i)));
// Cursor Must Be Reset After Each Letter to Col "i"
lcd.setCursor(i, 3);
// Move the Blinking Cursor One Spot Left Every 100ms
lcd.left();
delay(100);
}

//Turn LCD Blinking Cursor Off
lcd.noBlink();
// Or Use: lcd.blinkOff();
// Or Use: lcd.blink(false);
delay(2000);

// Drop the Contrast to "0"
lcd.setContrast(0);

// Clear Rows 0, 1, 2, and 3 (1st, 2nd, 3rd, and 4th Row)
lcd.clear(0);
lcd.clear(1);
lcd.clear(2);
lcd.clear(3);
// Reset Cursor to "0, 3"
lcd.setCursor(2, 1);
// Print "Now Let's Scroll"
lcd.print("Now Let's Scroll");

// Fade The Contrast In...
for (byte i = 0; i <= 40; i++) {
// Set Contrast to "i"
lcd.setContrast(i);
delay(100);
}
delay(2000);

// Set Cursor to "20, 1" (21st Column of 2nd Row, Sort Of)
lcd.setCursor(20, 1);
// Shift ALL Text Left 2 Positions, Once Every 100ms...
// The Easy Way This Time
lcd.scrollDisplayLeft(1, 100);
// Or Use: lcd.shiftLeft(14, 100);
delay(250);

byte col = 21; // Variable For Next Loop
// Now Shift ALL Text Right 20 Positions, Once Every 100ms...
// The Harder Way
for (byte i = 0; i <= 20; i++) {
delay(100);
lcd.scrollDisplayRight();
// Or Use: shiftRight();
// Clear Each Character Before It Re-enters Frame
lcd.clear(col, 1); col--;
}
delay(2000);

// Clear The Entire LCD...
// Also Resetting The LCD Shift
lcd.clear();

// Set Cursor to "3, 1" (4th Column, 2nd Row)
lcd.setCursor(3, 1);
// Print Some Thank You Text
lcd.print("Thanks 4 The ");
// Show That Heart We Made Earlier
lcd.write((byte)0);
delay(2000);

//Clean Up The Entire LCD Before Loop Reset
lcd.clear();
delay(1500);
}
Binary file not shown.
Loading

0 comments on commit 8e8699e

Please sign in to comment.