Hello,
for my multidisplay, i need a fast LCD, and like others have seen the basic Arduino Libarys are quite slow...
so, with some changes the LCD4Bit Libary can reach impressive speeds! ![]()
you can modify the LCD4Bit with some assembler, and never use the "cursorTo" Function.
heres the change:
void LCD4Bit::pulseEnablePin(){
digitalWrite(Enable,LOW);
asm("nop\n");
// send a pulse to enable
digitalWrite(Enable,HIGH);
asm("nop\n");
digitalWrite(Enable,LOW);
asm("nop\n");
}
delete the LCD4Bit.o after modifying LCD4Bit.cpp.
and for positioning the cursor use:
lcd.commandWrite(0x80); //Line=1, Cursor 0
lcd.commandWrite(0xC0+val); //Line=2, Cursor val
lcd.commandWrite(0x94+7); //Line=3, Cursor 7
lcd.commandWrite(0xD4); //Line=4, Cursor 0
give it a try, the difference is impressive for so little changes ![]()
the code in the samplevid from above:
#include <LCD4Bit.h>
LCD4Bit lcd = LCD4Bit(4);
/*==============================================================================
* GLOBAL VARIABLES
*============================================================================*/
//Variables:
int val = 0; // variable to store the value coming from the sensor
int val2 = 0;
int valT1 = 0; // variable to store the Temp Case
/*==============================================================================
* FUNCTIONS
*============================================================================*/
/*==============================================================================
* SETUP()
*============================================================================*/
void setup() {
lcd.init(); //Inits the LCD
}
/*==============================================================================
* LOOP()
*============================================================================*/
void loop() {
//Lets start the loop for the Value Displaying:
//get the Analog Value:
val = analogRead(0)/50;
lcd.commandWrite(0x80);
for (int i=0; i <= 20; i++){
lcd.commandWrite(0x80+i);
//lcd.cursorTo(1,i);
lcd.print(255);
lcd.commandWrite(0xC0+i);
//lcd.cursorTo(2,i);
lcd.print(255);
lcd.commandWrite(0x94+i);
lcd.print(255);
lcd.commandWrite(0xD4+i);
lcd.print(255);
delay(val);
}
lcd.commandWrite(0x80);
for (int i=0; i <= 20; i++){
lcd.commandWrite(0x80+i);
//lcd.cursorTo(1,i);
lcd.print(23);
lcd.commandWrite(0xC0+i);
//lcd.cursorTo(2,i);
lcd.print(23);
lcd.commandWrite(0x94+i);
lcd.print(23);
lcd.commandWrite(0xD4+i);
lcd.print(23);
delay(val);
}
}
designer2k2