summaryrefslogtreecommitdiffstats
path: root/src/af-gps-binding.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-07-08 09:32:20 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-07-08 09:32:20 +0200
commit6458edb901be6107455b9fecbdf0b7c82eae15ab (patch)
tree2d34caf5a4723709617630845f9daf2f8b8162f9 /src/af-gps-binding.c
parent411882240e0211b33f0dd6ce4df343f0b2c14725 (diff)
fix angle measurement
Change-Id: I63ed2e6001f1cfedf82e527667d56a7787934315 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/af-gps-binding.c')
-rw-r--r--src/af-gps-binding.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/af-gps-binding.c b/src/af-gps-binding.c
index 602ed91..cd9d021 100644
--- a/src/af-gps-binding.c
+++ b/src/af-gps-binding.c
@@ -125,6 +125,7 @@ static int nmea_time(const char *text, uint32_t *result)
static int nmea_angle(const char *text, double *result)
{
uint32_t x = 0;
+ double v;
int dotidx = (int)(strchrnul(text, '.') - text);
switch(dotidx) {
@@ -141,23 +142,19 @@ static int nmea_angle(const char *text, double *result)
return 0;
x = x * 10 + (uint32_t)(text[dotidx - 3] - '0');
case 2:
- if (text[dotidx - 2] < '0' || text[dotidx - 2] > '9')
- return 0;
- x = x * 6 + (uint32_t)(text[dotidx - 3] - '0');
+ v = atof(&text[dotidx - 2]);
+ break;
case 1:
if (text[dotidx - 1] < '0' || text[dotidx - 1] > '9')
return 0;
- x = x * 10 + (uint32_t)(text[dotidx - 3] - '0');
case 0:
+ v = atof(text);
break;
default:
return 0;
}
- if (text[dotidx] == '.')
- *result = atof(&text[dotidx]) + x;
- else
- *result = x;
+ *result = (double)x + v * 0.01666666666666666666666;
return 1;
}