Skip to content

Commit 393ceea

Browse files
committed
gps tracker configuration file
1 parent 0222b86 commit 393ceea

File tree

9 files changed

+353
-13
lines changed

9 files changed

+353
-13
lines changed

sys/arm_u8g/gps/config.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
3+
config.h
4+
5+
Configuration file for the GPS tracker device.
6+
7+
m2tklib - Mini Interative Interface Toolkit Library
8+
u8glib - Universal 8bit Graphics Library
9+
10+
Copyright (C) 2013 [email protected]
11+
12+
This program is free software: you can redistribute it and/or modify
13+
it under the terms of the GNU General Public License as published by
14+
the Free Software Foundation, either version 3 of the License, or
15+
(at your option) any later version.
16+
17+
This program is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU General Public License for more details.
21+
22+
You should have received a copy of the GNU General Public License
23+
along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
25+
*/
26+
27+
#ifndef _CONFIG_H
28+
#define _CONFIG_H
29+
30+
/*
31+
Define the following variable to enable monitoring of battery voltage.
32+
ADC2 at R_PIO1_1 will be used for monitoring.
33+
This will also enable the battery symbol in the upper left of the display and
34+
the battery submenu.
35+
*/
36+
//#define USE_BATTERY_ADC
37+
38+
39+
/*
40+
Select transmit speed of the connected GPS module.
41+
If the following macro is defined, use 4800 Baud.
42+
If the following macro is not defined, use 9600 Baud
43+
*/
44+
#define USE_GPS_4800BAUD
45+
46+
47+
#endif

sys/arm_u8g/gps/gps.c

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "init.h"
3434
#include "util.h"
3535
#include "exmem.h"
36+
#include "config.h"
3637

3738
/*=========================================================================*/
3839
/* global variables and objects */
@@ -99,9 +100,13 @@ float gps_cos(float x)
99100
/*=======================================================================*/
100101
uint8_t update_gps_tracker_variables(void)
101102
{
103+
#ifdef USE_BATTERY_ADC
102104
uint16_t tmp16;
105+
#endif
103106
uint8_t is_changed = 0;
104-
107+
108+
109+
#ifdef USE_BATTERY_ADC
105110
tmp16 = adc_get_value(2);
106111
tmp16 = low_pass( &gps_tracker_variables.adc_low_pass_z, tmp16, 7);
107112

@@ -110,6 +115,7 @@ uint8_t update_gps_tracker_variables(void)
110115
// is_changed = 1;
111116
gps_tracker_variables.adc_battery = tmp16;
112117
}
118+
#endif
113119

114120
if ( gps_tracker_variables.sec_cnt != gps_tracker_variables.sec_cnt_raw )
115121
{
@@ -299,10 +305,12 @@ void prepare_map(void)
299305
#define MAP_SCALE_OFFSET 6
300306
#define MAP_RADIUS 21
301307
#define MAP_TARGET_RADIUS 2
308+
#define MAP_COURSE_RADIUS 3
302309
static void draw_map_mode_0(void)
303310
{
304311
uint8_t i;
305312
gps_float_t half_map_pixel_size = MAP_RADIUS;
313+
gps_float_t course;
306314
u8g_int_t x_org = MAP_OFFSET+MAP_RADIUS;
307315
u8g_int_t y_org = MAP_OFFSET+MAP_RADIUS;
308316
u8g_int_t x,y;
@@ -318,6 +326,24 @@ static void draw_map_mode_0(void)
318326
u8g_DrawStr(&u8g, MAP_OFFSET+MAP_RADIUS+2, MAP_OFFSET+ 2*MAP_RADIUS + MAP_SCALE_OFFSET + 4, gps_get_half_map_str());
319327
u8g_DrawCircle(&u8g, x_org,y_org,MAP_RADIUS, U8G_DRAW_ALL);
320328

329+
/* true_course == 0: geogr. north, counts clockwise (?) */
330+
/* true_course == 90: east */
331+
course = ((gps_float_t)(360+90))-pq.interface.true_course;
332+
course *= num._pi_div_180;
333+
while ( course > num.pi )
334+
{
335+
course -= num.pi;
336+
course -= num.pi;
337+
}
338+
339+
//x = x_org + half_map_pixel_size*gps_cos(course);
340+
//y = y_org - half_map_pixel_size*gps_sin(course);
341+
x = half_map_pixel_size*gps_cos(course);
342+
y = half_map_pixel_size*gps_sin(course);
343+
//u8g_DrawCircle(&u8g, x,y, MAP_COURSE_RADIUS, U8G_DRAW_ALL);
344+
u8g_DrawLine(&u8g, x_org + x/2, y_org -y/2, x_org + x, y_org -y);
345+
346+
321347
/* loop through last positions, returned from the GPS receiver */
322348
for( i = 0; i < pq.cnt; i++ )
323349
{
@@ -451,8 +477,9 @@ const uint8_t satellite_bitmap[10] = { 0x00, 0x010, 0x092, 0x054, 0x038, 0x010,
451477

452478
void draw_status(void)
453479
{
454-
int32_t battery;
480+
#ifdef USE_BATTERY_ADC
455481
int32_t i;
482+
int32_t battery;
456483
battery = (gps_tracker_variables.adc_battery*3300L);
457484
battery /= 1024;
458485
battery -= BATTERY_EMPTY_LEVEL_mV;
@@ -473,6 +500,11 @@ void draw_status(void)
473500
u8g_DrawBitmap(&u8g, u8g_GetWidth(&u8g) - 27, 0, 1, 10, satellite_bitmap);
474501
u8g_SetFont(&u8g, SMALL_FONT);
475502
u8g_DrawStr(&u8g, u8g_GetWidth(&u8g) - 20, 8, u8g_u16toa(pq.sat_cnt, 2));
503+
#else
504+
u8g_DrawBitmap(&u8g, u8g_GetWidth(&u8g) - 27+10, 0, 1, 10, satellite_bitmap);
505+
u8g_SetFont(&u8g, SMALL_FONT);
506+
u8g_DrawStr(&u8g, u8g_GetWidth(&u8g) - 20+10, 8, u8g_u16toa(pq.sat_cnt, 2));
507+
#endif
476508
}
477509

478510

@@ -542,6 +574,10 @@ const char *combo_fn_e_w(uint8_t idx)
542574

543575
M2_LABEL(el_gps_symbol_label, NULL, "Sym: ");
544576
M2_COMBO(el_gps_symbol_combo, "w10", &gps_tracker_variables.gps_symbol, 27, combo_symbol);
577+
578+
// M2_LABEL(el_gps_text_label, NULL, "Inf: ");
579+
// M2_TEXT(el_gps_text, "a1", &gps_tracker_variables.gps_pos_text, 4);
580+
545581
M2_LABEL(el_gps_frac_lat_label, NULL, "Lat: ");
546582
M2_U32NUM(el_gps_frac_lat_num, fmt_lat_lon_u32, &gps_tracker_variables.gps_frac_lat);
547583
M2_COMBO(el_gps_frac_lat_n_s, "w10", &gps_tracker_variables.gps_frac_lat_n_s, 2, combo_fn_n_s);
@@ -553,6 +589,10 @@ M2_LIST(list_gps_frac) = {
553589
&el_gps_symbol_combo,
554590
&m2_null_element,
555591

592+
// &el_gps_text_label,
593+
// &el_gps_text,
594+
// &m2_null_element,
595+
556596
&el_gps_frac_lat_label,
557597
&el_gps_frac_lat_num,
558598
&el_gps_frac_lat_n_s,
@@ -591,6 +631,7 @@ void cb_gps_frac_ok(m2_el_fnarg_p fnarg)
591631

592632
void cb_gps_frac_zero(m2_el_fnarg_p fnarg)
593633
{
634+
gps_tracker_variables.gps_symbol = 0;
594635
gps_tracker_variables.gps_frac_lat = 0;
595636
gps_tracker_variables.gps_grad_lat = 0;
596637
gps_tracker_variables.gps_frac_lat_n_s = 0;
@@ -638,6 +679,7 @@ M2_U32NUM(el_gps_sexa_lat_grad, fmt_a1c3, &gps_tracker_variables.gps_grad_lat);
638679
M2_U32NUM(el_gps_sexa_lat_num, fmt_a1c53, &gps_tracker_variables.gps_frac_lat);
639680
M2_U32NUM(el_gps_sexa_lon_grad, fmt_a1c3, &gps_tracker_variables.gps_grad_lon);
640681
M2_U32NUM(el_gps_sexa_lon_num, fmt_a1c53, &gps_tracker_variables.gps_frac_lon);
682+
641683
M2_LIST(list_gps_sexa) = {
642684
&el_gps_symbol_label,
643685
&el_gps_symbol_combo,
@@ -786,7 +828,9 @@ M2_ALIGN(top_el_ml, NULL, &el_ml_vlist);
786828

787829
/*=== show battery ===*/
788830

831+
#ifdef USE_BATTERY_ADC
789832
M2_ALIGN(el_show_battery, "|0", &el_goto_home);
833+
#endif
790834

791835
/*=== show system ===*/
792836

@@ -801,14 +845,17 @@ M2_ALIGN(el_show_gps_uart, "|0", &el_goto_home);
801845
M2_ALIGN(el_show_gps_stat, "|0", &el_goto_home);
802846

803847

804-
848+
#ifdef USE_BATTERY_ADC
805849
M2_ROOT(el_info_show_battery, fmt_W64f8, "Battery", &el_show_battery);
850+
#endif
806851
M2_ROOT(el_info_show_system, fmt_W64f8, "System Info", &el_show_system);
807852
M2_ROOT(el_info_show_gps_uart, fmt_W64f8, "GPS UART", &el_show_gps_uart);
808853
M2_ROOT(el_info_show_gps_stat, fmt_W64f8, "GPS Status", &el_show_gps_stat);
809854
M2_ROOT(el_info_back, fmt_W64f8, "Home", &el_home);
810855
M2_LIST(list_info) = {
856+
#ifdef USE_BATTERY_ADC
811857
&el_info_show_battery,
858+
#endif
812859
&el_info_show_system,
813860
&el_info_show_gps_uart,
814861
&el_info_show_gps_stat,
@@ -988,6 +1035,7 @@ void draw(void)
9881035
{
9891036
u8g_SetDefaultForegroundColor(&u8g);
9901037
draw_status();
1038+
#ifdef USE_BATTERY_ADC
9911039
if ( m2_GetRoot() == &el_show_battery )
9921040
{
9931041
u8g_SetFont(&u8g, NORMAL_FONT);
@@ -997,7 +1045,9 @@ void draw(void)
9971045
u8g_DrawStr(&u8g, 0, 12*3, "mV: ");
9981046
u8g_DrawStr(&u8g, 30, 12*3, u8g_u16toa((gps_tracker_variables.adc_battery*3300UL)/1024, 4));
9991047
}
1000-
else if ( m2_GetRoot() == &el_show_system )
1048+
else
1049+
#endif
1050+
if ( m2_GetRoot() == &el_show_system )
10011051
{
10021052
uint32_t h = 8;
10031053
u8g_SetFont(&u8g, SMALL_FONT);

sys/arm_u8g/gps/helvB08_gps.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
Fontname: -Adobe-Helvetica-Bold-R-Normal--11-80-100-100-P-60-ISO10646-1
3+
Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved.
4+
Capital A Height: 8, '1' Height: 8
5+
Calculated Max Values w=10 h=10 x= 1 y= 7 dx=11 dy= 0 ascent= 9 len=18
6+
Font Bounding box w=12 h=19 x=-1 y=-5
7+
Calculated Min Values x=-1 y=-2 dx= 0 dy= 0
8+
Pure Font ascent = 8 descent=-2
9+
X Font ascent = 8 descent=-2
10+
Max Font ascent = 9 descent=-2
11+
*/
12+
#include "u8g.h"
13+
const u8g_fntpgm_uint8_t helvB08_gps[1295] U8G_FONT_SECTION("helvB08_gps") = {
14+
0,12,19,255,251,8,1,182,3,122,32,127,254,9,254,8,
15+
254,0,0,0,3,0,1,2,8,8,4,1,0,192,192,192,
16+
192,128,128,0,192,3,3,3,5,1,5,160,160,160,7,7,
17+
7,6,255,0,40,40,126,40,252,80,80,5,10,10,6,0,
18+
255,32,112,168,224,112,56,40,168,112,32,7,8,8,8,0,
19+
0,98,180,104,16,16,44,86,140,7,8,8,8,0,0,112,
20+
216,216,112,222,204,220,118,1,3,3,3,1,5,128,128,128,
21+
3,10,10,4,0,254,32,96,64,192,192,192,192,64,96,32,
22+
3,10,10,4,0,254,128,192,64,96,96,96,96,64,192,128,
23+
3,3,3,4,0,5,160,64,160,6,5,5,6,0,1,48,
24+
48,252,48,48,2,4,4,3,0,254,192,192,64,128,4,1,
25+
1,5,0,3,240,2,2,2,3,0,0,192,192,4,8,8,
26+
4,0,0,16,16,32,32,64,64,128,128,5,8,8,6,0,
27+
0,112,216,216,216,216,216,216,112,3,8,8,6,1,0,96,
28+
224,96,96,96,96,96,96,5,8,8,6,0,0,112,216,24,
29+
24,48,96,192,248,5,8,8,6,0,0,112,216,24,48,24,
30+
24,216,112,6,8,8,6,0,0,8,24,56,88,152,252,24,
31+
24,5,8,8,6,0,0,248,192,192,240,24,152,216,112,5,
32+
8,8,6,0,0,112,216,192,240,216,216,216,112,5,8,8,
33+
6,0,0,248,24,24,48,48,96,96,96,5,8,8,6,0,
34+
0,112,216,216,112,216,216,216,112,5,8,8,6,0,0,112,
35+
216,216,216,120,24,216,112,2,6,6,3,0,0,192,192,0,
36+
0,192,192,2,8,8,3,0,254,192,192,0,0,192,192,64,
37+
128,4,5,5,5,0,1,48,96,192,96,48,5,3,3,6,
38+
0,2,248,0,248,4,5,5,5,0,1,192,96,48,96,192,
39+
5,8,8,6,0,0,112,216,24,48,96,96,0,96,10,9,
40+
18,11,0,255,31,0,96,128,77,64,146,64,162,64,164,128,
41+
155,0,64,0,62,0,7,8,8,8,0,0,56,56,108,108,
42+
108,254,198,198,6,8,8,7,0,0,248,204,204,248,204,204,
43+
204,248,7,8,8,8,0,0,60,102,194,192,192,194,102,60,
44+
6,8,8,7,0,0,240,216,204,204,204,204,216,240,5,8,
45+
8,6,0,0,248,192,192,248,192,192,192,248,5,8,8,6,
46+
0,0,248,192,192,240,192,192,192,192,7,8,8,8,0,0,
47+
60,102,194,192,206,198,102,58,6,8,8,7,0,0,204,204,
48+
204,252,204,204,204,204,2,8,8,3,0,0,192,192,192,192,
49+
192,192,192,192,5,8,8,6,0,0,24,24,24,24,24,24,
50+
216,112,7,8,8,7,0,0,204,216,240,224,240,216,204,198,
51+
5,8,8,6,0,0,192,192,192,192,192,192,192,248,9,8,
52+
16,10,0,0,193,128,227,128,227,128,247,128,213,128,221,128,
53+
201,128,201,128,7,8,8,8,0,0,198,230,230,214,214,206,
54+
206,198,7,8,8,8,0,0,56,108,198,198,198,198,108,56,
55+
6,8,8,7,0,0,248,204,204,204,248,192,192,192,7,9,
56+
9,8,0,255,56,108,198,198,198,214,108,60,2,6,8,8,
57+
7,0,0,248,204,204,204,248,204,204,204,6,8,8,7,0,
58+
0,120,204,224,120,28,140,204,120,6,8,8,7,0,0,252,
59+
48,48,48,48,48,48,48,6,8,8,7,0,0,204,204,204,
60+
204,204,204,204,120,7,8,8,8,0,0,198,198,108,108,108,
61+
56,56,16,10,8,16,11,0,0,204,192,204,192,204,192,109,
62+
128,109,128,127,128,51,0,51,0,7,8,8,8,0,0,198,
63+
198,108,56,56,108,198,198,8,8,8,9,0,0,195,195,102,
64+
102,60,24,24,24,6,8,8,7,0,0,252,12,24,48,112,
65+
96,192,252,3,10,10,4,0,254,224,192,192,192,192,192,192,
66+
192,192,224,4,8,8,4,0,0,128,128,64,64,32,32,16,
67+
16,3,10,10,4,0,254,224,96,96,96,96,96,96,96,96,
68+
224,4,4,4,5,0,4,96,240,144,144,6,1,1,6,0,
69+
254,252,2,2,2,3,0,7,128,64,6,6,6,6,0,0,
70+
112,152,120,216,216,108,5,8,8,6,0,0,192,192,240,216,
71+
216,216,216,240,4,6,6,5,0,0,112,208,192,192,208,112,
72+
5,8,8,6,0,0,24,24,120,216,216,216,216,120,5,6,
73+
6,6,0,0,112,216,248,192,216,112,5,8,8,4,255,0,
74+
56,96,240,96,96,96,96,96,5,8,8,6,0,254,104,216,
75+
216,216,216,120,24,112,5,8,8,6,0,0,192,192,240,216,
76+
216,216,216,216,2,8,8,3,0,0,192,0,192,192,192,192,
77+
192,192,3,10,10,3,255,254,96,0,96,96,96,96,96,96,
78+
96,192,6,8,8,6,0,0,192,192,216,240,224,240,216,204,
79+
2,8,8,3,0,0,192,192,192,192,192,192,192,192,8,6,
80+
6,9,0,0,182,219,219,219,219,219,5,6,6,6,0,0,
81+
176,216,216,216,216,216,5,6,6,6,0,0,112,216,216,216,
82+
216,112,5,8,8,6,0,254,176,216,216,216,216,240,192,192,
83+
5,8,8,6,0,254,104,216,216,216,216,120,24,24,4,6,
84+
6,4,0,0,176,224,192,192,192,192,5,6,6,6,0,0,
85+
112,216,112,24,216,112,4,8,8,4,255,0,96,96,240,96,
86+
96,96,96,48,5,6,6,6,0,0,216,216,216,216,216,104,
87+
5,6,6,6,0,0,216,216,216,80,112,32,7,6,6,8,
88+
0,0,214,214,214,108,108,108,6,6,6,7,0,0,204,120,
89+
48,120,204,204,5,8,8,6,0,254,216,216,216,216,120,48,
90+
48,96,5,6,6,6,0,0,248,24,48,96,192,248,4,10,
91+
10,5,0,254,48,96,96,96,192,96,96,96,96,48,1,10,
92+
10,3,1,254,128,128,128,128,128,128,128,128,128,128,4,10,
93+
10,5,0,254,192,96,96,96,48,96,96,96,96,192,5,2,
94+
2,6,0,3,104,176,3,3,3,4,0,5,224,160,224};

sys/arm_u8g/gps/info.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,37 @@ Implementation Plan
2323
- edit target identifier
2424
--> done
2525
- draw circle for special targets
26-
--> done (not tested)
26+
--> done (not tested) --> ok
2727
- display sats, battery, time(?) on all screens
2828
--> sat & bat
2929

3030
- create_gps_pos_string(&(pq.interface.pos)); in GPS Stat �bernehmen
3131
--> done
3232
- time is UTC: new pref. correct by +/- h
33+
--> done
3334

3435
- edit pos: zero or current pos: preferences
3536
better: [0] [x]
3637
copy from pq.interface.pos
37-
--> done, testing required
38+
--> done, testing required --> ok
3839

3940
- Add N,S,E,W to fractional from (instead of sign)
4041
--> done
4142

4243
- degree symbol not show, change font?
44+
--> done
45+
46+
- Store some text with the position
47+
--> M2_TEXT requires 900 Bytes extra --> too much
48+
--> will not be implemented
49+
50+
- Show "course" on the GPS map
51+
--> started, not tested --> needs more testing
52+
53+
- target position: clear map special char with "0"
54+
--> done
55+
56+
- allow switching of baud rate (4800, 9600)
4357

4458
- low power modes?
4559

sys/arm_u8g/gps/init.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
#include "pq.h"
77
#include "u8g.h"
88

9-
#define NORMAL_FONT u8g_font_helvB08r
9+
extern const u8g_fntpgm_uint8_t helvB08_gps[1295] U8G_FONT_SECTION("helvB08_gps");
10+
11+
//#define NORMAL_FONT u8g_font_helvB08r
12+
#define NORMAL_FONT helvB08_gps
1013
#define SMALL_FONT u8g_font_5x8r
1114

12-
#define MAP_POS_CNT 4
15+
#define MAP_POS_CNT 10
1316

1417
struct gps_map_pos_struct
1518
{
@@ -51,6 +54,8 @@ struct gps_tracker_variables_struct {
5154
uint8_t gps_frac_lat_n_s;
5255
uint8_t gps_frac_lon_e_w;
5356

57+
//char gps_pos_text[8];
58+
5459
uint32_t gps_frac_lat; /* M2 Data Entry */
5560
uint32_t gps_frac_lon; /* M2 Data Entry */
5661

sys/arm_u8g/gps/pq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ void pq_DegreeMinutesToStr(pq_t *pq, uint8_t is_lat, char *s)
517517
{
518518
pq_SetSignPrefix(is_lat, pq->pos_is_neg, s);
519519
pq_itoa(s+2, pq->pos_degree, 3);
520-
s[5] = '°';
520+
s[5] = '\x7f'; /* degree symbol of helvB08 font */
521521
s[6] = ' ';
522522
pq_itoa(s+7, pq->pos_minutes, 2);
523523
s[9] = '.';

0 commit comments

Comments
 (0)