diff --git a/examples/Autoscroll/Autoscroll.ino b/examples/autoscroll.cpp similarity index 93% rename from examples/Autoscroll/Autoscroll.ino rename to examples/autoscroll.cpp index f70a1a7..93148c2 100644 --- a/examples/Autoscroll/Autoscroll.ino +++ b/examples/autoscroll.cpp @@ -1,74 +1,74 @@ -/* - LiquidCrystal Library - Autoscroll - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch demonstrates the use of the autoscroll() - and noAutoscroll() functions to make new text scroll or not. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll - - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); -} - -void loop() { - // set the cursor to (0,0): - lcd.setCursor(0, 0); - // print from 0 to 9: - for (int thisChar = 0; thisChar < 10; thisChar++) { - lcd.print(thisChar); - delay(500); - } - - // set the cursor to (16,1): - lcd.setCursor(16, 1); - // set the display to automatically scroll: - lcd.autoscroll(); - // print from 0 to 9: - for (int thisChar = 0; thisChar < 10; thisChar++) { - lcd.print(thisChar); - delay(500); - } - // turn off automatic scrolling - lcd.noAutoscroll(); - - // clear screen for the next loop: - lcd.clear(); -} - +/* + LiquidCrystal Library - Autoscroll + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates the use of the autoscroll() + and noAutoscroll() functions to make new text scroll or not. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll + + */ + +// include the library code: +#include +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); +} + +void loop() { + // set the cursor to (0,0): + lcd.setCursor(0, 0); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + + // set the cursor to (16,1): + lcd.setCursor(16, 1); + // set the display to automatically scroll: + lcd.autoscroll(); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + // turn off automatic scrolling + lcd.noAutoscroll(); + + // clear screen for the next loop: + lcd.clear(); +} \ No newline at end of file diff --git a/examples/Blink/Blink.ino b/examples/blink.cpp similarity index 96% rename from examples/Blink/Blink.ino rename to examples/blink.cpp index fea13a3..441aabb 100644 --- a/examples/Blink/Blink.ino +++ b/examples/blink.cpp @@ -37,10 +37,11 @@ */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows: diff --git a/examples/Cursor/Cursor.ino b/examples/cursor.cpp similarity index 96% rename from examples/Cursor/Cursor.ino rename to examples/cursor.cpp index 8699d27..7bd1c28 100644 --- a/examples/Cursor/Cursor.ino +++ b/examples/cursor.cpp @@ -38,10 +38,11 @@ */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows: @@ -57,5 +58,4 @@ void loop() { // Turn on the cursor: lcd.cursor(); delay(500); -} - +} \ No newline at end of file diff --git a/examples/CustomCharacter/CustomCharacter.ino b/examples/customcharacter.cpp similarity index 97% rename from examples/CustomCharacter/CustomCharacter.ino rename to examples/customcharacter.cpp index bdac95c..d4ac73f 100644 --- a/examples/CustomCharacter/CustomCharacter.ino +++ b/examples/customcharacter.cpp @@ -39,10 +39,11 @@ */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // make some custom characters: byte heart[8] = { @@ -137,4 +138,4 @@ void loop() { // draw him arms up: lcd.write(4); delay(delayTime); -} +} \ No newline at end of file diff --git a/examples/Display/Display.ino b/examples/display.cpp similarity index 96% rename from examples/Display/Display.ino rename to examples/display.cpp index 90b14f0..2460cd5 100644 --- a/examples/Display/Display.ino +++ b/examples/display.cpp @@ -38,10 +38,11 @@ */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows: @@ -57,5 +58,4 @@ void loop() { // Turn on the display: lcd.display(); delay(500); -} - +} \ No newline at end of file diff --git a/examples/HelloWorld/HelloWorld.ino b/examples/helloworld.cpp similarity index 96% rename from examples/HelloWorld/HelloWorld.ino rename to examples/helloworld.cpp index bf122d9..f5802b4 100644 --- a/examples/HelloWorld/HelloWorld.ino +++ b/examples/helloworld.cpp @@ -38,10 +38,11 @@ */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows: @@ -56,5 +57,4 @@ void loop() { lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis() / 1000); -} - +} \ No newline at end of file diff --git a/examples/Scroll/Scroll.ino b/examples/scroll.cpp similarity index 97% rename from examples/Scroll/Scroll.ino rename to examples/scroll.cpp index 0a4a95f..ea5e1cf 100644 --- a/examples/Scroll/Scroll.ino +++ b/examples/scroll.cpp @@ -38,10 +38,11 @@ */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows: @@ -81,6 +82,4 @@ void loop() { // delay at the end of the full loop: delay(1000); - -} - +} \ No newline at end of file diff --git a/examples/SerialDisplay/SerialDisplay.ino b/examples/serialdisplay.cpp similarity index 96% rename from examples/SerialDisplay/SerialDisplay.ino rename to examples/serialdisplay.cpp index 578e11e..054f29e 100644 --- a/examples/SerialDisplay/SerialDisplay.ino +++ b/examples/serialdisplay.cpp @@ -36,10 +36,11 @@ */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows: @@ -61,4 +62,4 @@ void loop() { lcd.write(Serial.read()); } } -} +} \ No newline at end of file diff --git a/examples/setCursor/setCursor.ino b/examples/setcursor.cpp similarity index 96% rename from examples/setCursor/setCursor.ino rename to examples/setcursor.cpp index d2dae93..2b75483 100644 --- a/examples/setCursor/setCursor.ino +++ b/examples/setcursor.cpp @@ -37,6 +37,7 @@ */ // include the library code: +#include #include // these constants won't change. But you can change the size of @@ -45,7 +46,7 @@ const int numRows = 2; const int numCols = 16; // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows: @@ -67,6 +68,4 @@ void loop() { } } } -} - - +} \ No newline at end of file diff --git a/examples/TextDirection/TextDirection.ino b/examples/textdirection.cpp similarity index 96% rename from examples/TextDirection/TextDirection.ino rename to examples/textdirection.cpp index c838d81..9593735 100644 --- a/examples/TextDirection/TextDirection.ino +++ b/examples/textdirection.cpp @@ -37,10 +37,11 @@ http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection */ // include the library code: +#include #include // initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); int thisChar = 'a'; diff --git a/src/main.cpp b/src/buttons.cpp similarity index 94% rename from src/main.cpp rename to src/buttons.cpp index 0cd6d50..5291b0a 100644 --- a/src/main.cpp +++ b/src/buttons.cpp @@ -1,80 +1,79 @@ -#include "Arduino.h" - -extern "C" { - #include "pb_decode.h" - #include "pb_encode.h" - #include "lcdkeypad.pb.h" -} - -#include - -// Select the pins used on the LCD panel -LiquidCrystal lcd(8, 9, 4, 5, 6, 7); - -// Define some values used by the panel and buttons -int lcd_key = 0; -int adc_key_in = 0; -#define btnRIGHT 0 -#define btnUP 1 -#define btnDOWN 2 -#define btnLEFT 3 -#define btnSELECT 4 -#define btnNONE 5 - -// Read the buttons -int read_LCD_buttons() { - // Read the value from the sensor - adc_key_in = analogRead(0); - - // Map buttons (v1.0 hardware) - if (adc_key_in > 1000) return btnNONE; - if (adc_key_in < 50) return btnRIGHT; - if (adc_key_in < 195) return btnUP; - if (adc_key_in < 380) return btnDOWN; - if (adc_key_in < 555) return btnLEFT; - if (adc_key_in < 790) return btnSELECT; - - return btnNONE; // when all others fail, return this... -} - -void setup() { - lcd.begin(16, 2); - lcd.setCursor(0, 0); - lcd.print("Push the buttons"); -} - -void loop() { - // Move cursor to second line "1" and 9 spaces over - lcd.setCursor(9, 1); - - // Display seconds elapsed since power-up - lcd.print(millis()/1000); - - // Move to the start of the second line - lcd.setCursor(0, 1); - - // Read the buttons - lcd_key = read_LCD_buttons(); - - // Print button status - switch (lcd_key) { - case btnRIGHT: - lcd.print("RIGHT "); - break; - case btnLEFT: - lcd.print("LEFT "); - break; - case btnUP: - lcd.print("UP "); - break; - case btnDOWN: - lcd.print("DOWN "); - break; - case btnSELECT: - lcd.print("SELECT"); - break; - case btnNONE: - lcd.print("NONE "); - break; - } +#include +#include + +extern "C" { + #include "pb_decode.h" + #include "pb_encode.h" + #include "lcdkeypad.pb.h" +} + +// Select the pins used on the LCD panel +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); + +// Define some values used by the panel and buttons +int lcd_key = 0; +int adc_key_in = 0; +#define btnRIGHT 0 +#define btnUP 1 +#define btnDOWN 2 +#define btnLEFT 3 +#define btnSELECT 4 +#define btnNONE 5 + +// Read the buttons +int read_LCD_buttons() { + // Read the value from the sensor + adc_key_in = analogRead(0); + + // Map buttons (v1.0 hardware) + if (adc_key_in > 1000) return btnNONE; + if (adc_key_in < 50) return btnRIGHT; + if (adc_key_in < 195) return btnUP; + if (adc_key_in < 380) return btnDOWN; + if (adc_key_in < 555) return btnLEFT; + if (adc_key_in < 790) return btnSELECT; + + return btnNONE; // when all others fail, return this... +} + +void setup() { + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Push the buttons"); +} + +void loop() { + // Move cursor to second line "1" and 9 spaces over + lcd.setCursor(9, 1); + + // Display seconds elapsed since power-up + lcd.print(millis()/1000); + + // Move to the start of the second line + lcd.setCursor(0, 1); + + // Read the buttons + lcd_key = read_LCD_buttons(); + + // Print button status + switch (lcd_key) { + case btnRIGHT: + lcd.print("RIGHT "); + break; + case btnLEFT: + lcd.print("LEFT "); + break; + case btnUP: + lcd.print("UP "); + break; + case btnDOWN: + lcd.print("DOWN "); + break; + case btnSELECT: + lcd.print("SELECT"); + break; + case btnNONE: + lcd.print("NONE "); + break; + } } \ No newline at end of file