diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-31 08:29:43 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-31 08:29:43 -0400 |
commit | 8deceaf5efd69c1f9592deef6b00bd210af38ba3 (patch) | |
tree | d105b7663f927c29dde6067ae69e3e42f0103b8d /lcd.c | |
parent | fae02b5c3a9d5f3cf3e6253cdcd6a0100bdbcd73 (diff) |
added LCD_write_padded_spaces
Diffstat (limited to 'lcd.c')
-rw-r--r-- | lcd.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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); } |