Alphanumeric LCD Library for Arduino  1.0.4
LCD Control library for Arduino
 All Classes Files Functions Variables Macros Pages
AlphaLCD Class Reference

#include "AlphaLCD.h"

+ Inheritance diagram for AlphaLCD:

Public Member Functions

 AlphaLCD ()
 Constructor with no parameters, to create initial class instances. More...
 
 AlphaLCD (uint8_t dp, uint8_t cp, uint8_t lp)
 Constructor with the hardware initialization parameters (pin numbers) More...
 
void init (uint8_t dp, uint8_t cp, uint8_t lp)
 Hardware initialization. More...
 
void begin (uint8_t cols, uint8_t rows, uint8_t charsize=0x00)
 Start the LCD modes and initializes the software configuration parameters. More...
 
void clear ()
 Clear the display content and set the cursor to the position (0,0) More...
 
void home ()
 Set the cursor to the position (0,0) More...
 
void noDisplay ()
 Turn off the display. More...
 
void display ()
 Turn on the display. More...
 
void noBlink ()
 Turn off the blinking cursor. More...
 
void blink ()
 Turn off the blinking cursor. More...
 
void noCursor ()
 Turn off the underline cursor. More...
 
void cursor ()
 Turn on the underline cursor. More...
 
void scrollDisplayLeft ()
 Scroll the display to the left by one position. More...
 
void scrollDisplayRight ()
 Scroll the display to the right by one position. More...
 
void leftToRight ()
 Flow the text from left to right. More...
 
void rightToLeft ()
 Flow the text from right to left. More...
 
void autoscroll ()
 Enable the automatic horizontal scrolling of the text. More...
 
void noAutoscroll ()
 Disable the automatic horizontal scrolling of the text. More...
 
void isDisplay (bool set)
 Helper method to set on/off the display. More...
 
void isCursor (bool set)
 Helper method to set on/off the cursor visibility. More...
 
void isBlinking (bool set)
 Helper method to set on/off the blinking cursor. More...
 
void isRightToLeft (bool set)
 Helper method to set on/off the right-to-left writing direction. More...
 
void isAutoscroll (bool set)
 Helper method to set on/off autoscroll. More...
 
void createChar (uint8_t, uint8_t[])
 Create one of the 8 CGRAM memory locations from 0x00 to 0x07 with a user defined characters. More...
 
void setCursor (uint8_t, uint8_t)
 Set the cursor to the requested position. More...
 
virtual size_t write (uint8_t)
 Helper method to send data to the device. More...
 
void command (uint8_t)
 Helper method to send commands to the device. More...
 

Private Member Functions

void send (uint8_t, uint8_t)
 Write either command or data, with automatic 4/8-bit selection. More...
 
void write4bits (uint8_t, uint8_t)
 Write the character on the device, 4 bits mode. More...
 
void write8bits (uint8_t, uint8_t)
 Write the character on the device, 8 bits mode. More...
 

Private Attributes

uint8_t _clock_pin
 
uint8_t _data_pin
 
uint8_t _latch_pin
 
uint8_t _smart_enable
 
uint8_t _displayfunction
 
uint8_t _displaycontrol
 
uint8_t _displaymode
 
uint8_t _backlight
 
uint8_t _initialized
 
uint8_t _numlines
 
uint8_t _currline
 

Detailed Description

Definition at line 65 of file AlphaLCD.h.

Constructor & Destructor Documentation

AlphaLCD::AlphaLCD ( )

Constructor with no parameters, to create initial class instances.

Definition at line 32 of file AlphaLCD.cpp.

32  {
33 
34 }
AlphaLCD::AlphaLCD ( uint8_t  dp,
uint8_t  cp,
uint8_t  lp 
)

Constructor with the hardware initialization parameters (pin numbers)

parameters depends on the phisycal connection of the LCD-Alpha component.

Definition at line 41 of file AlphaLCD.cpp.

References init().

42 {
43  init (dp, cp, lp);
44 }
void init(uint8_t dp, uint8_t cp, uint8_t lp)
Hardware initialization.
Definition: AlphaLCD.cpp:56

Member Function Documentation

void AlphaLCD::autoscroll ( void  )

Enable the automatic horizontal scrolling of the text.

As the scrolling is done on the entire display content, the resulting effect is like the right justification

Definition at line 270 of file AlphaLCD.cpp.

References _displaymode, command(), LCD_ENTRYMODESET, and LCD_ENTRYSHIFTINCREMENT.

Referenced by isAutoscroll().

270  {
273 }
uint8_t _displaymode
Definition: AlphaLCD.h:111
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_ENTRYMODESET
Definition: AlphaLCD.h:30
#define LCD_ENTRYSHIFTINCREMENT
Definition: AlphaLCD.h:39
void AlphaLCD::begin ( uint8_t  cols,
uint8_t  lines,
uint8_t  dotsize = 0x00 
)

Start the LCD modes and initializes the software configuration parameters.

Note
The method avoid displays with more than 2 lines

int Number of columns (hardware settings: 16 characters) int number of lines (hardware settings: 2 lines)

Definition at line 83 of file AlphaLCD.cpp.

References _clock_pin, _currline, _data_pin, _displaycontrol, _displayfunction, _displaymode, _numlines, clear(), command(), display(), LCD_2LINE, LCD_5x10DOTS, LCD_8BITMODE, LCD_BLINKOFF, LCD_CURSOROFF, LCD_DISPLAYON, LCD_ENTRYLEFT, LCD_ENTRYMODESET, LCD_ENTRYSHIFTDECREMENT, LCD_FUNCTIONSET, and write4bits().

Referenced by init().

83  {
84  if (lines > 1) {
86  }
87 
88  _numlines = lines;
89  _currline = 0;
90 
91  // for some 1 line displays you can select a 10 pixel height font
92  if ((dotsize != 0) && (lines == 1)) {
94  }
95 
96  // We need at least 40ms after power rises before sending commands.
97  delayMicroseconds(50000);
98  // clear the shift register by sending 16 0's to it (twice)
99  shiftOut(_data_pin, _clock_pin, LSBFIRST, B00000000);
100  shiftOut(_data_pin, _clock_pin, LSBFIRST, B00000000);
101 
102  //put the LCD into 4 bit or 8 bit mode
103  if (! (_displayfunction & LCD_8BITMODE)) {
104 
105  // we start in 8bit mode, try to set 4 bit mode
106  write4bits(0x03, LOW);
107  delayMicroseconds(4500);
108 
109  // second try
110  write4bits(0x03, LOW);
111  delayMicroseconds(4500);
112 
113  // third go!
114  write4bits(0x03, LOW);
115  delayMicroseconds(150);
116 
117  // set to 8-bit interface
118  write4bits(0x02, LOW);
119  } else {
120  // Send function set command sequence
122  delayMicroseconds(4500);
123 
124  // second try
126  delayMicroseconds(150);
127 
128  // third go
130  }
131 
132  // finally, set # lines, font size, etc.
134 
135  // turn the display on with no cursor or blinking by default
137  display();
138 
139  // clear it off
140  clear();
141 
142  // Initialize to default text direction (for romance languages)
144  // set the entry mode
146 
147 }
uint8_t _displaymode
Definition: AlphaLCD.h:111
#define LCD_FUNCTIONSET
Definition: AlphaLCD.h:33
#define LCD_5x10DOTS
Definition: AlphaLCD.h:58
uint8_t _clock_pin
Definition: AlphaLCD.h:105
uint8_t _data_pin
Definition: AlphaLCD.h:106
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
uint8_t _numlines
Definition: AlphaLCD.h:114
void write4bits(uint8_t, uint8_t)
Write the character on the device, 4 bits mode.
Definition: AlphaLCD.cpp:369
#define LCD_8BITMODE
Definition: AlphaLCD.h:54
#define LCD_ENTRYMODESET
Definition: AlphaLCD.h:30
#define LCD_CURSOROFF
Definition: AlphaLCD.h:45
uint8_t _displayfunction
Definition: AlphaLCD.h:109
#define LCD_ENTRYLEFT
Definition: AlphaLCD.h:38
uint8_t _displaycontrol
Definition: AlphaLCD.h:110
uint8_t _currline
Definition: AlphaLCD.h:114
void display()
Turn on the display.
Definition: AlphaLCD.cpp:197
#define LCD_DISPLAYON
Definition: AlphaLCD.h:42
#define LCD_ENTRYSHIFTDECREMENT
Definition: AlphaLCD.h:40
#define LCD_BLINKOFF
Definition: AlphaLCD.h:47
#define LCD_2LINE
Definition: AlphaLCD.h:56
void clear()
Clear the display content and set the cursor to the position (0,0)
Definition: AlphaLCD.cpp:152
void AlphaLCD::blink ( )

Turn off the blinking cursor.

Definition at line 229 of file AlphaLCD.cpp.

References _displaycontrol, command(), LCD_BLINKON, and LCD_DISPLAYCONTROL.

Referenced by isBlinking().

229  {
232 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_BLINKON
Definition: AlphaLCD.h:46
uint8_t _displaycontrol
Definition: AlphaLCD.h:110
#define LCD_DISPLAYCONTROL
Definition: AlphaLCD.h:31
void AlphaLCD::clear ( )

Clear the display content and set the cursor to the position (0,0)

Definition at line 152 of file AlphaLCD.cpp.

References command(), and LCD_CLEARDISPLAY.

Referenced by begin().

153 {
155  delayMicroseconds(2000);
156 }
#define LCD_CLEARDISPLAY
Definition: AlphaLCD.h:28
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
void AlphaLCD::command ( uint8_t  value)
inline

Helper method to send commands to the device.

Definition at line 339 of file AlphaLCD.cpp.

References send().

Referenced by autoscroll(), begin(), blink(), clear(), createChar(), cursor(), display(), home(), leftToRight(), noAutoscroll(), noBlink(), noCursor(), noDisplay(), rightToLeft(), scrollDisplayLeft(), scrollDisplayRight(), and setCursor().

339  {
340  send(value, false);
341 }
void send(uint8_t, uint8_t)
Write either command or data, with automatic 4/8-bit selection.
Definition: AlphaLCD.cpp:353
void AlphaLCD::createChar ( uint8_t  location,
uint8_t  charmap[] 
)

Create one of the 8 CGRAM memory locations from 0x00 to 0x07 with a user defined characters.

The characters should be 5x8 dots font patterns, so the definition should be an 8 bytes array with the less 5 bits set accordingly with the pixels values of the character pattern.

Parameters
intThe character memory location
intthe character map 8 bytes array

Definition at line 324 of file AlphaLCD.cpp.

References command(), LCD_SETCGRAMADDR, and write().

324  {
325 
326  location &= 0x7; // No more than 7 memory locations
327 
328  command(LCD_SETCGRAMADDR | (location << 3));
329 
330  // Character definition loop
331  for (int i=0; i<8; i++) {
332  write(charmap[i]);
333  }
334 }
#define LCD_SETCGRAMADDR
Definition: AlphaLCD.h:34
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
virtual size_t write(uint8_t)
Helper method to send data to the device.
Definition: AlphaLCD.cpp:346
void AlphaLCD::cursor ( )

Turn on the underline cursor.

Definition at line 213 of file AlphaLCD.cpp.

References _displaycontrol, command(), LCD_CURSORON, and LCD_DISPLAYCONTROL.

Referenced by isCursor().

213  {
216 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_CURSORON
Definition: AlphaLCD.h:44
uint8_t _displaycontrol
Definition: AlphaLCD.h:110
#define LCD_DISPLAYCONTROL
Definition: AlphaLCD.h:31
void AlphaLCD::display ( )

Turn on the display.

Definition at line 197 of file AlphaLCD.cpp.

References _displaycontrol, command(), LCD_DISPLAYCONTROL, and LCD_DISPLAYON.

Referenced by begin(), and isDisplay().

197  {
200 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
uint8_t _displaycontrol
Definition: AlphaLCD.h:110
#define LCD_DISPLAYON
Definition: AlphaLCD.h:42
#define LCD_DISPLAYCONTROL
Definition: AlphaLCD.h:31
void AlphaLCD::home ( )

Set the cursor to the position (0,0)

Definition at line 161 of file AlphaLCD.cpp.

References command(), and LCD_RETURNHOME.

162 {
164  delayMicroseconds(2000);
165 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_RETURNHOME
Definition: AlphaLCD.h:29
void AlphaLCD::init ( uint8_t  dp,
uint8_t  cp,
uint8_t  lp 
)

Hardware initialization.

Initializes the hardware parameters for the LCD connection. The LCD mode is set to 4 bit by default due the hardware circuit settings

Parameters
intData Pin number
intClock Pin number
intLatch Pin number

Definition at line 56 of file AlphaLCD.cpp.

References _backlight, _clock_pin, _data_pin, _displayfunction, _latch_pin, begin(), LCD_1LINE, LCD_4BITMODE, LCD_5x8DOTS, and LCD_BL_PIN.

Referenced by AlphaLCD().

57 {
58  _data_pin = dp;
59  _clock_pin = cp;
60  _latch_pin = lp;
61 
63 
64  pinMode(_data_pin, OUTPUT);
65  pinMode(_clock_pin, OUTPUT);
66  pinMode(_latch_pin, OUTPUT);
67 
69 
70  // Display size (characters and lines). By default it is set to 16 characters x 2 lines
71  // but should be set with the right number of lines and columns,
72  // accordingly with the hardware specifications
73  begin(16, 2);
74 }
#define LCD_5x8DOTS
Definition: AlphaLCD.h:59
#define LCD_4BITMODE
Definition: AlphaLCD.h:55
#define LCD_1LINE
Definition: AlphaLCD.h:57
uint8_t _clock_pin
Definition: AlphaLCD.h:105
uint8_t _data_pin
Definition: AlphaLCD.h:106
void begin(uint8_t cols, uint8_t rows, uint8_t charsize=0x00)
Start the LCD modes and initializes the software configuration parameters.
Definition: AlphaLCD.cpp:83
uint8_t _backlight
Definition: AlphaLCD.h:112
uint8_t _displayfunction
Definition: AlphaLCD.h:109
uint8_t _latch_pin
Definition: AlphaLCD.h:107
#define LCD_BL_PIN
Definition: AlphaLCD.h:63
void AlphaLCD::isAutoscroll ( bool  set)
inline

Helper method to set on/off autoscroll.

Parameters
boolthe flag setting

Definition at line 309 of file AlphaLCD.cpp.

References autoscroll(), and noAutoscroll().

309  {
310  set ? autoscroll() : noAutoscroll();
311 }
void noAutoscroll()
Disable the automatic horizontal scrolling of the text.
Definition: AlphaLCD.cpp:278
void autoscroll()
Enable the automatic horizontal scrolling of the text.
Definition: AlphaLCD.cpp:270
void AlphaLCD::isBlinking ( bool  set)
inline

Helper method to set on/off the blinking cursor.

Parameters
boolthe flag setting

Definition at line 297 of file AlphaLCD.cpp.

References blink(), and noBlink().

297  {
298  set ? blink() : noBlink();
299 }
void blink()
Turn off the blinking cursor.
Definition: AlphaLCD.cpp:229
void noBlink()
Turn off the blinking cursor.
Definition: AlphaLCD.cpp:221
void AlphaLCD::isCursor ( bool  set)
inline

Helper method to set on/off the cursor visibility.

Parameters
boolthe flag setting

Definition at line 291 of file AlphaLCD.cpp.

References cursor(), and noCursor().

291  {
292  set ? cursor() : noCursor();
293 }
void noCursor()
Turn off the underline cursor.
Definition: AlphaLCD.cpp:205
void cursor()
Turn on the underline cursor.
Definition: AlphaLCD.cpp:213
void AlphaLCD::isDisplay ( bool  set)
inline

Helper method to set on/off the display.

Parameters
boolthe flag setting

Definition at line 285 of file AlphaLCD.cpp.

References display(), and noDisplay().

285  {
286  set ? display() : noDisplay();
287 }
void noDisplay()
Turn off the display.
Definition: AlphaLCD.cpp:189
void display()
Turn on the display.
Definition: AlphaLCD.cpp:197
void AlphaLCD::isRightToLeft ( bool  set)
inline

Helper method to set on/off the right-to-left writing direction.

Parameters
boolthe flag setting

Definition at line 303 of file AlphaLCD.cpp.

References leftToRight(), and rightToLeft().

303  {
304  set ? rightToLeft() : leftToRight();
305 }
void leftToRight()
Flow the text from left to right.
Definition: AlphaLCD.cpp:253
void rightToLeft()
Flow the text from right to left.
Definition: AlphaLCD.cpp:261
void AlphaLCD::leftToRight ( void  )

Flow the text from left to right.

Definition at line 253 of file AlphaLCD.cpp.

References _displaymode, command(), LCD_ENTRYLEFT, and LCD_ENTRYMODESET.

Referenced by isRightToLeft().

253  {
256 }
uint8_t _displaymode
Definition: AlphaLCD.h:111
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_ENTRYMODESET
Definition: AlphaLCD.h:30
#define LCD_ENTRYLEFT
Definition: AlphaLCD.h:38
void AlphaLCD::noAutoscroll ( void  )

Disable the automatic horizontal scrolling of the text.

Definition at line 278 of file AlphaLCD.cpp.

References _displaymode, command(), LCD_ENTRYMODESET, and LCD_ENTRYSHIFTINCREMENT.

Referenced by isAutoscroll().

278  {
281 }
uint8_t _displaymode
Definition: AlphaLCD.h:111
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_ENTRYMODESET
Definition: AlphaLCD.h:30
#define LCD_ENTRYSHIFTINCREMENT
Definition: AlphaLCD.h:39
void AlphaLCD::noBlink ( )

Turn off the blinking cursor.

Definition at line 221 of file AlphaLCD.cpp.

References _displaycontrol, command(), LCD_BLINKON, and LCD_DISPLAYCONTROL.

Referenced by isBlinking().

221  {
224 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_BLINKON
Definition: AlphaLCD.h:46
uint8_t _displaycontrol
Definition: AlphaLCD.h:110
#define LCD_DISPLAYCONTROL
Definition: AlphaLCD.h:31
void AlphaLCD::noCursor ( )

Turn off the underline cursor.

Definition at line 205 of file AlphaLCD.cpp.

References _displaycontrol, command(), LCD_CURSORON, and LCD_DISPLAYCONTROL.

Referenced by isCursor().

205  {
208 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_CURSORON
Definition: AlphaLCD.h:44
uint8_t _displaycontrol
Definition: AlphaLCD.h:110
#define LCD_DISPLAYCONTROL
Definition: AlphaLCD.h:31
void AlphaLCD::noDisplay ( )

Turn off the display.

Definition at line 189 of file AlphaLCD.cpp.

References _displaycontrol, command(), LCD_DISPLAYCONTROL, and LCD_DISPLAYON.

Referenced by isDisplay().

189  {
192 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
uint8_t _displaycontrol
Definition: AlphaLCD.h:110
#define LCD_DISPLAYON
Definition: AlphaLCD.h:42
#define LCD_DISPLAYCONTROL
Definition: AlphaLCD.h:31
void AlphaLCD::rightToLeft ( void  )

Flow the text from right to left.

Definition at line 261 of file AlphaLCD.cpp.

References _displaymode, command(), LCD_ENTRYLEFT, and LCD_ENTRYMODESET.

Referenced by isRightToLeft().

261  {
264 }
uint8_t _displaymode
Definition: AlphaLCD.h:111
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_ENTRYMODESET
Definition: AlphaLCD.h:30
#define LCD_ENTRYLEFT
Definition: AlphaLCD.h:38
void AlphaLCD::scrollDisplayLeft ( void  )

Scroll the display to the left by one position.

The method does not change the ram content.

Definition at line 238 of file AlphaLCD.cpp.

References command(), LCD_CURSORSHIFT, LCD_DISPLAYMOVE, and LCD_MOVELEFT.

238  {
240 }
#define LCD_MOVELEFT
Definition: AlphaLCD.h:52
#define LCD_CURSORSHIFT
Definition: AlphaLCD.h:32
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_DISPLAYMOVE
Definition: AlphaLCD.h:49
void AlphaLCD::scrollDisplayRight ( void  )

Scroll the display to the right by one position.

The method does not change the ram content.

Definition at line 246 of file AlphaLCD.cpp.

References command(), LCD_CURSORSHIFT, LCD_DISPLAYMOVE, and LCD_MOVERIGHT.

246  {
248 }
#define LCD_CURSORSHIFT
Definition: AlphaLCD.h:32
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
#define LCD_DISPLAYMOVE
Definition: AlphaLCD.h:49
#define LCD_MOVERIGHT
Definition: AlphaLCD.h:51
void AlphaLCD::send ( uint8_t  value,
uint8_t  mode 
)
private

Write either command or data, with automatic 4/8-bit selection.

Definition at line 353 of file AlphaLCD.cpp.

References _displayfunction, LCD_8BITMODE, write4bits(), and write8bits().

Referenced by command(), and write().

353  {
354 
356  write8bits(value, mode);
357  } else {
358  write4bits(value>>4, mode);
359  write4bits(value, mode);
360  }
361 }
void write4bits(uint8_t, uint8_t)
Write the character on the device, 4 bits mode.
Definition: AlphaLCD.cpp:369
#define LCD_8BITMODE
Definition: AlphaLCD.h:54
void write8bits(uint8_t, uint8_t)
Write the character on the device, 8 bits mode.
Definition: AlphaLCD.cpp:406
uint8_t _displayfunction
Definition: AlphaLCD.h:109
void AlphaLCD::setCursor ( uint8_t  col,
uint8_t  row 
)

Set the cursor to the requested position.

The method take care avoiding out of bound row and column values.

Note
The row and column are zero-based offset.
Parameters
intcolumn
introw

Definition at line 176 of file AlphaLCD.cpp.

References _numlines, command(), and LCD_SETDDRAMADDR.

177 {
178  int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
179  if ( row > _numlines ) {
180  row = _numlines-1;
181  }
182 
183  command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
184 }
void command(uint8_t)
Helper method to send commands to the device.
Definition: AlphaLCD.cpp:339
uint8_t _numlines
Definition: AlphaLCD.h:114
#define LCD_SETDDRAMADDR
Definition: AlphaLCD.h:35
size_t AlphaLCD::write ( uint8_t  value)
inlinevirtual

Helper method to send data to the device.

Definition at line 346 of file AlphaLCD.cpp.

References send().

Referenced by createChar().

346  {
347  send(value, true);
348 }
void send(uint8_t, uint8_t)
Write either command or data, with automatic 4/8-bit selection.
Definition: AlphaLCD.cpp:353
void AlphaLCD::write4bits ( uint8_t  value,
uint8_t  mode 
)
private

Write the character on the device, 4 bits mode.

int the character data mode the backlight on/off writing mode always on by default

Definition at line 369 of file AlphaLCD.cpp.

References _backlight, _clock_pin, _data_pin, _latch_pin, and LCD_RS_PIN.

Referenced by begin(), and send().

369  {
370  int EN_SWITCH = B00000010;
371  int RS_SWITCH = B00000001;
372  int cmd = 0;
373  int data = 0;
374  if (!mode) {
375  cmd = 0 | _backlight;
376  } else {
377  cmd = LCD_RS_PIN | _backlight;
378  }
379  data = value<<4 & B11110000;
380  cmd |= EN_SWITCH;
381  digitalWrite(_latch_pin, HIGH);
382  shiftOut(_data_pin, _clock_pin, LSBFIRST, data | cmd);
383  digitalWrite(_latch_pin, LOW);
384  delayMicroseconds(1);
385 
386  cmd &= ~EN_SWITCH;
387  digitalWrite(_latch_pin, HIGH);
388  shiftOut (_data_pin, _clock_pin, LSBFIRST, data | cmd);
389  digitalWrite(_latch_pin, LOW);
390  delayMicroseconds(1);
391 
392  cmd |= EN_SWITCH;
393  digitalWrite(_latch_pin, HIGH);
394  shiftOut(_data_pin, _clock_pin, LSBFIRST, data | cmd);
395  digitalWrite(_latch_pin, LOW);
396 
397  delayMicroseconds(100);
398 }
uint8_t _clock_pin
Definition: AlphaLCD.h:105
uint8_t _data_pin
Definition: AlphaLCD.h:106
uint8_t _backlight
Definition: AlphaLCD.h:112
#define LCD_RS_PIN
Definition: AlphaLCD.h:61
uint8_t _latch_pin
Definition: AlphaLCD.h:107
void AlphaLCD::write8bits ( uint8_t  value,
uint8_t  mode 
)
private

Write the character on the device, 8 bits mode.

int the character data mode the backlight on/off writing mode always on by default

Definition at line 406 of file AlphaLCD.cpp.

References _clock_pin, _data_pin, and _latch_pin.

Referenced by send().

406  {
407  int EN_SWITCH = B00000010;
408  int RS_SWITCH = B00000001;
409  int cmd = 0;
410  if (!mode) {
411  cmd = 0;
412  } else {
413  cmd = RS_SWITCH;
414  }
415  //set enable low
416  cmd |= EN_SWITCH;
417  digitalWrite (_latch_pin, HIGH);
418  shiftOut(_data_pin, _clock_pin, LSBFIRST, cmd);
419  shiftOut(_data_pin, _clock_pin, LSBFIRST, value);
420  digitalWrite (_latch_pin, LOW);
421  //delay (500);
422  //set enable high;
423  cmd &= ~EN_SWITCH;
424  digitalWrite (_latch_pin, HIGH);
425  shiftOut(_data_pin, _clock_pin, LSBFIRST, cmd);
426  shiftOut(_data_pin, _clock_pin, LSBFIRST, value);
427  digitalWrite (_latch_pin, LOW);
428  delayMicroseconds (1);
429  //delay (500);
430  //set enable low
431  cmd |= EN_SWITCH;
432  digitalWrite (_latch_pin, HIGH);
433  shiftOut(_data_pin, _clock_pin, LSBFIRST, cmd);
434  shiftOut(_data_pin, _clock_pin, LSBFIRST, value);
435  digitalWrite (_latch_pin, LOW);
436  delayMicroseconds (100);
437 
438 }
uint8_t _clock_pin
Definition: AlphaLCD.h:105
uint8_t _data_pin
Definition: AlphaLCD.h:106
uint8_t _latch_pin
Definition: AlphaLCD.h:107

Member Data Documentation

uint8_t AlphaLCD::_backlight
private

Definition at line 112 of file AlphaLCD.h.

Referenced by init(), and write4bits().

uint8_t AlphaLCD::_clock_pin
private

Definition at line 105 of file AlphaLCD.h.

Referenced by begin(), init(), write4bits(), and write8bits().

uint8_t AlphaLCD::_currline
private

Definition at line 114 of file AlphaLCD.h.

Referenced by begin().

uint8_t AlphaLCD::_data_pin
private

Definition at line 106 of file AlphaLCD.h.

Referenced by begin(), init(), write4bits(), and write8bits().

uint8_t AlphaLCD::_displaycontrol
private

Definition at line 110 of file AlphaLCD.h.

Referenced by begin(), blink(), cursor(), display(), noBlink(), noCursor(), and noDisplay().

uint8_t AlphaLCD::_displayfunction
private

Definition at line 109 of file AlphaLCD.h.

Referenced by begin(), init(), and send().

uint8_t AlphaLCD::_displaymode
private

Definition at line 111 of file AlphaLCD.h.

Referenced by autoscroll(), begin(), leftToRight(), noAutoscroll(), and rightToLeft().

uint8_t AlphaLCD::_initialized
private

Definition at line 113 of file AlphaLCD.h.

uint8_t AlphaLCD::_latch_pin
private

Definition at line 107 of file AlphaLCD.h.

Referenced by init(), write4bits(), and write8bits().

uint8_t AlphaLCD::_numlines
private

Definition at line 114 of file AlphaLCD.h.

Referenced by begin(), and setCursor().

uint8_t AlphaLCD::_smart_enable
private

Definition at line 108 of file AlphaLCD.h.


The documentation for this class was generated from the following files: