summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/Makefile2
-rw-r--r--app/dcf77.c2
-rw-r--r--app/display.c4
-rw-r--r--app/gps.c53
-rw-r--r--app/httpd.c38
-rw-r--r--app/main.c2
-rw-r--r--app/meteotime.c67
-rw-r--r--app/prototypes.h4
-rw-r--r--app/time_fn.c2
9 files changed, 89 insertions, 85 deletions
diff --git a/app/Makefile b/app/Makefile
index 78f0d9b..9547a09 100644
--- a/app/Makefile
+++ b/app/Makefile
@@ -31,7 +31,7 @@ default: ${PROG}.elf
CSRCS=led.c ticker.c ring.c usart.c stdio.c lwip_glue.c steth.c msf.c abs.c \
pll.c main.c time_fn.c ntp.c dcf77.c util.c stats.c gps.c hexdump.c bits.c \
max7219.c report.c sysclk.c cdcacm.c usb.c dfu.c adc.c dummy_kb.c ref.c \
- ptp.c display.c httpd.c alarm.c meteotime.c ephemeris.c
+ ptp.c display.c httpd.c alarm.c meteotime.c ephemeris.c fp.c
HSRCS= events.h gps.h project.h ring.h steth.h time_fn.h ubx.h
diff --git a/app/dcf77.c b/app/dcf77.c
index 4b69a69..b9b7dcd 100644
--- a/app/dcf77.c
+++ b/app/dcf77.c
@@ -104,7 +104,7 @@ static void process_bits (uint64_t abs, uint64_t ptp)
printf ("DCF77: Next minute is: %02d-%02d-%02d %02d:%02d\r\n", u.year, u.month, u.mday, u.hour, u.minute);
time_print_epoch ("DCF77: ", e, dcf77_info);
- meteotime_save(&u,bits);
+ meteotime_save (&u, bits);
dump_bits ("dcf77", bits);
}
diff --git a/app/display.c b/app/display.c
index 5c745b7..bf811d8 100644
--- a/app/display.c
+++ b/app/display.c
@@ -115,7 +115,7 @@ void display_dispatch (void)
case 1:
if (!have_lock) break;
- snprintf (buf, sizeof (buf), "%.8f", gps_lat);
+ snprintf (buf, sizeof (buf), "%s", fd1 (gps_lat, 0, 1, 8));
buf[sizeof (buf) - 1] = 0;
max7219_write_string (buf, 0, 2);
break;
@@ -123,7 +123,7 @@ void display_dispatch (void)
case 2:
if (!have_lock) break;
- snprintf (buf, sizeof (buf), "%.8f", gps_lon);
+ snprintf (buf, sizeof (buf), "%s", fd1 (gps_lon, 0, 1, 8));
buf[sizeof (buf) - 1] = 0;
max7219_write_string (buf, 0, 2);
break;
diff --git a/app/gps.c b/app/gps.c
index a8b8099..e87167d 100644
--- a/app/gps.c
+++ b/app/gps.c
@@ -120,25 +120,25 @@ static int ubx_recv_aid_eph (uint8_t *ptr, unsigned len)
ptr += ubx_get_u32 (ptr, &sv);
len -= 4;
- if ((sv<1) ||( sv>32)) return 0;
+ if ((sv < 1) || (sv > 32)) return 0;
+
+ i = sv - 1;
- i=sv-1;
-
ptr += ubx_get_u32 (ptr, &ephemeris[i].how);
len -= 4;
- printf("Received %d bytes of ephemeris for SV%d\r\n",len,(int) sv);
+ printf ("Received %d bytes of ephemeris for SV%d\r\n", len, (int) sv);
- if ((!len) ||( !ephemeris[i].how)) return 0 ;
+ if ((!len) || (!ephemeris[i].how)) return 0 ;
- memcpy(&ephemeris[i].sf1,ptr,32);
- len-=32;
- ptr+=32;
- memcpy(&ephemeris[i].sf2,ptr,32);
- len-=32;
- ptr+=32;
- memcpy(&ephemeris[i].sf3,ptr,32);
+ memcpy (&ephemeris[i].sf1, ptr, 32);
+ len -= 32;
+ ptr += 32;
+ memcpy (&ephemeris[i].sf2, ptr, 32);
+ len -= 32;
+ ptr += 32;
+ memcpy (&ephemeris[i].sf3, ptr, 32);
return 0;
}
@@ -170,9 +170,9 @@ ubx_recv_nav_posllh (uint8_t *ptr, unsigned len)
gps_lon = 1.e-7 * (double) ilon;
- printf ("POS: %.4f %.4f\r\n", gps_lat, gps_lon);
+ printf ("POS: %s %s\r\n", fd1 (gps_lat, 0, 1, 4), fd2 (gps_lon, 0, 1, 4));
- snprintf (gps_pos, sizeof (gps_pos) - 1, "location: %.4f %.4f", gps_lat, gps_lon);
+ snprintf (gps_pos, sizeof (gps_pos) - 1, "location: %s %s", fd1 (gps_lat, 0, 1, 4), fd2 (gps_lon, 0, 1, 4));
return 0;
}
@@ -636,6 +636,7 @@ ubx_recv (uint8_t class, uint8_t id, uint8_t *payload, unsigned len)
}
break;
+
case 0xd:
switch (id) {
case 0x4:
@@ -669,9 +670,10 @@ ubx_recv (uint8_t class, uint8_t id, uint8_t *payload, unsigned len)
case 0x30:
ubx_recv_almanac (payload, len);
break;
- case 0x31:
- ubx_recv_aid_eph(payload,len);
- break;
+
+ case 0x31:
+ ubx_recv_aid_eph (payload, len);
+ break;
case 0x50:
printf ("xfer ack\r\n");
@@ -900,20 +902,21 @@ ubx_send (uint8_t class, uint8_t id, const void *_payload, unsigned len)
void
gps_dispatch (void)
{
-static uint32_t last_eph;
-uint32_t t ;
+ static uint32_t last_eph;
+ uint32_t t ;
ubx_dispatch_search (-1, -1, NULL);
gps_pps_dispatch();
-t=ticks-last_eph;
-if (t>60000) {
- printf("Requesting ephemeris data\r\n");
- gps_dump_eph();
- last_eph=ticks;
-}
+ t = ticks - last_eph;
+
+ if (t > 60000) {
+ printf ("Requesting ephemeris data\r\n");
+ gps_dump_eph();
+ last_eph = ticks;
+ }
}
diff --git a/app/httpd.c b/app/httpd.c
index 71c62a4..1c8fb17 100644
--- a/app/httpd.c
+++ b/app/httpd.c
@@ -52,11 +52,11 @@ static uint32_t make_alarm (void)
}
PTB_ADD (" UTC: %s\n", buf);
- PTB_ADD (" RA: %.9f\n", ra);
+ PTB_ADD (" RA: %sf\n", fd1 (ra, 0, 1, 9));
PTB_ADD ("</pre>\n");
PTB_ADD ("<table>\n");
- PTB_ADD ("<tr><td><form method='get' action='/alarm_set.cgi'><td>LRA:</td><td><input type='text' name='lra' value='%.9f' size='32' maxlength='32' /></td><td><input type='submit' value='set' /></td></form></tr>\n", lra);
+ PTB_ADD ("<tr><td><form method='get' action='/alarm_set.cgi'><td>LRA:</td><td><input type='text' name='lra' value='%s' size='32' maxlength='32' /></td><td><input type='submit' value='set' /></td></form></tr>\n", fd1 (lra, 0, 1, 9));
PTB_ADD ("<tr><td><form method='get' action='/alarm_set.cgi'><td>LST:</td><td><input type='text' name='lst' value='%02d:%02d:%02d.%06d' size='32' maxlength='32' /></td><td><input type='submit' value='set' /></td></form></tr>\n", l.hour, l.minute, l.second, l.nanosecond / 1000);
PTB_ADD ("</table>\n");
@@ -94,8 +94,8 @@ static uint32_t make_index (void)
PTB_ADD ("<pre>\n");
PTB_ADD (" UTC: %s\n", buf);
- PTB_ADD (" RA: %.9f\n", ra);
- PTB_ADD (" LRA: %.9f\n", lra);
+ PTB_ADD (" RA: %s\n", fd1 (ra, 0, 1, 9));
+ PTB_ADD (" LRA: %s\n", fd1 (lra, 0, 1, 9));
PTB_ADD (" LST: %02d:%02d:%02d.%06d\n", l.hour, l.minute, l.second, l.nanosecond / 1000);
PTB_ADD ("</pre>\n");
PTB_ADD ("\n");
@@ -125,8 +125,8 @@ static uint32_t make_index (void)
}
PTB_ADD (" UTC: %s\n", buf);
- PTB_ADD (" RA: %.9f\n", ra);
- PTB_ADD (" LRA: %.9f\n", lra);
+ PTB_ADD (" RA: %s\n", fd1 (ra, 0, 1, 9));
+ PTB_ADD (" LRA: %s\n", fd1 (lra, 0, 1, 9));
PTB_ADD (" LST: %02d:%02d:%02d.%06d\n", l.hour, l.minute, l.second, l.nanosecond / 1000);
PTB_ADD ("</pre>\n");
@@ -259,22 +259,18 @@ int fs_open_custom (struct fs_file *file, const char *name)
{
if (!strcmp (name, "/index.html")) {
- file->data = (const char *)html_buf;
- file->len = make_index();
- }
- else if (!strcmp (name, "/alarm.html")) {
- file->data = (const char *)html_buf;
+ file->data = (const char *)html_buf;
+ file->len = make_index();
+ } else if (!strcmp (name, "/alarm.html")) {
+ file->data = (const char *)html_buf;
file->len = make_alarm();
- }
- else if (!strcmp (name, "/meteotime.dat")) {
- file->data = (const char *)meteotime_data;
- file->len=sizeof(meteotime_data);
- }
- else if (!strcmp (name, "/ephemeris.dat")) {
- file->data = (const char *)ephemeris;
- file->len=sizeof(ephemeris);
- }
- else {
+ } else if (!strcmp (name, "/meteotime.dat")) {
+ file->data = (const char *)meteotime_data;
+ file->len = sizeof (meteotime_data);
+ } else if (!strcmp (name, "/ephemeris.dat")) {
+ file->data = (const char *)ephemeris;
+ file->len = sizeof (ephemeris);
+ } else {
printf ("looking for url=%s, found nothing\n", name);
return 0;
}
diff --git a/app/main.c b/app/main.c
index 3fe11eb..47c1a4b 100644
--- a/app/main.c
+++ b/app/main.c
@@ -222,7 +222,7 @@ static void timer_setup (void)
timer_slave_set_trigger (TIM2, TIM_SMCR_TS_ITR0); /*clock from timer 1*/
timer_enable_counter (TIM2);
#else
- /* New Scheme 10MHz -> TIM2_ETR PA8->PA15*/
+ /* New Scheme 10MHz -> TIM2_ETR PA8->PA15*/
#define REFCLK_IN (GPIO15)
#define REFCLK_IN_PORT GPIOA
diff --git a/app/meteotime.c b/app/meteotime.c
index 5734a0b..e18220f 100644
--- a/app/meteotime.c
+++ b/app/meteotime.c
@@ -8,7 +8,7 @@
#define BITS_PER_WORD 32
-#define N_WORDS (((N_BITS)+(BITS_PER_WORD-1))/(BITS_PER_WORD))
+#define N_WORDS (((N_BITS)+(BITS_PER_WORD-1))/(BITS_PER_WORD))
#define M1 (~0UL)
@@ -16,50 +16,51 @@
uint32_t meteotime_data[N_WORDS];
-void meteotime_save(UTC *u, uint8_t *bits)
+void meteotime_save (UTC *u, uint8_t *bits)
{
-uint32_t c;
-uint32_t d1;
-uint32_t d2;
+ uint32_t c;
+ uint32_t d1;
+ uint32_t d2;
-unsigned i;
-unsigned word;
-unsigned bit;
-unsigned ibit;
+ unsigned i;
+ unsigned word;
+ unsigned bit;
+ unsigned ibit;
-//0-13
-for (d1=0,c=1,i=1;i<15;++i,c<<=1)
- if (bits[i]) d1|=c;
+ //0-13
+ for (d1 = 0, c = 1, i = 1; i < 15; ++i, c <<= 1)
+ if (bits[i]) d1 |= c;
-//14
-if (bits[17]) d1|=c;
-c<<=1;
+ //14
+ if (bits[17]) d1 |= c;
-//15-31
-for (i=36;i<53;++i,c<<=1)
- if (bits[i]) d1|=c;
+ c <<= 1;
-//0-4
-for (d2=0,c=1,i=53;i<58;++i,c<<=1)
- if (bits[i]) d2|=c;
+ //15-31
+ for (i = 36; i < 53; ++i, c <<= 1)
+ if (bits[i]) d1 |= c;
-bit=u->hour;
-bit*=60;
-bit+=u->minute;
-bit*=BITS_PER_MIN;
+ //0-4
+ for (d2 = 0, c = 1, i = 53; i < 58; ++i, c <<= 1)
+ if (bits[i]) d2 |= c;
-word=bit/BITS_PER_WORD;
-bit=bit & (BITS_PER_WORD -1);
-ibit=BITS_PER_WORD-bit;
+ bit = u->hour;
+ bit *= 60;
+ bit += u->minute;
+ bit *= BITS_PER_MIN;
+ word = bit / BITS_PER_WORD;
+ bit = bit & (BITS_PER_WORD - 1);
+ ibit = BITS_PER_WORD - bit;
-meteotime_data[word] &=~(M1 << bit);
-meteotime_data[word] |=(d1 << bit);
-word++;
+ meteotime_data[word] &= ~ (M1 << bit);
+ meteotime_data[word] |= (d1 << bit);
-meteotime_data[word] &=~((M1 >> ibit) |(M2 <<bit));
-meteotime_data[word] |=(d1 >> ibit) | (d2 <<bit);
+ word++;
+
+ meteotime_data[word] &= ~ ((M1 >> ibit) | (M2 << bit));
+ meteotime_data[word] |= (d1 >> ibit) | (d2 << bit);
}
diff --git a/app/prototypes.h b/app/prototypes.h
index 2fb6277..82be3cb 100644
--- a/app/prototypes.h
+++ b/app/prototypes.h
@@ -212,3 +212,7 @@ extern uint32_t meteotime_data[(((((37)*(60)*(24)))+(32 -1))/(32))];
extern void meteotime_save(UTC *u, uint8_t *bits);
/* ephemeris.c */
extern Ephemeris ephemeris[32];
+/* fp.c */
+extern char *fd1(double f, int s, int bp, int dp);
+extern char *fd2(double f, int s, int bp, int dp);
+extern char *fd3(double f, int s, int bp, int dp);
diff --git a/app/time_fn.c b/app/time_fn.c
index 75b69d3..8c6c4f1 100644
--- a/app/time_fn.c
+++ b/app/time_fn.c
@@ -437,7 +437,7 @@ EPOCH time_ra_to_next_epoch (EPOCH l, double tra)
int dog = 48;
- printf ("time_ra_to_next_epoch %.9f\n", tra);
+ printf ("time_ra_to_next_epoch %s\n", fd1 (tra, 0, 1, 9));
/* XXX: we should use newton raphson, but */
/* 1) we're on team hooke */