LCD4Bit
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 25 Jun 2015 15:24:08 +0000 (17:24 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 25 Jun 2015 15:24:08 +0000 (17:24 +0200)
http://linksprite.com/wiki/index.php5?title=16_X_2_LCD_Keypad_Shield_for_Arduino#Resources

libraries/LCD4Bit_mod/LCD4Bit_mod.cpp [new file with mode: 0644]
libraries/LCD4Bit_mod/LCD4Bit_mod.h [new file with mode: 0644]
libraries/LCD4Bit_mod/WConstants.h [new file with mode: 0644]
libraries/LCD4Bit_mod/examples/LCD4Bit_Temperature/LCD4Bit_Temperature.pde [new file with mode: 0644]
libraries/LCD4Bit_mod/examples/LCD4Bit_modExample/LCD4Bit_modExample.pde [new file with mode: 0644]
libraries/LCD4Bit_mod/keywords.txt [new file with mode: 0644]
libraries/LCD4Bit_mod/readme.txt [new file with mode: 0644]
libraries/LCD4Bit_mod/wiring.h [new file with mode: 0644]

diff --git a/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp b/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp
new file mode 100644 (file)
index 0000000..e500dd7
--- /dev/null
@@ -0,0 +1,232 @@
+/*\r
+LCD4Bit v0.1 16/Oct/2006 neillzero http://abstractplain.net\r
+\r
+What is this?\r
+An arduino library for comms with HD44780-compatible LCD, in 4-bit mode (saves pins)\r
+\r
+Sources:\r
+- The original "LiquidCrystal" 8-bit library and tutorial\r
+    http://www.arduino.cc/en/uploads/Tutorial/LiquidCrystal.zip\r
+    http://www.arduino.cc/en/Tutorial/LCDLibrary\r
+- DEM 16216 datasheet http://www.maplin.co.uk/Media/PDFs/N27AZ.pdf\r
+- Massimo's suggested 4-bit code (I took initialization from here) http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1144924220/8\r
+See also:\r
+- glasspusher's code (probably more correct): http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1160586800/0#0\r
+\r
+Tested only with a DEM 16216 (maplin "N27AZ" - http://www.maplin.co.uk/Search.aspx?criteria=N27AZ)\r
+If you use this successfully, consider feeding back to the arduino wiki with a note of which LCD it worked on.\r
+\r
+Usage:\r
+see the examples folder of this library distribution.\r
+\r
+*/\r
+\r
+#include "LCD4Bit_mod.h"\r
+extern "C" {\r
+  #include <stdio.h>  //not needed yet\r
+  #include <string.h> //needed for strlen()\r
+  #include <inttypes.h>\r
+  #include "WConstants.h"  //all things wiring / arduino\r
+}\r
+\r
+//command bytes for LCD\r
+#define CMD_CLR 0x01\r
+#define CMD_RIGHT 0x1C\r
+#define CMD_LEFT 0x18\r
+#define CMD_HOME 0x02\r
+\r
+// --------- PINS -------------------------------------\r
+//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.\r
+//this stops us sending signals to the RW pin if it isn't being used.\r
+int USING_RW = false;\r
+\r
+//RS, RW and Enable can be set to whatever you like\r
+int RS = 8;\r
+int RW = 11;\r
+int Enable = 9;\r
+//DB should be an unseparated group of pins  - because of lazy coding in pushNibble()\r
+int DB[] = {4, 5, 6, 7};  //wire these to DB4~7 on LCD.\r
+\r
+//--------------------------------------------------------\r
+\r
+//how many lines has the LCD? (don't change here - specify on calling constructor)\r
+int g_num_lines = 2;\r
+\r
+//pulse the Enable pin high (for a microsecond).\r
+//This clocks whatever command or data is in DB4~7 into the LCD controller.\r
+void LCD4Bit_mod::pulseEnablePin(){\r
+  digitalWrite(Enable,LOW);\r
+  delayMicroseconds(1);\r
+  // send a pulse to enable\r
+  digitalWrite(Enable,HIGH);\r
+  delayMicroseconds(1);\r
+  digitalWrite(Enable,LOW);\r
+  delay(1);  // pause 1 ms.  TODO: what delay, if any, is necessary here?\r
+}\r
+\r
+//push a nibble of data through the the LCD's DB4~7 pins, clocking with the Enable pin.\r
+//We don't care what RS and RW are, here.\r
+void LCD4Bit_mod::pushNibble(int value){\r
+  int val_nibble= value & 0x0F;  //clean the value.  (unnecessary)\r
+\r
+  for (int i=DB[0]; i <= DB[3]; i++) {\r
+    digitalWrite(i,val_nibble & 01);\r
+    val_nibble >>= 1;\r
+  }\r
+  pulseEnablePin();\r
+}\r
+\r
+//push a byte of data through the LCD's DB4~7 pins, in two steps, clocking each with the enable pin.\r
+void LCD4Bit_mod::pushByte(int value){\r
+  int val_lower = value & 0x0F;\r
+  int val_upper = value >> 4;\r
+  pushNibble(val_upper);\r
+  pushNibble(val_lower);\r
+}\r
+\r
+\r
+//stuff the library user might call---------------------------------\r
+//constructor.  num_lines must be 1 or 2, currently.\r
+LCD4Bit_mod::LCD4Bit_mod (int num_lines) {\r
+  g_num_lines = num_lines;\r
+  if (g_num_lines < 1 || g_num_lines > 2)\r
+  {\r
+    g_num_lines = 1;\r
+  }\r
+}\r
+\r
+void LCD4Bit_mod::commandWriteNibble(int nibble) {\r
+  digitalWrite(RS, LOW);\r
+  if (USING_RW) { digitalWrite(RW, LOW); }\r
+  pushNibble(nibble);\r
+}\r
+\r
+\r
+void LCD4Bit_mod::commandWrite(int value) {\r
+  digitalWrite(RS, LOW);\r
+  if (USING_RW) { digitalWrite(RW, LOW); }\r
+  pushByte(value);\r
+  //TODO: perhaps better to add a delay after EVERY command, here.  many need a delay, apparently.\r
+}\r
+\r
+\r
+\r
+\r
+//print the given character at the current cursor position. overwrites, doesn't insert.\r
+void LCD4Bit_mod::print(int value) {\r
+  //set the RS and RW pins to show we're writing data\r
+  digitalWrite(RS, HIGH);\r
+  if (USING_RW) { digitalWrite(RW, LOW); }\r
+\r
+  //let pushByte worry about the intricacies of Enable, nibble order.\r
+  pushByte(value);\r
+}\r
+\r
+\r
+//print the given string to the LCD at the current cursor position.  overwrites, doesn't insert.\r
+//While I don't understand why this was named printIn (PRINT IN?) in the original LiquidCrystal library, I've preserved it here to maintain the interchangeability of the two libraries.\r
+void LCD4Bit_mod::printIn(char msg[]) {\r
+  uint8_t i;  //fancy int.  avoids compiler warning when comparing i with strlen()'s uint8_t\r
+  for (i=0;i < strlen(msg);i++){\r
+    print(msg[i]);\r
+  }\r
+}\r
+\r
+\r
+//send the clear screen command to the LCD\r
+void LCD4Bit_mod::clear(){\r
+  commandWrite(CMD_CLR);\r
+  delay(1);\r
+}\r
+\r
+\r
+// initiatize lcd after a short pause\r
+//while there are hard-coded details here of lines, cursor and blink settings, you can override these original settings after calling .init()\r
+void LCD4Bit_mod::init () {\r
+  pinMode(Enable,OUTPUT);\r
+  pinMode(RS,OUTPUT);\r
+  if (USING_RW) { pinMode(RW,OUTPUT); }\r
+  pinMode(DB[0],OUTPUT);\r
+  pinMode(DB[1],OUTPUT);\r
+  pinMode(DB[2],OUTPUT);\r
+  pinMode(DB[3],OUTPUT);\r
+\r
+  delay(50);\r
+\r
+  //The first 4 nibbles and timings are not in my DEM16217 SYH datasheet, but apparently are HD44780 standard...\r
+  commandWriteNibble(0x03);\r
+  delay(5);\r
+  commandWriteNibble(0x03);\r
+  delayMicroseconds(100);\r
+  commandWriteNibble(0x03);\r
+  delay(5);\r
+\r
+  // needed by the LCDs controller\r
+  //this being 2 sets up 4-bit mode.\r
+  commandWriteNibble(0x02);\r
+  commandWriteNibble(0x02);\r
+  //todo: make configurable by the user of this library.\r
+  //NFXX where\r
+  //N = num lines (0=1 line or 1=2 lines).\r
+  //F= format (number of dots (0=5x7 or 1=5x10)).\r
+  //X=don't care\r
+\r
+  int num_lines_ptn = g_num_lines - 1 << 3;\r
+  int dot_format_ptn = 0x00;      //5x7 dots.  0x04 is 5x10\r
+\r
+  commandWriteNibble(num_lines_ptn | dot_format_ptn);\r
+  delayMicroseconds(60);\r
+\r
+  //The rest of the init is not specific to 4-bit mode.\r
+  //NOTE: we're writing full bytes now, not nibbles.\r
+\r
+  // display control:\r
+  // turn display on, cursor off, no blinking\r
+  commandWrite(0x0C);\r
+  delayMicroseconds(60);\r
+\r
+  //clear display\r
+  commandWrite(0x01);\r
+  delay(3);\r
+\r
+  // entry mode set: 06\r
+  // increment automatically, display shift, entire shift off\r
+  commandWrite(0x06);\r
+\r
+  delay(1);//TODO: remove unnecessary delays\r
+}\r
+\r
+\r
+//non-core stuff --------------------------------------\r
+//move the cursor to the given absolute position.  line numbers start at 1.\r
+//if this is not a 2-line LCD4Bit_mod instance, will always position on first line.\r
+void LCD4Bit_mod::cursorTo(int line_num, int x){\r
+  //first, put cursor home\r
+  commandWrite(CMD_HOME);\r
+\r
+  //if we are on a 1-line display, set line_num to 1st line, regardless of given\r
+  if (g_num_lines==1){\r
+    line_num = 1;\r
+  }\r
+  //offset 40 chars in if second line requested\r
+  if (line_num == 2){\r
+    x += 40;\r
+  }\r
+  //advance the cursor to the right according to position. (second line starts at position 40).\r
+  for (int i=0; i<x; i++) {\r
+    commandWrite(0x14);\r
+  }\r
+}\r
+\r
+//scroll whole display to left\r
+void LCD4Bit_mod::leftScroll(int num_chars, int delay_time){\r
+  for (int i=0; i<num_chars; i++) {\r
+    commandWrite(CMD_LEFT);\r
+    delay(delay_time);\r
+  }\r
+}\r
+\r
+//Improvements ------------------------------------------------\r
+//Remove the unnecessary delays (e.g. from the end of pulseEnablePin()).\r
+//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.\r
+//-------------------------------------------------------------\r
diff --git a/libraries/LCD4Bit_mod/LCD4Bit_mod.h b/libraries/LCD4Bit_mod/LCD4Bit_mod.h
new file mode 100644 (file)
index 0000000..5f054b3
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef LCD4Bit_mod_h\r
+#define LCD4Bit_mod_h\r
+\r
+#include <inttypes.h>\r
+\r
+class LCD4Bit_mod {\r
+public:\r
+  LCD4Bit_mod(int num_lines);\r
+  void commandWrite(int value);\r
+  void init();\r
+  void print(int value);\r
+  void printIn(char value[]);\r
+  void clear();\r
+  //non-core---------------\r
+  void cursorTo(int line_num, int x);\r
+  void leftScroll(int chars, int delay_time);\r
+  //end of non-core--------\r
+\r
+  //4bit only, therefore ideally private but may be needed by user\r
+  void commandWriteNibble(int nibble);\r
+private:\r
+  void pulseEnablePin();\r
+  void pushNibble(int nibble);\r
+  void pushByte(int value);\r
+};\r
+\r
+#endif\r
diff --git a/libraries/LCD4Bit_mod/WConstants.h b/libraries/LCD4Bit_mod/WConstants.h
new file mode 100644 (file)
index 0000000..5167caa
--- /dev/null
@@ -0,0 +1 @@
+#include "wiring.h"\r
diff --git a/libraries/LCD4Bit_mod/examples/LCD4Bit_Temperature/LCD4Bit_Temperature.pde b/libraries/LCD4Bit_mod/examples/LCD4Bit_Temperature/LCD4Bit_Temperature.pde
new file mode 100644 (file)
index 0000000..fec20f5
--- /dev/null
@@ -0,0 +1,179 @@
+//example use of LCD4Bit_mod library\r
+\r
+#include <LCD4Bit_mod.h> \r
+#include <stdio.h>\r
+\r
+#define TEMP_PIN 3\r
+//create object to control an LCD.  \r
+//number of lines in display=1\r
+LCD4Bit_mod lcd = LCD4Bit_mod(2); \r
+\r
+void getCurrentTemp(char *temp);\r
+\r
+//Key message\r
+int  adc_key_val[5] ={30, 150, 360, 535, 760 };\r
+int NUM_KEYS = 5;\r
+int adc_key_in;\r
+int key=-1;\r
+int oldkey=-1;\r
+\r
+void setup() { \r
+  pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat\r
+\r
+   // initialize DS18B20 datapin\r
+    digitalWrite(TEMP_PIN, LOW);\r
+    pinMode(TEMP_PIN, INPUT);      // sets the digital pin as input (logic 1)\r
+  lcd.init();\r
+  //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()\r
+  //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)\r
+   lcd.clear();\r
+  lcd.printIn("Temperature is");\r
+    \r
+}\r
+\r
+void loop() {\r
+\r
+  char temp_string[10];\r
+  adc_key_in = analogRead(0);    // read the value from the sensor  \r
+  key = get_key(adc_key_in);                   // convert into key press\r
+       \r
+ if (key != oldkey)                                // if keypress is detected\r
+ {\r
+    delay(50);         // wait for debounce time\r
+    adc_key_in = analogRead(0);    // read the value from the sensor  \r
+    key = get_key(adc_key_in);                 // convert into key press\r
+    if (key != oldkey)                         \r
+    {                  \r
+      oldkey = key;\r
+      getCurrentTemp(temp_string);\r
+      lcd.cursorTo(2, 0);  //line=2, x=0\r
+      lcd.printIn(temp_string);\r
+    }\r
+ }\r
\r
+  \r
+  \r
+}\r
+\r
+// Convert ADC value to key number\r
+int get_key(unsigned int input)\r
+{\r
+       int k;\r
+    \r
+       for (k = 0; k < NUM_KEYS; k++)\r
+       {\r
+               if (input < adc_key_val[k])\r
+               {\r
+           \r
+    return k;\r
+        }\r
+       }\r
+   \r
+    if (k >= NUM_KEYS)\r
+        k = -1;     // No valid key pressed\r
+    \r
+    return k;\r
+}\r
+\r
+\r
+void OneWireReset(int Pin) // reset.  Should improve to act as a presence pulse\r
+{\r
+     digitalWrite(Pin, LOW);\r
+     pinMode(Pin, OUTPUT); // bring low for 500 us\r
+     delayMicroseconds(500);\r
+     pinMode(Pin, INPUT);\r
+     delayMicroseconds(500);\r
+}\r
+\r
+void OneWireOutByte(int Pin, byte d) // output byte d (least sig bit first).\r
+{\r
+   byte n;\r
+\r
+   for(n=8; n!=0; n--)\r
+   {\r
+      if ((d & 0x01) == 1)  // test least sig bit\r
+      {\r
+         digitalWrite(Pin, LOW);\r
+         pinMode(Pin, OUTPUT);\r
+         delayMicroseconds(5);\r
+         pinMode(Pin, INPUT);\r
+         delayMicroseconds(60);\r
+      }\r
+      else\r
+      {\r
+         digitalWrite(Pin, LOW);\r
+         pinMode(Pin, OUTPUT);\r
+         delayMicroseconds(60);\r
+         pinMode(Pin, INPUT);\r
+      }\r
+\r
+      d=d>>1; // now the next bit is in the least sig bit position.\r
+   }\r
+   \r
+}\r
+\r
+byte OneWireInByte(int Pin) // read byte, least sig byte first\r
+{\r
+    byte d, n, b;\r
+\r
+    for (n=0; n<8; n++)\r
+    {\r
+        digitalWrite(Pin, LOW);\r
+        pinMode(Pin, OUTPUT);\r
+        delayMicroseconds(5);\r
+        pinMode(Pin, INPUT);\r
+        delayMicroseconds(5);\r
+        b = digitalRead(Pin);\r
+        delayMicroseconds(50);\r
+        d = (d >> 1) | (b<<7); // shift d to right and insert b in most sig bit position\r
+    }\r
+    return(d);\r
+}\r
+\r
+\r
+void getCurrentTemp(char *temp)\r
+{  \r
+  int HighByte, LowByte, TReading, Tc_100, sign, whole, fract;\r
+\r
+  OneWireReset(TEMP_PIN);\r
+  OneWireOutByte(TEMP_PIN, 0xcc);\r
+  OneWireOutByte(TEMP_PIN, 0x44); // perform temperature conversion, strong pullup for one sec\r
+\r
+  OneWireReset(TEMP_PIN);\r
+  OneWireOutByte(TEMP_PIN, 0xcc);\r
+  OneWireOutByte(TEMP_PIN, 0xbe);\r
+\r
+  LowByte = OneWireInByte(TEMP_PIN);\r
+  HighByte = OneWireInByte(TEMP_PIN);\r
+  TReading = (HighByte << 8) + LowByte;\r
+  sign = TReading & 0x8000;  // test most sig bit\r
+  if (sign) // negative\r
+  {\r
+    TReading = (TReading ^ 0xffff) + 1; // 2's comp\r
+  }\r
+  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25\r
+\r
+  whole = Tc_100 / 100;  // separate off the whole and fractional portions\r
+  fract = Tc_100 % 100;\r
+\r
+/*\r
+       if(sign) temp[0]='-';\r
+       else             temp[0]='+';\r
+       \r
+       temp[1]= whole%100+'0';\r
+       temp[2]= (whole-100*temp[1])%10 +'0' ;\r
+       temp[3]= whole-100*temp[1]-10*temp[2] +'0';\r
+       \r
+       temp[4]='.';\r
+       temp[5]=fract%10 +'0';\r
+       temp[6]=fract-temp[5]*10 +'0';\r
+       \r
+       temp[7] = '\0';\r
+*/\r
+\r
+       sprintf(temp, "%c%3d%c%2d", (sign==0)?'+':'-', whole, '.', fract);\r
+       \r
+}      \r
+       \r
+       \r
+       \r
diff --git a/libraries/LCD4Bit_mod/examples/LCD4Bit_modExample/LCD4Bit_modExample.pde b/libraries/LCD4Bit_mod/examples/LCD4Bit_modExample/LCD4Bit_modExample.pde
new file mode 100644 (file)
index 0000000..0e4eea7
--- /dev/null
@@ -0,0 +1,79 @@
+//example use of LCD4Bit_mod library\r
+\r
+#include <LCD4Bit_mod.h> \r
+//create object to control an LCD.  \r
+//number of lines in display=1\r
+LCD4Bit_mod lcd = LCD4Bit_mod(2); \r
+\r
+//Key message\r
+char msgs[5][15] = {"Right Key OK ", \r
+                    "Up Key OK    ", \r
+                    "Down Key OK  ", \r
+                    "Left Key OK  ", \r
+                    "Select Key OK" };\r
+int  adc_key_val[5] ={30, 150, 360, 535, 760 };\r
+int NUM_KEYS = 5;\r
+int adc_key_in;\r
+int key=-1;\r
+int oldkey=-1;\r
+\r
+void setup() { \r
+  pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat\r
+\r
+  lcd.init();\r
+  //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()\r
+  //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)\r
+   lcd.clear();\r
+  lcd.printIn("KEYPAD testing... pressing");\r
+    \r
+}\r
+\r
+void loop() {\r
+\r
+       adc_key_in = analogRead(0);    // read the value from the sensor  \r
+  digitalWrite(13, HIGH);  \r
+  key = get_key(adc_key_in);                   // convert into key press\r
+       \r
+       if (key != oldkey)                                  // if keypress is detected\r
+       {\r
+    delay(50);         // wait for debounce time\r
+               adc_key_in = analogRead(0);    // read the value from the sensor  \r
+    key = get_key(adc_key_in);                 // convert into key press\r
+    if (key != oldkey)                         \r
+    {                  \r
+      oldkey = key;\r
+      if (key >=0){\r
+      lcd.cursorTo(2, 0);  //line=2, x=0\r
+                       lcd.printIn(msgs[key]);\r
+      }\r
+    }\r
+  }\r
+  \r
+  //delay(1000);\r
+  digitalWrite(13, LOW);\r
+  \r
+\r
\r
+  \r
+  \r
+}\r
+\r
+// Convert ADC value to key number\r
+int get_key(unsigned int input)\r
+{\r
+       int k;\r
+    \r
+       for (k = 0; k < NUM_KEYS; k++)\r
+       {\r
+               if (input < adc_key_val[k])\r
+               {\r
+           \r
+    return k;\r
+        }\r
+       }\r
+    \r
+    if (k >= NUM_KEYS)\r
+        k = -1;     // No valid key pressed\r
+    \r
+    return k;\r
+}\r
diff --git a/libraries/LCD4Bit_mod/keywords.txt b/libraries/LCD4Bit_mod/keywords.txt
new file mode 100644 (file)
index 0000000..1296cd9
--- /dev/null
@@ -0,0 +1,27 @@
+#######################################
+# Syntax Coloring Map For Matrix
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+LCD4Bit_mod KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+clear          KEYWORD2
+commandWrite   KEYWORD2
+cursorTo       KEYWORD2
+init           KEYWORD2
+leftScroll     KEYWORD2
+print          KEYWORD2
+printIn        KEYWORD2
+commandWriteNibble     KEYWORD2
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+
diff --git a/libraries/LCD4Bit_mod/readme.txt b/libraries/LCD4Bit_mod/readme.txt
new file mode 100644 (file)
index 0000000..2bc7c2f
--- /dev/null
@@ -0,0 +1,38 @@
+This is a C++ library for Arduino for controlling an HD74800-compatible LCD in 4-bit mode.
+Tested on Arduino 0010 
+
+Installation
+--------------------------------------------------------------------------------
+
+To install this library, just place this entire folder as a subfolder in your
+Arduino/lib/targets/libraries folder.
+
+When installed, this library should look like:
+
+arduino-0010/hardware/libraries/LCD4Bit_mod              (this library's folder)
+arduino-0010/hardware/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp  (the library implementation file)
+arduino-0010/hardware/libraries/LCD4Bit_mod/LCD4Bit_mod.h    (the library description file)
+arduino-0010/hardware/libraries/LCD4Bit_mod/keywords.txt (the syntax coloring file)
+arduino-0010/hardware/libraries/LCD4Bit_mod/examples     (the examples in the "open" menu)
+arduino-0010/hardware/libraries/LCD4Bit_mod/readme.txt   (this file)
+
+Building
+--------------------------------------------------------------------------------
+
+After this library is installed, you just have to start the Arduino application.
+You may see a few warning messages as it's built.
+
+To use this library in a sketch, go to the Sketch | Import Library menu and
+select LCD4Bit_mod.  This will add a corresponding line to the top of your sketch:
+#include <LCD4Bit_mod.h>
+
+To stop using this library, delete that line from your sketch.
+
+Geeky information:
+After a successful build of this library, a new file named "LCD4Bit_mod.o" will appear
+in "Arduino/lib/targets/libraries/LCD4Bit". This file is the built/compiled library
+code.
+
+If you choose to modify the code for this library (i.e. "LCD4Bit_mod.cpp" or "LCD4Bit_mod.h"),
+then you must first 'unbuild' this library by deleting the "LCD4Bit_mod.o" file. The
+new "LCD4Bit_mod.o" with your code will appear after the next press of "verify"
diff --git a/libraries/LCD4Bit_mod/wiring.h b/libraries/LCD4Bit_mod/wiring.h
new file mode 100644 (file)
index 0000000..bd49ef3
--- /dev/null
@@ -0,0 +1,134 @@
+/*\r
+  wiring.h - Partial implementation of the Wiring API for the ATmega8.\r
+  Part of Arduino - http://www.arduino.cc/\r
+\r
+  Copyright (c) 2005-2006 David A. Mellis\r
+\r
+  This library is free software; you can redistribute it and/or\r
+  modify it under the terms of the GNU Lesser General Public\r
+  License as published by the Free Software Foundation; either\r
+  version 2.1 of the License, or (at your option) any later version.\r
+\r
+  This library is distributed in the hope that it will be useful,\r
+  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+  Lesser General Public License for more details.\r
+\r
+  You should have received a copy of the GNU Lesser General\r
+  Public License along with this library; if not, write to the\r
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,\r
+  Boston, MA  02111-1307  USA\r
+\r
+  $Id$\r
+*/\r
+\r
+#ifndef Wiring_h\r
+#define Wiring_h\r
+\r
+#include <avr/io.h>\r
+#include <stdlib.h>\r
+#include "binary.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C"{\r
+#endif\r
+\r
+#define HIGH 0x1\r
+#define LOW  0x0\r
+\r
+#define INPUT 0x0\r
+#define OUTPUT 0x1\r
+\r
+#define true 0x1\r
+#define false 0x0\r
+\r
+#define PI 3.1415926535897932384626433832795\r
+#define HALF_PI 1.5707963267948966192313216916398\r
+#define TWO_PI 6.283185307179586476925286766559\r
+#define DEG_TO_RAD 0.017453292519943295769236907684886\r
+#define RAD_TO_DEG 57.295779513082320876798154814105\r
+\r
+#define SERIAL  0x0\r
+#define DISPLAY 0x1\r
+\r
+#define LSBFIRST 0\r
+#define MSBFIRST 1\r
+\r
+#define CHANGE 1\r
+#define FALLING 2\r
+#define RISING 3\r
+\r
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)\r
+#define INTERNAL1V1 2\r
+#define INTERNAL2V56 3\r
+#else\r
+#define INTERNAL 3\r
+#endif\r
+#define DEFAULT 1\r
+#define EXTERNAL 0\r
+\r
+// undefine stdlib's abs if encountered\r
+#ifdef abs\r
+#undef abs\r
+#endif\r
+\r
+#define min(a,b) ((a)<(b)?(a):(b))\r
+#define max(a,b) ((a)>(b)?(a):(b))\r
+#define abs(x) ((x)>0?(x):-(x))\r
+#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))\r
+#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))\r
+#define radians(deg) ((deg)*DEG_TO_RAD)\r
+#define degrees(rad) ((rad)*RAD_TO_DEG)\r
+#define sq(x) ((x)*(x))\r
+\r
+#define interrupts() sei()\r
+#define noInterrupts() cli()\r
+\r
+#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )\r
+#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )\r
+#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )\r
+\r
+#define lowByte(w) ((uint8_t) ((w) & 0xff))\r
+#define highByte(w) ((uint8_t) ((w) >> 8))\r
+\r
+#define bitRead(value, bit) (((value) >> (bit)) & 0x01)\r
+#define bitSet(value, bit) ((value) |= (1UL << (bit)))\r
+#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))\r
+#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))\r
+\r
+typedef unsigned int word;\r
+\r
+#define bit(b) (1UL << (b))\r
+\r
+typedef uint8_t boolean;\r
+typedef uint8_t byte;\r
+\r
+void init(void);\r
+\r
+void pinMode(uint8_t, uint8_t);\r
+void digitalWrite(uint8_t, uint8_t);\r
+int digitalRead(uint8_t);\r
+int analogRead(uint8_t);\r
+void analogReference(uint8_t mode);\r
+void analogWrite(uint8_t, int);\r
+\r
+unsigned long millis(void);\r
+unsigned long micros(void);\r
+void delay(unsigned long);\r
+void delayMicroseconds(unsigned int us);\r
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);\r
+\r
+void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);\r
+uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);\r
+\r
+void attachInterrupt(uint8_t, void (*)(void), int mode);\r
+void detachInterrupt(uint8_t);\r
+\r
+void setup(void);\r
+void loop(void);\r
+\r
+#ifdef __cplusplus\r
+} // extern "C"\r
+#endif\r
+\r
+#endif\r