summaryrefslogtreecommitdiff
path: root/lcd.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-31 08:29:43 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-31 08:29:43 -0400
commit8deceaf5efd69c1f9592deef6b00bd210af38ba3 (patch)
treed105b7663f927c29dde6067ae69e3e42f0103b8d /lcd.c
parentfae02b5c3a9d5f3cf3e6253cdcd6a0100bdbcd73 (diff)
added LCD_write_padded_spaces
Diffstat (limited to 'lcd.c')
-rw-r--r--lcd.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lcd.c b/lcd.c
index d90bb69..bedb844 100644
--- a/lcd.c
+++ b/lcd.c
@@ -189,7 +189,24 @@ static void LCD_RAM_write(int RAM_start,int row, int col, char *LCD_string)
void LCD_write(int row, int col, char *LCD_string)
{
LCD_RAM_write(LCD_DATA_RAM, row, col, LCD_string);
- return;
+}
+
+
+void LCD_write_padded_spaces(int row, int col, char *LCD_string, int width)
+{
+ gchar *padded = NULL;
+
+ int in_len = strlen (LCD_string);
+
+ if (in_len > width) {
+ padded = g_strdup (LCD_string);
+ padded[width] = 0;
+ } else {
+ padded = g_strdup_printf ("%s%*s", LCD_string, width - in_len, "");
+ }
+
+ LCD_write(row, col, padded);
+ g_free (padded);
}