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
Revision 2:9673849ef2e9, committed 2016-02-27
- Comitter:
- Hotboards
- Date:
- Sat Feb 27 20:02:57 2016 +0000
- Parent:
- 1:b777b6147d99
- Child:
- 3:e16488b64ef7
- Commit message:
- added mbed documentation
Changed in this revision
| Hotboards_SpiLcd.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Hotboards_SpiLcd.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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;
--- a/Hotboards_SpiLcd.h Fri Jan 29 01:08:33 2016 +0000
+++ b/Hotboards_SpiLcd.h Sat Feb 27 20:02:57 2016 +0000
@@ -59,34 +59,130 @@
#define HT_SPILCD_NORMINST 0x00
+/** Hotboards_SpiLcd class.
+ * Used to control lcd with spi serial interface
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "Hotboards_SpiLcd.h"
+ *
+ * Hotboards_SpiLcd lcd( PB_5, NC, PB_3 ); // mosi, miso, sclk
+ *
+ * int main( void )
+ * {
+ * lcd.init( );
+ * lcd.printf( "Hola mundo" );
+ * }
+ * @endcode
+ */
class Hotboards_SpiLcd : public Stream
{
public:
+ /** Create Hotboards_SpiLcd instance
+ */
Hotboards_SpiLcd( SPI &spi, PinName cs, PinName rs, PinName rst );
+
+ /** send commands to initialize internal lcd controller
+ */
void init( void );
+
+ /** Clears the LCD screen and positions the cursor in the upper-left corner.
+ */
void clear( void );
+
+ /** 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 home( void );
+ /** Turns off the LCD display, without losing the text currently shown on it.
+ */
void noDisplay( void );
+
+ /** 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 display( void );
+
+ /** Turns off the blinking LCD cursor.
+ */
void noBlink( void );
+
+ /** Display the blinking LCD cursor. If used in combination with the cursor() function,
+ * the result will depend on the particular display.
+ */
void blink( void );
+
+ /** Hides the LCD cursor.
+ */
void noCursor( void );
+
+ /** Display the LCD cursor: an underscore (line) at the position to which the
+ * next character will be written.
+ */
void cursor( void );
+
+ /** Scrolls the contents of the display (text and cursor) one space to the left.
+ */
void scrollDisplayLeft( void );
+
+ /** Scrolls the contents of the display (text and cursor) one space to the right.
+ */
void scrollDisplayRight( void );
+
+ /** 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 leftToRight( void );
+
+ /** 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 rightToLeft( void );
+
+ /** 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 autoscroll( void );
+
+ /** Turns off automatic scrolling of the LCD.
+ */
void noAutoscroll( void );
//void setRowOffsets( int row1, int row2 );
+
//void createChar( uint8_t, uint8_t[] );
- void setCursor( uint8_t, uint8_t );
+
+ /** Position the LCD cursor; that is, set the location at which subsequent
+ * text written to the LCD will be displayed.
+ *
+ * @param col: the column at which to position the cursor (with 0 being the first column)
+ * @param row: the row at which to position the cursor (with 0 being the first row)
+ */
+ void setCursor( uint8_t col, uint8_t row );
+
+ /** Write a character to the LCD.
+ * @data: the character to write to the display
+ */
void command( uint8_t );
#if DOXYGEN_ONLY
- int putc(int c);
+ /** Write a character to the LCD.
+ * @param c: character to display
+ */
+ int putc(int c);
+
+ /** Write a formatted string of characters to the LCD.
+ * @param format: formatted string
+ */
int printf(const char* format, ...);
#endif
Hotboards SpiLcd.