Added new demo applications and corrected thermometer demo app.
This commit is contained in:
+1
-1
@@ -92,7 +92,7 @@ public:
|
||||
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);
|
||||
|
||||
|
||||
@@ -6,64 +6,51 @@ LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address
|
||||
#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);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <LCD.h>
|
||||
#include "thermistor.h"
|
||||
#include "analogTemp.h"
|
||||
|
||||
#define _LCD_I2C_
|
||||
|
||||
@@ -37,7 +35,7 @@
|
||||
correct temperature reading from the internal temperature sensor
|
||||
of your AVR.
|
||||
*/
|
||||
#define TEMP_CAL_OFFSET 335
|
||||
#define TEMP_CAL_OFFSET 334
|
||||
|
||||
/*!
|
||||
@defined FILTER_ALP
|
||||
@@ -67,8 +65,6 @@ const int CONTRAST = 130;
|
||||
LCD *myLCD = &lcd;
|
||||
|
||||
static double tempFilter;
|
||||
thermistor *tempSensor;
|
||||
static analogTemp myTemp;
|
||||
|
||||
|
||||
/*!
|
||||
@@ -83,7 +79,9 @@ const uint8_t charBitmap[][8] = {
|
||||
{ 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}
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -150,7 +148,7 @@ static void drawBars ( int value, uint8_t row, uint8_t barLength, char start,
|
||||
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
|
||||
@@ -197,11 +195,6 @@ void setup ()
|
||||
#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++ )
|
||||
@@ -211,9 +204,9 @@ void setup ()
|
||||
Serial.println ( freeMemory () );
|
||||
|
||||
myLCD->clear ();
|
||||
myLCD->print ("Temperature:");
|
||||
myLCD->print ("Temp:");
|
||||
|
||||
tempFilter = tempSensor->readTemperature (); // Initialise the temperature Filter
|
||||
tempFilter = readTemperature (); // Initialise the temperature Filter
|
||||
|
||||
}
|
||||
|
||||
@@ -221,19 +214,18 @@ void setup ()
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user