From 8deceaf5efd69c1f9592deef6b00bd210af38ba3 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Fri, 31 Aug 2012 08:29:43 -0400 Subject: added LCD_write_padded_spaces --- lcd.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lcd.c') 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); } -- cgit