mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
Remove duplicate copies of LCD examples
This commit is contained in:
parent
fa9284a5a3
commit
466b5124d2
@ -1,62 +0,0 @@
|
||||
/*
|
||||
This example demonstrates how to use the Form and Field classes from the
|
||||
LCD library to provide a simple UI on the 16x2 LCD display.
|
||||
|
||||
This example is placed into the public domain.
|
||||
*/
|
||||
|
||||
// include the library code:
|
||||
#include <LCD.h>
|
||||
#include <Form.h>
|
||||
#include <TextField.h>
|
||||
#include <TimeField.h>
|
||||
#include <IntField.h>
|
||||
#include <BoolField.h>
|
||||
|
||||
// Initialize the LCD
|
||||
LCD lcd;
|
||||
|
||||
// Note: if you are using the USBDroid and have reassigned pin D9 on the LCD shield to some
|
||||
// other pin (e.g. A1), then you will need to initialize the shield with something like:
|
||||
// LCD lcd(A1);
|
||||
// See also: http://www.freetronics.com/pages/combining-the-lcd-keypad-shield-and-the-usbdroid
|
||||
|
||||
// Create the main form and its fields.
|
||||
Form mainForm(lcd);
|
||||
TextField welcomeField(mainForm, "Form example", "v1.0");
|
||||
TimeField timeField(mainForm, "Time since reset", 24, TIMEFIELD_READ_ONLY);
|
||||
IntField volumeField(mainForm, "Volume", 0, 100, 5, 85, "%");
|
||||
BoolField ledField(mainForm, "Status LED", "On", "Off", true);
|
||||
TimeField durationField(mainForm, "Timer duration", 24, TIMEFIELD_READ_WRITE);
|
||||
|
||||
#define STATUS_LED 13
|
||||
|
||||
void setup() {
|
||||
// Status LED initially on.
|
||||
pinMode(STATUS_LED, OUTPUT);
|
||||
digitalWrite(STATUS_LED, HIGH);
|
||||
|
||||
// Enable the screen saver, which will automatically blank the screen after 10 seconds.
|
||||
// The screen will wake up again when a button is pressed or lcd.display() is called.
|
||||
lcd.enableScreenSaver();
|
||||
|
||||
// Show the main form for the first time.
|
||||
mainForm.show();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Update the number of seconds since reset:
|
||||
timeField.setValue(millis() / 1000);
|
||||
|
||||
// Dispatch button events to the main form.
|
||||
int event = lcd.getButton();
|
||||
if (mainForm.dispatch(event) == FORM_CHANGED) {
|
||||
if (mainForm.isCurrent(ledField)) {
|
||||
if (ledField.value())
|
||||
digitalWrite(STATUS_LED, HIGH);
|
||||
else
|
||||
digitalWrite(STATUS_LED, LOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
This example demonstrates how to use the LCD library, which extends the
|
||||
standard LiquidCrystal library to provide support for the Freetronics back light
|
||||
and Up/Down/Left/Right/Select buttons. More information on the shield here:
|
||||
|
||||
http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide
|
||||
|
||||
This example is placed into the public domain.
|
||||
*/
|
||||
|
||||
// include the library code:
|
||||
#include <LCD.h>
|
||||
|
||||
// initialize the library
|
||||
LCD lcd;
|
||||
|
||||
// Note: if you are using the USBDroid and have reassigned pin D9 on the LCD shield to some
|
||||
// other pin (e.g. A1), then you will need to initialize the shield with something like:
|
||||
// LCD lcd(A1);
|
||||
// See also: http://www.freetronics.com/pages/combining-the-lcd-keypad-shield-and-the-usbdroid
|
||||
|
||||
void setup() {
|
||||
// Enable the screen saver, which will automatically blank the screen after 10 seconds.
|
||||
// The screen will wake up again when a button is pressed or lcd.display() is called.
|
||||
lcd.enableScreenSaver();
|
||||
|
||||
// Print a message to the LCD.
|
||||
lcd.print("hello, world!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// set the cursor to column 0, line 1
|
||||
// (note: line 1 is the second row, since counting begins with 0):
|
||||
lcd.setCursor(0, 1);
|
||||
// print the number of seconds since reset:
|
||||
lcd.print(millis()/1000);
|
||||
|
||||
// print the name of the button that is currently pressed
|
||||
lcd.setCursor(8, 1);
|
||||
int button = lcd.getButton();
|
||||
if (button == LCD_BUTTON_LEFT)
|
||||
lcd.print("LEFT");
|
||||
else if (button == LCD_BUTTON_RIGHT)
|
||||
lcd.print("RIGHT");
|
||||
else if (button == LCD_BUTTON_UP)
|
||||
lcd.print("UP");
|
||||
else if (button == LCD_BUTTON_DOWN)
|
||||
lcd.print("DOWN");
|
||||
else if (button == LCD_BUTTON_SELECT)
|
||||
lcd.print("SELECT");
|
||||
else if (button < 0) // button release
|
||||
lcd.print(" ");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user