summaryrefslogtreecommitdiff
path: root/libraries/MultiLCD
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2014-04-20 13:25:28 +0800
committerStanley Huang <stanleyhuangyc@gmail.com>2014-04-20 13:25:28 +0800
commit9629ada62a954692ccc95ad50cb71f443110662b (patch)
tree14b75df6afda76d8727c9727f3f3144a94b7c842 /libraries/MultiLCD
parent0cbe52d6155b78b713fbf13f1b5328bbb286b674 (diff)
download2021-arduino-obd-9629ada62a954692ccc95ad50cb71f443110662b.tar.gz
2021-arduino-obd-9629ada62a954692ccc95ad50cb71f443110662b.tar.bz2
2021-arduino-obd-9629ada62a954692ccc95ad50cb71f443110662b.zip
Update MultiLCD library
Diffstat (limited to 'libraries/MultiLCD')
-rw-r--r--libraries/MultiLCD/LCD4Bit_mod.cpp199
-rw-r--r--libraries/MultiLCD/LCD4Bit_mod.h46
-rw-r--r--libraries/MultiLCD/MultiLCD.h2
-rw-r--r--libraries/MultiLCD/examples/lcdhello/lcdhello.ino82
4 files changed, 1 insertions, 328 deletions
diff --git a/libraries/MultiLCD/LCD4Bit_mod.cpp b/libraries/MultiLCD/LCD4Bit_mod.cpp
deleted file mode 100644
index 5072818..0000000
--- a/libraries/MultiLCD/LCD4Bit_mod.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-LCD4Bit v0.1 16/Oct/2006 neillzero http://abstractplain.net
-
-What is this?
-An arduino library for comms with HD44780-compatible LCD, in 4-bit mode (saves pins)
-
-Sources:
-- The original "LiquidCrystal" 8-bit library and tutorial
- http://www.arduino.cc/en/uploads/Tutorial/LiquidCrystal.zip
- http://www.arduino.cc/en/Tutorial/LCDLibrary
-- DEM 16216 datasheet http://www.maplin.co.uk/Media/PDFs/N27AZ.pdf
-- Massimo's suggested 4-bit code (I took initialization from here) http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1144924220/8
-See also:
-- glasspusher's code (probably more correct): http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1160586800/0#0
-
-Tested only with a DEM 16216 (maplin "N27AZ" - http://www.maplin.co.uk/Search.aspx?criteria=N27AZ)
-If you use this successfully, consider feeding back to the arduino wiki with a note of which LCD it worked on.
-
-Usage:
-see the examples folder of this library distribution.
-
-*/
-
-#if defined(ARDUINO) && ARDUINO >= 100
-#include "Arduino.h"
-#else
-#include "WProgram.h"
-#endif
-
-#include "LCD4Bit_mod.h"
-
-//command bytes for LCD
-#define CMD_CLR 0x01
-#define CMD_RIGHT 0x1C
-#define CMD_LEFT 0x18
-#define CMD_HOME 0x02
-
-//pulse the Enable pin high (for a microsecond).
-//This clocks whatever command or data is in DB4~7 into the LCD controller.
-void LCD4Bit_mod::pulseEnablePin(){
- digitalWrite(Enable,LOW);
- delayMicroseconds(1);
- // send a pulse to enable
- digitalWrite(Enable,HIGH);
- delayMicroseconds(1);
- digitalWrite(Enable,LOW);
- delay(1); // pause 1 ms. TODO: what delay, if any, is necessary here?
-}
-
-//push a nibble of data through the the LCD's DB4~7 pins, clocking with the Enable pin.
-//We don't care what RS and RW are, here.
-void LCD4Bit_mod::pushNibble(byte value)
-{
- byte val_nibble= value & 0x0F; //clean the value. (unnecessary)
-
- for (byte i=DB[0]; i <= DB[3]; i++) {
- digitalWrite(i,val_nibble & 01);
- val_nibble >>= 1;
- }
- pulseEnablePin();
-}
-
-//push a byte of data through the LCD's DB4~7 pins, in two steps, clocking each with the enable pin.
-void LCD4Bit_mod::pushByte(byte value)
-{
- byte val_lower = value & 0x0F;
- byte val_upper = value >> 4;
- pushNibble(val_upper);
- pushNibble(val_lower);
-}
-
-void LCD4Bit_mod::commandWriteNibble(byte nibble)
-{
- digitalWrite(RS, LOW);
- if (USING_RW) { digitalWrite(RW, LOW); }
- pushNibble(nibble);
-}
-
-
-void LCD4Bit_mod::commandWrite(byte value)
-{
- digitalWrite(RS, LOW);
- if (USING_RW) { digitalWrite(RW, LOW); }
- pushByte(value);
- //TODO: perhaps better to add a delay after EVERY command, here. many need a delay, apparently.
-}
-
-
-
-
-//print the given character at the current cursor position. overwrites, doesn't insert.
-size_t LCD4Bit_mod::write(uint8_t c)
-{
- //set the RS and RW pins to show we're writing data
- digitalWrite(RS, HIGH);
- if (USING_RW) { digitalWrite(RW, LOW); }
-
- //let pushByte worry about the intricacies of Enable, nibble order.
- pushByte(c);
-
- return 1;
-}
-
-
-//send the clear screen command to the LCD
-void LCD4Bit_mod::clear()
-{
- commandWrite(CMD_CLR);
- delay(1);
-}
-
-
-// initiatize lcd after a short pause
-//while there are hard-coded details here of lines, cursor and blink settings, you can override these original settings after calling .init()
-void LCD4Bit_mod::begin ()
-{
- pinMode(Enable,OUTPUT);
- pinMode(RS,OUTPUT);
- if (USING_RW) { pinMode(RW,OUTPUT); }
- pinMode(DB[0],OUTPUT);
- pinMode(DB[1],OUTPUT);
- pinMode(DB[2],OUTPUT);
- pinMode(DB[3],OUTPUT);
-
- delay(50);
-
- //The first 4 nibbles and timings are not in my DEM16217 SYH datasheet, but apparently are HD44780 standard...
- commandWriteNibble(0x03);
- delay(5);
- commandWriteNibble(0x03);
- delayMicroseconds(100);
- commandWriteNibble(0x03);
- delay(5);
-
- // needed by the LCDs controller
- //this being 2 sets up 4-bit mode.
- commandWriteNibble(0x02);
- commandWriteNibble(0x02);
- //todo: make configurable by the user of this library.
- //NFXX where
- //N = num lines (0=1 line or 1=2 lines).
- //F= format (number of dots (0=5x7 or 1=5x10)).
- //X=don't care
-
- byte num_lines_ptn = (num_lines - 1) << 3;
- byte dot_format_ptn = 0x00; //5x7 dots. 0x04 is 5x10
-
- commandWriteNibble(num_lines_ptn | dot_format_ptn);
- delayMicroseconds(60);
-
- //The rest of the init is not specific to 4-bit mode.
- //NOTE: we're writing full bytes now, not nibbles.
-
- // display control:
- // turn display on, cursor off, no blinking
- commandWrite(0x0C);
- delayMicroseconds(60);
-
- //clear display
- commandWrite(0x01);
- delay(3);
-
- // entry mode set: 06
- // increment automatically, display shift, entire shift off
- commandWrite(0x06);
-
- delay(1);//TODO: remove unnecessary delays
-}
-
-
-//non-core stuff --------------------------------------
-//move the cursor to the given absolute position. line numbers start at 1.
-//if this is not a 2-line LCD4Bit_mod instance, will always position on first line.
-void LCD4Bit_mod::setCursor(byte x, byte line)
-{
- //first, put cursor home
- commandWrite(CMD_HOME);
- //offset 40 chars in if second line requested
- x += line * 40;
-
- //advance the cursor to the right according to position. (second line starts at position 40).
- for (byte i=0; i<x; i++) {
- commandWrite(0x14);
- }
-}
-
-//scroll whole display to left
-void LCD4Bit_mod::leftScroll(byte num_chars, unsigned int delay_time)
-{
- for (byte i=0; i<num_chars; i++) {
- commandWrite(CMD_LEFT);
- delay(delay_time);
- }
-}
-
-//Improvements ------------------------------------------------
-//Remove the unnecessary delays (e.g. from the end of pulseEnablePin()).
-//Allow the user to pass the pins to be used by the LCD in the constructor, and store them as member variables of the class instance.
-//-------------------------------------------------------------
diff --git a/libraries/MultiLCD/LCD4Bit_mod.h b/libraries/MultiLCD/LCD4Bit_mod.h
deleted file mode 100644
index 1d223b1..0000000
--- a/libraries/MultiLCD/LCD4Bit_mod.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef LCD4Bit_mod_h
-#define LCD4Bit_mod_h
-
-#include <inttypes.h>
-
-class LCD4Bit_mod : public Print {
-public:
- LCD4Bit_mod(byte num_lines = 2):USING_RW(false),RS(8),RW(11),Enable(9)
- {
- DB[0] = 4;
- DB[1] = 5;
- DB[2] = 6;
- DB[3] = 7;
- this->num_lines = num_lines;
- }
- void commandWrite(byte value);
- void begin();
- size_t write(uint8_t c);
- void clear();
- //non-core---------------
- void setCursor(byte x, byte line);
- void leftScroll(byte chars, unsigned int delay_time);
- //end of non-core--------
-
- //4bit only, therefore ideally private but may be needed by user
- void commandWriteNibble(byte nibble);
-private:
- void pulseEnablePin();
- void pushNibble(byte nibble);
- void pushByte(byte value);
- // --------- PINS -------------------------------------
- //is the RW pin of the LCD under our control? If we're only ever going to write to the LCD, we can use one less microcontroller pin, and just tie the LCD pin to the necessary signal, high or low.
- //this stops us sending signals to the RW pin if it isn't being used.
- bool USING_RW;
- //RS, RW and Enable can be set to whatever you like
- byte RS;
- byte RW;
- byte Enable;
- //DB should be an unseparated group of pins - because of lazy coding in pushNibble()
- byte DB[4]; //wire these to DB4~7 on LCD.
- //how many lines has the LCD? (don't change here - specify on calling constructor)
- int num_lines;
-
-};
-
-#endif
diff --git a/libraries/MultiLCD/MultiLCD.h b/libraries/MultiLCD/MultiLCD.h
index cd3d4c1..6e36301 100644
--- a/libraries/MultiLCD/MultiLCD.h
+++ b/libraries/MultiLCD/MultiLCD.h
@@ -198,7 +198,7 @@ public:
}
void setXY(uint16_t x, uint16_t y)
{
- m_y = x;
+ m_x = x;
m_y = y;
}
void setTextColor(uint16_t color)
diff --git a/libraries/MultiLCD/examples/lcdhello/lcdhello.ino b/libraries/MultiLCD/examples/lcdhello/lcdhello.ino
deleted file mode 100644
index b5c6ffd..0000000
--- a/libraries/MultiLCD/examples/lcdhello/lcdhello.ino
+++ /dev/null
@@ -1,82 +0,0 @@
-/*************************************************************************
-* Demo sketch of Arduino Text Display Library for Multiple LCDs
-* Distributed under GPL v2.0
-* Copyright (c) 2013 Stanley Huang <stanleyhuangyc@live.com>
-* All rights reserved.
-*************************************************************************/
-
-#include <Arduino.h>
-#include <Wire.h>
-#include <MultiLCD.h>
-
-LCD_SSD1306 lcd; /* for SSD1306 OLED module */
-//LCD_PCD8544 lcd; /* for LCD4884 shield or Nokia 5100 screen module */
-//LCD_1602 lcd; /* for LCD1602 shield */
-//LCD_ZTOLED lcd; /* for ZT OLED module */
-//LCD_ILI9325D lcd; /* for Itead 2.8" TFT shield */
-
-static const PROGMEM uint8_t smile[48 * 48 / 8] = {
-0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFE,0xFE,0x7E,0x7F,0x7F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x7F,0x7F,0x7E,0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F,0x7F,0x7E,0xFE,0xFE,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFE,0xFE,0x7E,0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
-};
-
-static const PROGMEM uint8_t tick[16 * 16 / 8] =
-{0x00,0x80,0xC0,0xE0,0xC0,0x80,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0x78,0x30,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00};
-
-static const PROGMEM uint8_t cross[16 * 16 / 8] =
-{0x00,0x0C,0x1C,0x3C,0x78,0xF0,0xE0,0xC0,0xE0,0xF0,0x78,0x3C,0x1C,0x0C,0x00,0x00,0x00,0x30,0x38,0x3C,0x1E,0x0F,0x07,0x03,0x07,0x0F,0x1E,0x3C,0x38,0x30,0x00,0x00};
-
-void setup()
-{
- delay(1000);
- lcd.begin();
- //lcd.setFlags(FLAG_PIXEL_DOUBLE);
- lcd.setFont(FONT_SIZE_SMALL);
- lcd.println("ABCDEFGHIJK");
- lcd.setFont(FONT_SIZE_MEDIUM);
- lcd.println("ABCDEFGHIJK");
- lcd.setFont(FONT_SIZE_XLARGE);
- lcd.printLong(12345678);
-}
-
-void loop()
-{
- return;
-
- lcd.draw(smile, 40, 0, 48, 48);
- lcd.draw(tick, 40, 48, 16, 16);
- lcd.draw(cross, 72, 48, 16, 16);
- delay(1000);
-
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.setFont(FONT_SIZE_SMALL);
- lcd.print("Hello, world!");
-
- lcd.setCursor(0, 1);
- lcd.setFont(FONT_SIZE_MEDIUM);
- lcd.print("Hello, world!");
-
- lcd.setCursor(0, 3);
- lcd.setFont(FONT_SIZE_SMALL);
- lcd.printLong(12345678);
-
- lcd.setCursor(64, 3);
- lcd.setFont(FONT_SIZE_MEDIUM);
- lcd.printLong(12345678);
-
- lcd.setCursor(0, 4);
- lcd.setFont(FONT_SIZE_LARGE);
- lcd.printLong(12345678);
-
- lcd.setCursor(0, 6);
- lcd.setFont(FONT_SIZE_XLARGE);
- lcd.printLong(12345678);
-
- delay(3000);
- lcd.clear();
-}