Is it possible for you to provide a list of the LCD types that you would consider to be included in the class? I'd be willing to set up a test, but the only LCD I have is a generic 16x2.
Right. I have Uno R3 (China) with Mango LCD Keypad Shield currently running with;
//Sample using LiquidCrystal library
#include <LiquidCrystal.h>
/*******************************************************
This program will test the LCD panel and the buttons
Mark Bramwell, July 2010
********************************************************/
// 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()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
// For V1.1 us this threshold
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 450) return btnDOWN;
if (adc_key_in < 650) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;
return btnNONE; // when all others fail, return this...
}
void setup()
{
Serial.begin(9600);
Serial.println("LCD_Test");
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Push the buttons"); // print a simple message
}
void loop()
{
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up
lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key) // depending on which button was pushed, we perform an action
{
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;
}
}
}
Available now for your tests.
First kick at the cat.
Original library:
Sketch uses 3078 bytes (9%) of program storage space. Maximum is 32256 bytes.
Global variables use 296 bytes (14%) of dynamic memory, leaving 1752 bytes for local variables. Maximum is 2048 bytes.
Your library:
Sketch uses 3100 bytes (9%) of program storage space. Maximum is 32256 bytes.
Global variables use 297 bytes (14%) of dynamic memory, leaving 1751 bytes for local variables.
Screen comes up with 'Push the buttons' but no other display. No timer display and the buttons are not reflected.
Always a promising start.
No offense, but IMHO, we need another LCD library like we need a hole in our collective heads.
I don't think this is about creating a new LCD library but rather allowing the existing libraries to share the non-hardware specific code. That makes good sense to me.
I think Adafruit did something similar with their Adafruit GFX and Unified sensor libraries.
The question is whether you can get the LCD library authors on board. Some of the popular LiquidCrystal_I2C libraries seem to have been abandoned.
It seems somewhat related to what Arduino is doing with the new Arduino Core API (AKA "Project Chainsaw"), where they are taking all the non-architecture specific code out of the core libraries so that all the hardware packages can share that code:
I've been doing the same thing in my code for the different TFT and OLED displays I've been using. No matter what I'm drawing, it all now works the same. HUGE time & brain saver.
But it was a lot of typing..
-jim lee
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.