summaryrefslogtreecommitdiff
path: root/display.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2004-08-11 21:10:11 +0000
committerEric S. Raymond <esr@thyrsus.com>2004-08-11 21:10:11 +0000
commitea16011ee24a62547a1a2ef42ba7295c0b45ae0d (patch)
tree16e7d1e269166e429baef566e33d5cb47c0b7429 /display.c
parent36208f433acb9826c6d46d9d145eb06910f49577 (diff)
downloadgpsd-ea16011ee24a62547a1a2ef42ba7295c0b45ae0d.tar.gz
ESR's gpsd patch #4: This is the one that nukes globals.
There is exactly one (1) global variable left after this patch. It is called "session", and is a per-GPS-session object that looks like this: struct session_t { int debug; struct longlat initpos; int device_type; struct OUTDATA gNMEAdata; }; The next step is for the device-type field to stop being an enum and become an object pointer -- or as close to an object pointer as you get in C, anyway. It will refer to a driver object.
Diffstat (limited to 'display.c')
-rw-r--r--display.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/display.c b/display.c
index 1464e781..d9b1867b 100644
--- a/display.c
+++ b/display.c
@@ -25,10 +25,11 @@
#include <X11/Shell.h>
#include <math.h>
-#include "nmea.h"
#include "outdata.h"
+#include "nmea.h"
#include "gps.h"
+
#define XCENTER (double)(width/2)
#define YCENTER (double)(height/2)
#define SCALE (double)(diameter/2)
@@ -38,11 +39,13 @@
#undef min
#define min(a,b) ((a) < (b) ? (a) : (b))
-Widget draww;
-GC drawGC;
-Dimension width, height;
-int diameter;
-Pixmap pixmap;
+extern struct session_t session;
+
+static Widget draww;
+static GC drawGC;
+static Dimension width, height;
+static int diameter;
+static Pixmap pixmap;
void set_color(String color)
{
@@ -109,15 +112,15 @@ int get_status(int satellite)
int i;
int s;
- if (gNMEAdata.ZCHseen) {
+ if (session.gNMEAdata.ZCHseen) {
for (i = 0; i < 12; i++)
- if (satellite == gNMEAdata.Zs[i])
- return gNMEAdata.Zv[i];
+ if (satellite == session.gNMEAdata.Zs[i])
+ return session.gNMEAdata.Zv[i];
return 0;
} else {
for (i = 0; i < 12; i++)
- if (satellite == gNMEAdata.PRN[i]) {
- s = gNMEAdata.ss[i];
+ if (satellite == session.gNMEAdata.PRN[i]) {
+ s = session.gNMEAdata.ss[i];
if (s<20) return 1;
if (s<40) return 2;
@@ -135,7 +138,7 @@ void draw_graphics()
double x, y;
char buf[20];
- if (gNMEAdata.cmask & (C_SAT | C_ZCH)) {
+ if (session.gNMEAdata.cmask & (C_SAT | C_ZCH)) {
i = min(width, height);
@@ -157,10 +160,10 @@ void draw_graphics()
draw_arc(width / 2, height / 2, i - RM);
/* Now draw the satellites... */
- for (i = 0; i < gNMEAdata.in_view; i++) {
- pol2cart(gNMEAdata.azimuth[i], gNMEAdata.elevation[i], &x, &y);
+ for (i = 0; i < session.gNMEAdata.in_view; i++) {
+ pol2cart(session.gNMEAdata.azimuth[i], session.gNMEAdata.elevation[i], &x, &y);
- switch (get_status(gNMEAdata.PRN[i]) & 7) {
+ switch (get_status(session.gNMEAdata.PRN[i]) & 7) {
case 0:
case 1:
set_color("Grey");
@@ -183,7 +186,7 @@ void draw_graphics()
11, 11, /* width, height */
0, 360 * 64 /* angle1, angle2 */
);
- sprintf(buf, "%02d", gNMEAdata.PRN[i]);
+ sprintf(buf, "%02d", session.gNMEAdata.PRN[i]);
set_color("Blue");
XDrawString(XtDisplay(draww), pixmap, drawGC,
(int) x + 0, (int) y + 17, buf, 2);