Hotboards_SpiLcd.cpp - Library for write and control and lcd with spi interfaces and the ST7032 controller. Base on Arduino's Liquid Cristal library
Dependents: Hotboards_SpiLcd-Hello_World Hotboards_SpiLcd-Writing_In_Diferent_Rows Hotboards_SpiLcd_Scrolling_Text Hotboards_SpiLcd_AutoScroll ... more
Diff: Hotboards_SpiLcd.cpp
- Revision:
- 2:9673849ef2e9
- Parent:
- 1:b777b6147d99
diff -r b777b6147d99 -r 9673849ef2e9 Hotboards_SpiLcd.cpp
--- a/Hotboards_SpiLcd.cpp Fri Jan 29 01:08:33 2016 +0000
+++ b/Hotboards_SpiLcd.cpp Sat Feb 27 20:02:57 2016 +0000
@@ -23,9 +23,7 @@
_rst_pin = 1; /*reset not active*/
}
-/*
- * send commands to initialize internal lcd controller
- */
+
void Hotboards_SpiLcd::init( void )
{
_rst_pin = 0;
@@ -62,58 +60,42 @@
clear( );/*clearscreen*/
}
-/*
- * Clears the LCD screen and positions the cursor in the upper-left corner.
- */
+
void Hotboards_SpiLcd::clear( void )
{
command( HT_SPILCD_CLEARDISPLAY ); // clear display, set cursor position to zero
wait( 0.002 ); // this command takes a long time!
}
-/*
- * Positions the cursor in the upper-left of the LCD. That is, use that location
- * in outputting subsequent text to the display. To also clear the display, use
- * the clear() function instead
- */
+
void Hotboards_SpiLcd::home( void )
{
command( HT_SPILCD_RETURNHOME ); // set cursor position to zero
wait( 0.002 ); // this command takes a long time!
}
-/*
- * Turns off the LCD display, without losing the text currently shown on it.
- */
+
void Hotboards_SpiLcd::noDisplay( void )
{
_displaycontrol &= ~HT_SPILCD_DISPLAYON;
command( HT_SPILCD_DISPLAYCONTROL | _displaycontrol );
}
-/*
- * Turns on the LCD display, after it's been turned off with noDisplay().
- * This will restore the text (and cursor) that was on the display.
- */
+
void Hotboards_SpiLcd::display( void )
{
_displaycontrol |= HT_SPILCD_DISPLAYON;
command( HT_SPILCD_DISPLAYCONTROL | _displaycontrol );
}
-/*
- * Turns off the blinking LCD cursor.
- */
+
void Hotboards_SpiLcd::noBlink( void )
{
_displaycontrol &= ~HT_SPILCD_BLINKON;
command( HT_SPILCD_DISPLAYCONTROL | _displaycontrol );
}
-/*
- * Display the blinking LCD cursor. If used in combination with the cursor() function,
- * the result will depend on the particular display.
- */
+
void Hotboards_SpiLcd::blink( void )
{
_displaycontrol |= HT_SPILCD_BLINKON;
@@ -121,19 +103,14 @@
}
-/*
- * Hides the LCD cursor.
- */
+
void Hotboards_SpiLcd::noCursor( void )
{
_displaycontrol &= ~HT_SPILCD_CURSORON;
command( HT_SPILCD_DISPLAYCONTROL | _displaycontrol );
}
-/*
- * Display the LCD cursor: an underscore (line) at the position to which the
- * next character will be written.
- */
+
void Hotboards_SpiLcd::cursor( void )
{
_displaycontrol |= HT_SPILCD_CURSORON;
@@ -141,73 +118,47 @@
}
-/*
- * Scrolls the contents of the display (text and cursor) one space to the left.
- */
+
void Hotboards_SpiLcd::scrollDisplayLeft( void )
{
command( HT_SPILCD_CURSORSHIFT | HT_SPILCD_DISPLAYMOVE | HT_SPILCD_MOVELEFT );
}
-/*
- * Scrolls the contents of the display (text and cursor) one space to the right.
- */
+
void Hotboards_SpiLcd::scrollDisplayRight( void )
{
command( HT_SPILCD_CURSORSHIFT | HT_SPILCD_DISPLAYMOVE | HT_SPILCD_MOVERIGHT );
}
-/*
- * Set the direction for text written to the LCD to left-to-right, the default.
- * This means that subsequent characters written to the display will go from left to right,
- * but does not affect previously-output text.
- */
+
void Hotboards_SpiLcd::leftToRight( void )
{
_displaymode |= HT_SPILCD_ENTRYLEFT;
command( HT_SPILCD_ENTRYMODESET | _displaymode );
}
-/*
- * Set the direction for text written to the LCD to right-to-left (the default is left-to-right).
- * This means that subsequent characters written to the display will go from right to left,
- * but does not affect previously-output text.
- */
+
void Hotboards_SpiLcd::rightToLeft( void )
{
_displaymode &= ~HT_SPILCD_ENTRYLEFT;
command( HT_SPILCD_ENTRYMODESET | _displaymode );
}
-/*
- * Turns on automatic scrolling of the LCD. This causes each character
- * output to the display to push previous characters over by one space.
- * If the current text direction is left-to-right (the default),
- * the display scrolls to the left; if the current direction is right-to-left,
- * the display scrolls to the right. This has the effect of outputting
- * each new character to the same location on the LCD.
- */
+
void Hotboards_SpiLcd::autoscroll( void )
{
_displaymode |= HT_SPILCD_ENTRYSHIFTINCREMENT;
command( HT_SPILCD_ENTRYMODESET | _displaymode );
}
-/*
- * Turns off automatic scrolling of the LCD.
- */
+
void Hotboards_SpiLcd::noAutoscroll( void )
{
_displaymode &= ~HT_SPILCD_ENTRYSHIFTINCREMENT;
command( HT_SPILCD_ENTRYMODESET | _displaymode );
}
-/*
- * Position the LCD cursor; that is, set the location at which subsequent
- * text written to the LCD will be displayed.
- * col: the column at which to position the cursor (with 0 being the first column)
- * row: the row at which to position the cursor (with 0 being the first row)
- */
+
void Hotboards_SpiLcd::setCursor( uint8_t col, uint8_t row )
{
const uint8_t Buffer[ 2 ]= { 0x00u, 0x40u };
@@ -223,10 +174,7 @@
/*********** mid level commands, for sending data/cmds */
-/*
- * Write a character to the LCD.
- * data: the character to write to the display
- */
+
inline void Hotboards_SpiLcd::command( uint8_t value )
{
_cs_pin = 0;
Hotboards SpiLcd.