From 6bfc4efca61208782570bdedc5d46fb494ebc4c0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 23 Feb 2015 16:47:25 -0500 Subject: monitor_nme0183.c: factor out a utility function. gpsmon behavior is unchanged. --- monitor_nmea0183.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'monitor_nmea0183.c') diff --git a/monitor_nmea0183.c b/monitor_nmea0183.c index 148500b4..4eac611a 100644 --- a/monitor_nmea0183.c +++ b/monitor_nmea0183.c @@ -178,6 +178,32 @@ static void cooked_pvt(void) (void)mvwprintw(cookedwin, 1, 60, "%-17s", scr); } +static void monitor_satlist(WINDOW *win, int y, int x) +/* display as much as we can of a satlist in a specified window */ +{ + int ymax, xmax; + char scr[128]; + int i; + + assert(win != NULL); + (void)wmove(win, y, x); + (void)wclrtoeol(win); + scr[0] = '\0'; + for (i = 0; i < MAXCHANNELS; i++) { + if (session.gpsdata.skyview[i].used) + str_appendf(scr, sizeof(scr), + "%d ", session.gpsdata.skyview[i].PRN); + } + getmaxyx(win, ymax, xmax); + assert(ymax != 0); /* suppress compiler warning */ + (void)mvwaddnstr(win, y, x, scr, xmax - 2 - x); + if (strlen(scr) >= (size_t) (xmax - 2)) { + (void)mvwaddch(win, y, xmax - 2 - x, (chtype) '.'); + (void)mvwaddch(win, y, xmax - 3 - x, (chtype) '.'); + (void)mvwaddch(win, y, xmax - 4 - x, (chtype) '.'); + } + monitor_fixframe(win); +} /*@ -globstate -nullpass (splint is confused) */ static void nmea_update(void) @@ -279,25 +305,8 @@ static void nmea_update(void) if (strcmp(fields[0], "GPGSA") == 0 || strcmp(fields[0], "GNGSA") == 0 || strcmp(fields[0], "GLGSA") == 0) { - char scr[128]; - int i; (void)mvwprintw(gpgsawin, MODE_LINE, 7, "%1s %s", fields[1], fields[2]); - (void)wmove(gpgsawin, SATS_LINE, 7); - (void)wclrtoeol(gpgsawin); - scr[0] = '\0'; - for (i = 0; i < MAXCHANNELS; i++) { - if (session.gpsdata.skyview[i].used) - str_appendf(scr, sizeof(scr), - "%d ", session.gpsdata.skyview[i].PRN); - } - getmaxyx(gpgsawin, ymax, xmax); - (void)mvwaddnstr(gpgsawin, SATS_LINE, 7, scr, xmax - 2 - 7); - if (strlen(scr) >= (size_t) (xmax - 2)) { - (void)mvwaddch(gpgsawin, SATS_LINE, xmax - 2 - 7, (chtype) '.'); - (void)mvwaddch(gpgsawin, SATS_LINE, xmax - 3 - 7, (chtype) '.'); - (void)mvwaddch(gpgsawin, SATS_LINE, xmax - 4 - 7, (chtype) '.'); - } - monitor_fixframe(gpgsawin); + monitor_satlist(gpgsawin, SATS_LINE, 7); (void)mvwprintw(gpgsawin, DOP_LINE, 8, "%-5s", fields[16]); (void)mvwprintw(gpgsawin, DOP_LINE, 16, "%-5s", fields[17]); (void)mvwprintw(gpgsawin, DOP_LINE, 24, "%-5s", fields[15]); -- cgit v1.2.1