summaryrefslogtreecommitdiff
path: root/lcd.c
diff options
context:
space:
mode:
authorroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:14:14 +0900
committerroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:14:14 +0900
commit347f3f886ea54470f340def6a7af981f5845cc01 (patch)
treeee0b53caff48b05e0b18af074daa1a0c33dc38c4 /lcd.c
parentf4bf2894fa2e1b05958f0828d932e9068bc9b828 (diff)
Allow 64-char model numbersINSTRUMENT_6_0_10
Diffstat (limited to 'lcd.c')
-rw-r--r--lcd.c56
1 files changed, 43 insertions, 13 deletions
diff --git a/lcd.c b/lcd.c
index 526cf8e..2eb7f98 100644
--- a/lcd.c
+++ b/lcd.c
@@ -18,12 +18,15 @@ char LCD_Data[LCD_rows][LCD_cols]; /* shadow copy of LCD display in local RAM, t
static void break_up_string (char *in_string, int N, char **str1, char **str2, char **str3)
{
+ int i;
+
gchar** words = g_strsplit(in_string, " ", -1);
GString* rows[3];
- rows[0] = g_string_new(NULL);
- rows[1] = g_string_new(NULL);
- rows[2] = g_string_new(NULL);
+
+ for (i = 0; i<3; i++) {
+ rows[i] = g_string_new(NULL);
+ }
int row = 0;
int col = 0;
@@ -32,22 +35,49 @@ static void break_up_string (char *in_string, int N, char **str1, char **str2, c
for (word = words; *word != NULL; word++) {
int wordlen = strlen(*word);
- if (col + wordlen > N) {
- col = 0;
- row++;
- }
+ if (wordlen > N) {
+ // model numbers can be up to 64 chars
+
+ int remainder = col + wordlen - N;
+ if (row < 3) {
+ g_string_append(rows[row], *word);
+ col = 0;
+ row++;
+ }
+
+ if (row < 3) {
+ g_string_append(rows[row], *word + (wordlen - remainder));
+ col += remainder;
+ }
- if (row < 3) {
- g_string_append(rows[row], *word);
+ } else {
- col += wordlen;
+ if (col + wordlen > N) {
+ col = 0;
+ row++;
+ }
- if (col != 0 && (col + 1) < N) {
- g_string_append(rows[row], " ");
- col++;
+ if (row < 3) {
+ g_string_append(rows[row], *word);
+ col += wordlen;
}
}
+
+ if ((row < 3) && (col != 0) && (col < N)) {
+ g_string_append(rows[row], " ");
+ col++;
+ }
+
+ if (col >= N) {
+ col = 0;
+ row++;
+ }
+ }
+
+ for (i = 0; i<3; i++) {
+ g_string_truncate (rows[i], N);
}
+
*str1 = g_string_free(rows[0], FALSE);
*str2 = g_string_free(rows[1], FALSE);
*str3 = g_string_free(rows[2], FALSE);