F Malpartida avatar F Malpartida committed 3503588

Added performance enhancements to the liquidCrystal library and the liquidCrystal_I2C library.

Comments (0)

Files changed (5)

 #endif
 
 #include <inttypes.h>
-#include <Wire.h>
+#include <../Wire/Wire.h>
 #include <I2CIO.h>
 
 // CLASS VARIABLES

LiquidCrystal.cpp

 // pulseEnable
 void LiquidCrystal::pulseEnable(void) 
 {
+   // There is no need for the delays, since the digitalWrite operation
+   // takes longer.
    digitalWrite(_enable_pin, LOW);
-   delayMicroseconds(1);
+   //delayMicroseconds(1);
    
    digitalWrite(_enable_pin, HIGH);
-   delayMicroseconds(1);           // enable pulse must be > 450ns
+   //delayMicroseconds(1);          // enable pulse must be > 450ns
    
    digitalWrite(_enable_pin, LOW);
-   delayMicroseconds(100);         // commands need > 37us to settle
+   //delayMicroseconds(37);         // commands need > 37us to settle
 }
 
 //
    for (uint8_t i = 0; i < 8; i++) 
    {
       digitalWrite(_data_pins[i], (value >> i) & 0x01);
-   }
-   
+   }   
    pulseEnable();
 }

LiquidCrystal_I2C.cpp

 // write4bits
 void LiquidCrystal_I2C::pulseEnable (uint8_t _data)
 {
+   // No need to use the delay routines since the time taken to write takes
+   // longer that what is needed.
 	expanderWrite (_data | En);	// En HIGH
-	delayMicroseconds(1);		   // enable pulse must be >450ns
-	
-	expanderWrite(_data & ~En);  // En low
-	delayMicroseconds(50);		  // commands need > 37us to settle
+	//delayMicroseconds(1);		   // enable pulse must be >450ns
+   
+	expanderWrite(_data & ~En);   // En low
+	//delayMicroseconds(50);		// commands need > 37us to settle
 } 
 
 //

LiquidCrystal_I2C.h

 #define LiquidCrystal_I2C_h
 #include <inttypes.h>
 #include <Print.h>
-#include <Wire.h>
 #include <I2CIO.h>
 #include <LCD.h>
 

examples/i2cLCDextraIO/i2cLCDextraIO.pde

                 correct temperature reading from the internal temperature sensor
                 of your AVR.
 */
-#define TEMP_CAL_OFFSET 336
+#define TEMP_CAL_OFFSET 335
 
 /*!
     @defined    FILTER_ALP
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 const int    CONTRAST_PIN  = 9;
 const int    BACKLIGHT_PIN = 7;
-const int    CONTRAST      = 125;
+const int    CONTRAST      = 130;
 #endif
 
 
    myLCD->print (start);
 
    // Calculate the size of the bar
-   value = map ( value, -10, 45, 0, ( barLength ) * CHAR_WIDTH );
+   value = map ( value, -30, 45, 0, ( barLength ) * CHAR_WIDTH );
    numBars = value / CHAR_WIDTH;
    
    // Limit the size of the bargraph to barLength
   drawBars ( tempFilter, 1, 7, '-', '+' );
   Serial.println (micros() - time);
   
-  delay (1000);
+  delay (200);
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.