Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred Jonsson committed May 28, 2012
1 parent 77ed2f4 commit f82ec65
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
28 changes: 13 additions & 15 deletions libraries/LiquidCrystal/LiquidCrystal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,17 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
else
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;

begin(16, 1);
}

void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
if (lines > 1) {
void LiquidCrystal::begin(uint8_t cols, uint8_t rows, uint8_t dotsize) {
if (rows > 1) {
_displayfunction |= LCD_2LINE;
}
_numlines = lines;
_currline = 0;
_numcols = cols;
_numrows = rows;

// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
if ((dotsize != 0) && (rows == 1)) {
_displayfunction |= LCD_5x10DOTS;
}

Expand Down Expand Up @@ -151,7 +149,7 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
clear();

// Initialize to default text direction (for romance languages)
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDISABLE;
// set the entry mode
command(LCD_ENTRYMODESET | _displaymode);

Expand All @@ -172,9 +170,9 @@ void LiquidCrystal::home()

void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row >= _numlines ) {
row = _numlines-1; // we count rows starting w/0
int row_offsets[] = { 0x00, 0x40, _numcols, 0x40 + _numcols };
if ( row >= _numrows ) {
row = _numrows - 1; // we count rows starting w/0
}

command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
Expand Down Expand Up @@ -230,15 +228,15 @@ void LiquidCrystal::rightToLeft(void) {
command(LCD_ENTRYMODESET | _displaymode);
}

// This will 'right justify' text from the cursor
// This will move the text on write, looks like a fixed cursor
void LiquidCrystal::autoscroll(void) {
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
_displaymode |= LCD_ENTRYSHIFTENABLE;
command(LCD_ENTRYMODESET | _displaymode);
}

// This will 'left justify' text from the cursor
// This will fix the text and moves the cursor on write
void LiquidCrystal::noAutoscroll(void) {
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
_displaymode &= ~LCD_ENTRYSHIFTENABLE;
command(LCD_ENTRYMODESET | _displaymode);
}

Expand Down
9 changes: 4 additions & 5 deletions libraries/LiquidCrystal/LiquidCrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
// flags for display entry mode
#define LCD_ENTRYRIGHT 0x00
#define LCD_ENTRYLEFT 0x02
#define LCD_ENTRYSHIFTINCREMENT 0x01
#define LCD_ENTRYSHIFTDECREMENT 0x00
#define LCD_ENTRYSHIFTENABLE 0x01
#define LCD_ENTRYSHIFTDISABLE 0x00

// flags for display on/off control
#define LCD_DISPLAYON 0x04
Expand Down Expand Up @@ -98,9 +98,8 @@ class LiquidCrystal : public Print {
uint8_t _displaycontrol;
uint8_t _displaymode;

uint8_t _initialized;

uint8_t _numlines,_currline;
uint8_t _numcols;
uint8_t _numrows;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ byte armsUp[8] = {
0b01010
};
void setup() {
// set up the lcd's number of columns and rows:
lcd.begin(16, 2);

// create a new character
lcd.createChar(0, heart);
// create a new character
Expand All @@ -108,8 +111,6 @@ void setup() {
// create a new character
lcd.createChar(4, armsUp);

// set up the lcd's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the lcd.
lcd.print("I ");
lcd.write(0);
Expand Down

0 comments on commit f82ec65

Please sign in to comment.