Commits

F Malpartida  committed c57fe4c

Added new demo applications and corrected thermometer demo app.

  • Participants
  • Parent commits 6255e55
  • Tags V 1.1.3

Comments (0)

Files changed (3)

File LiquidCrystal_I2C.h

     the address can be configured using the on board jumpers.
     @param      En[in] LCD En (Enable) pin connected to the IO extender module
     @param      Rw[in] LCD Rw (Read/write) pin connected to the IO extender module
-    @para       Rs[in] LCD Rs (Reset) pin connected to the IO extender module
+    @param      Rs[in] LCD Rs (Reset) pin connected to the IO extender module
     */
    LiquidCrystal_I2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs);
    

File examples/HelloWorld_i2c/HelloWorld_i2c.pde

 #define BACKLIGHT_PIN     13
 
 // Creat a set of new characters
-byte smiley[8] = {
-  0b00000,
-  0b00000,
-  0b01010,
-  0b00000,
-  0b00000,
-  0b10001,
-  0b01110,
-  0b00000
-};
-
-byte armsUp[8] = {
-  0b00100,
-  0b01010,
-  0b00100,
-  0b10101,
-  0b01110,
-  0b00100,
-  0b00100,
-  0b01010
-};
-
-byte frownie[8] = {
-  0b00000,
-  0b00000,
-  0b01010,
-  0b00000,
-  0b00000,
-  0b00000,
-  0b01110,
-  0b10001
+const uint8_t charBitmap[][8] = {
+   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
+   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
+   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
+   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
+   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
+   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
+   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
+   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
+   
 };
 
 void setup()
 {
+   int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
+
   // Switch on the backlight
   pinMode ( BACKLIGHT_PIN, OUTPUT );
   digitalWrite ( BACKLIGHT_PIN, HIGH );
   
   lcd.begin(16,2);               // initialize the lcd 
 
-  lcd.createChar (0, smiley);    // load character to the LCD
-  lcd.createChar (1, armsUp);    // load character to the LCD
-  lcd.createChar (2, frownie);   // load character to the LCD
+   for ( int i = 0; i < charBitmapSize; i++ )
+   {
+      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
+   }
 
   lcd.home ();                   // go home
   lcd.print("Hello, ARDUINO ");  
   lcd.setCursor ( 0, 1 );        // go to the next line
-  lcd.print (" FORUM - fm   ");      
+  lcd.print (" FORUM - fm   ");
+  delay ( 1000 );
 }
 
 void loop()
 {
-  // Do a little animation by writing to the same location
-  lcd.setCursor ( 14, 1 );
-  lcd.print (char(2));
-  delay (200);
-  lcd.setCursor ( 14, 1 );
-  lcd.print ( char(0));
-  delay (200);
+   lcd.home ();
+   // Do a little animation by writing to the same location
+   for ( int i = 0; i < 2; i++ )
+   {
+      for ( int j = 0; j < 16; j++ )
+      {
+         lcd.print (char(random(7)));
+      }
+      lcd.setCursor ( 0, 1 );
+   }
+   delay (200);
 }

File examples/i2cLCDextraIO/i2cLCDextraIO.pde

 #include <Arduino.h>
 #include <Wire.h>
 #include <LCD.h>
-#include "thermistor.h"
-#include "analogTemp.h"
 
 #define _LCD_I2C_
 
                 correct temperature reading from the internal temperature sensor
                 of your AVR.
 */
-#define TEMP_CAL_OFFSET 335
+#define TEMP_CAL_OFFSET 334
 
 /*!
     @defined    FILTER_ALP
 LCD *myLCD = &lcd;
 
 static double tempFilter;
-thermistor *tempSensor;
-static analogTemp myTemp; 
 
 
 /*!
    { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 },
    { 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 },
    { 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 },
-   { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 }
+   { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 },
+   { 0xe, 0x11, 0x11, 0x11, 0xe, 0, 0, 0 },
+   { 0x6, 0x9, 0x9, 0x6, 0x0, 0, 0, 0}
 };
 
 /*!
    myLCD->print (start);
 
    // Calculate the size of the bar
-   value = map ( value, -30, 45, 0, ( barLength ) * CHAR_WIDTH );
+   value = map ( value, -30, 50, 0, ( barLength ) * CHAR_WIDTH );
    numBars = value / CHAR_WIDTH;
    
    // Limit the size of the bargraph to barLength
 #endif
 
    myLCD->begin ( 16, 2 );
-
-   
-   myTemp.setCalOffset ( TEMP_CAL_OFFSET );
-   tempSensor = &myTemp;
-   tempSensor->init ();
   
    // Load custom character set into CGRAM
    for ( i = 0; i < charBitmapSize; i++ )
    Serial.println ( freeMemory () );
 
    myLCD->clear ();
-   myLCD->print ("Temperature:");
+   myLCD->print ("Temp:");
 
-   tempFilter = tempSensor->readTemperature (); // Initialise the temperature Filter
+   tempFilter = readTemperature (); // Initialise the temperature Filter
 
 }
 
 void loop ()
 {
   int temp;
-  unsigned long time, diff;
   
-  temp = tempSensor->readTemperature();
+  temp = readTemperature();
   tempFilter = ( FILTER_ALP * temp) + (( 1.0 - FILTER_ALP ) * tempFilter);
 
-  time = micros ();
-  myLCD->setCursor ( 11, 1 );
+  myLCD->setCursor ( 8, 0 );
   myLCD->print ("     ");
-  myLCD->setCursor ( 11, 1 );
-  myLCD->print ( tempFilter, 1 );  
-  myLCD->setCursor (1, 0);
-  drawBars ( tempFilter, 1, 7, '-', '+' );
-  Serial.println (micros() - time);
+  myLCD->setCursor ( 8, 0 );
+  myLCD->print ( tempFilter, 1 );
+  myLCD->setCursor ( 12, 0 );
+  myLCD->print ( "\x07" );
+  myLCD->print ("C");  
+  drawBars ( tempFilter, 1, 14, '-', '+' );
   
   delay (200);
 }