changeset 139:1a3366477e09 main

New function to clear an entire line with a single call.
author Bob Cook <bob@bobcookdev.com>
date Fri, 06 Apr 2012 12:19:43 -0700
parents a832a6908d9e
children c2a99aad2e9b
files main/packages/avr/lcd/hd44780/hd44780.cpp main/packages/avr/lcd/hd44780/hd44780.h
diffstat 2 files changed, 41 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/main/packages/avr/lcd/hd44780/hd44780.cpp	Fri Apr 06 12:18:49 2012 -0700
+++ b/main/packages/avr/lcd/hd44780/hd44780.cpp	Fri Apr 06 12:19:43 2012 -0700
@@ -327,16 +327,6 @@
 
 // ----------------------------------------------------------------------------------------
 
-void hd44780_clear_screen()
-{
-    send_command( HD44780_CMD_CLEAR_SCREEN );
-    spinwait_delay_ms( 2 );
-    send_command( HD44780_CMD_HOME );
-    spinwait_delay_ms( 2 );
-}
-
-// ----------------------------------------------------------------------------------------
-
 void hd44780_display_on()
 {
     send_command( HD44780_CMD_DISPLAY_CTL | HD44780_CTLOPT_DISPLAY_ON );
@@ -372,6 +362,30 @@
 
 // ----------------------------------------------------------------------------------------
 
+void hd44780_clear_screen()
+{
+    send_command( HD44780_CMD_CLEAR_SCREEN );
+    spinwait_delay_ms( 2 );
+    send_command( HD44780_CMD_HOME );
+    spinwait_delay_ms( 2 );
+}
+
+// ----------------------------------------------------------------------------------------
+
+void hd44780_clear_line( uint8_t y )
+{
+    hd44780_set_position( 0, y );
+
+    for ( uint8_t i = 0; i < PRJ_HD4470_DISPLAY_COLUMNS; ++i )
+    {
+        send_data( static_cast< uint8_t >( ' ' ) );
+    }
+
+    hd44780_set_position( 0, y );
+}
+
+// ----------------------------------------------------------------------------------------
+
 void hd44780_set_position( uint8_t x, uint8_t y )
 {
     x %= PRJ_HD4470_DISPLAY_COLUMNS;
--- a/main/packages/avr/lcd/hd44780/hd44780.h	Fri Apr 06 12:18:49 2012 -0700
+++ b/main/packages/avr/lcd/hd44780/hd44780.h	Fri Apr 06 12:19:43 2012 -0700
@@ -105,14 +105,6 @@
 void hd44780_init();
 
 // ----------------------------------------------------------------------------------------
-//  hd44780_clear_screen
-//
-//      Erase the entire screen, and reset the cursor position to the upper left corner.
-//
-
-void hd44780_clear_screen();
-
-// ----------------------------------------------------------------------------------------
 //  hd44780_display_on
 //
 //      Turn on the display. This does not clear the screen, just turns it on. The cursor
@@ -130,6 +122,23 @@
 void hd44780_display_off();
 
 // ----------------------------------------------------------------------------------------
+//  hd44780_clear_screen
+//
+//      Erase the entire screen, and reset the cursor position to the upper left corner.
+//
+
+void hd44780_clear_screen();
+
+// ----------------------------------------------------------------------------------------
+//  hd44780_clear_line
+//
+//      Clear a horizontal line. This is not the same a clearing the entire screen.
+//      The cursor is positioned at the start of the line.
+//
+
+void hd44780_clear_line( uint8_t y );
+
+// ----------------------------------------------------------------------------------------
 //  hd44780_set_position
 //
 //      Position the cursor at the given position, where (0,0) is upper left.