Skip to content

Commit

Permalink
gps tracker configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Jan 19, 2014
1 parent 0222b86 commit 393ceea
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 13 deletions.
47 changes: 47 additions & 0 deletions sys/arm_u8g/gps/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
config.h
Configuration file for the GPS tracker device.
m2tklib - Mini Interative Interface Toolkit Library
u8glib - Universal 8bit Graphics Library
Copyright (C) 2013 [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _CONFIG_H
#define _CONFIG_H

/*
Define the following variable to enable monitoring of battery voltage.
ADC2 at R_PIO1_1 will be used for monitoring.
This will also enable the battery symbol in the upper left of the display and
the battery submenu.
*/
//#define USE_BATTERY_ADC


/*
Select transmit speed of the connected GPS module.
If the following macro is defined, use 4800 Baud.
If the following macro is not defined, use 9600 Baud
*/
#define USE_GPS_4800BAUD


#endif
58 changes: 54 additions & 4 deletions sys/arm_u8g/gps/gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "init.h"
#include "util.h"
#include "exmem.h"
#include "config.h"

/*=========================================================================*/
/* global variables and objects */
Expand Down Expand Up @@ -99,9 +100,13 @@ float gps_cos(float x)
/*=======================================================================*/
uint8_t update_gps_tracker_variables(void)
{
#ifdef USE_BATTERY_ADC
uint16_t tmp16;
#endif
uint8_t is_changed = 0;



#ifdef USE_BATTERY_ADC
tmp16 = adc_get_value(2);
tmp16 = low_pass( &gps_tracker_variables.adc_low_pass_z, tmp16, 7);

Expand All @@ -110,6 +115,7 @@ uint8_t update_gps_tracker_variables(void)
// is_changed = 1;
gps_tracker_variables.adc_battery = tmp16;
}
#endif

if ( gps_tracker_variables.sec_cnt != gps_tracker_variables.sec_cnt_raw )
{
Expand Down Expand Up @@ -299,10 +305,12 @@ void prepare_map(void)
#define MAP_SCALE_OFFSET 6
#define MAP_RADIUS 21
#define MAP_TARGET_RADIUS 2
#define MAP_COURSE_RADIUS 3
static void draw_map_mode_0(void)
{
uint8_t i;
gps_float_t half_map_pixel_size = MAP_RADIUS;
gps_float_t course;
u8g_int_t x_org = MAP_OFFSET+MAP_RADIUS;
u8g_int_t y_org = MAP_OFFSET+MAP_RADIUS;
u8g_int_t x,y;
Expand All @@ -318,6 +326,24 @@ static void draw_map_mode_0(void)
u8g_DrawStr(&u8g, MAP_OFFSET+MAP_RADIUS+2, MAP_OFFSET+ 2*MAP_RADIUS + MAP_SCALE_OFFSET + 4, gps_get_half_map_str());
u8g_DrawCircle(&u8g, x_org,y_org,MAP_RADIUS, U8G_DRAW_ALL);

/* true_course == 0: geogr. north, counts clockwise (?) */
/* true_course == 90: east */
course = ((gps_float_t)(360+90))-pq.interface.true_course;
course *= num._pi_div_180;
while ( course > num.pi )
{
course -= num.pi;
course -= num.pi;
}

//x = x_org + half_map_pixel_size*gps_cos(course);
//y = y_org - half_map_pixel_size*gps_sin(course);
x = half_map_pixel_size*gps_cos(course);
y = half_map_pixel_size*gps_sin(course);
//u8g_DrawCircle(&u8g, x,y, MAP_COURSE_RADIUS, U8G_DRAW_ALL);
u8g_DrawLine(&u8g, x_org + x/2, y_org -y/2, x_org + x, y_org -y);


/* loop through last positions, returned from the GPS receiver */
for( i = 0; i < pq.cnt; i++ )
{
Expand Down Expand Up @@ -451,8 +477,9 @@ const uint8_t satellite_bitmap[10] = { 0x00, 0x010, 0x092, 0x054, 0x038, 0x010,

void draw_status(void)
{
int32_t battery;
#ifdef USE_BATTERY_ADC
int32_t i;
int32_t battery;
battery = (gps_tracker_variables.adc_battery*3300L);
battery /= 1024;
battery -= BATTERY_EMPTY_LEVEL_mV;
Expand All @@ -473,6 +500,11 @@ void draw_status(void)
u8g_DrawBitmap(&u8g, u8g_GetWidth(&u8g) - 27, 0, 1, 10, satellite_bitmap);
u8g_SetFont(&u8g, SMALL_FONT);
u8g_DrawStr(&u8g, u8g_GetWidth(&u8g) - 20, 8, u8g_u16toa(pq.sat_cnt, 2));
#else
u8g_DrawBitmap(&u8g, u8g_GetWidth(&u8g) - 27+10, 0, 1, 10, satellite_bitmap);
u8g_SetFont(&u8g, SMALL_FONT);
u8g_DrawStr(&u8g, u8g_GetWidth(&u8g) - 20+10, 8, u8g_u16toa(pq.sat_cnt, 2));
#endif
}


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

M2_LABEL(el_gps_symbol_label, NULL, "Sym: ");
M2_COMBO(el_gps_symbol_combo, "w10", &gps_tracker_variables.gps_symbol, 27, combo_symbol);

// M2_LABEL(el_gps_text_label, NULL, "Inf: ");
// M2_TEXT(el_gps_text, "a1", &gps_tracker_variables.gps_pos_text, 4);

M2_LABEL(el_gps_frac_lat_label, NULL, "Lat: ");
M2_U32NUM(el_gps_frac_lat_num, fmt_lat_lon_u32, &gps_tracker_variables.gps_frac_lat);
M2_COMBO(el_gps_frac_lat_n_s, "w10", &gps_tracker_variables.gps_frac_lat_n_s, 2, combo_fn_n_s);
Expand All @@ -553,6 +589,10 @@ M2_LIST(list_gps_frac) = {
&el_gps_symbol_combo,
&m2_null_element,

// &el_gps_text_label,
// &el_gps_text,
// &m2_null_element,

&el_gps_frac_lat_label,
&el_gps_frac_lat_num,
&el_gps_frac_lat_n_s,
Expand Down Expand Up @@ -591,6 +631,7 @@ void cb_gps_frac_ok(m2_el_fnarg_p fnarg)

void cb_gps_frac_zero(m2_el_fnarg_p fnarg)
{
gps_tracker_variables.gps_symbol = 0;
gps_tracker_variables.gps_frac_lat = 0;
gps_tracker_variables.gps_grad_lat = 0;
gps_tracker_variables.gps_frac_lat_n_s = 0;
Expand Down Expand Up @@ -638,6 +679,7 @@ M2_U32NUM(el_gps_sexa_lat_grad, fmt_a1c3, &gps_tracker_variables.gps_grad_lat);
M2_U32NUM(el_gps_sexa_lat_num, fmt_a1c53, &gps_tracker_variables.gps_frac_lat);
M2_U32NUM(el_gps_sexa_lon_grad, fmt_a1c3, &gps_tracker_variables.gps_grad_lon);
M2_U32NUM(el_gps_sexa_lon_num, fmt_a1c53, &gps_tracker_variables.gps_frac_lon);

M2_LIST(list_gps_sexa) = {
&el_gps_symbol_label,
&el_gps_symbol_combo,
Expand Down Expand Up @@ -786,7 +828,9 @@ M2_ALIGN(top_el_ml, NULL, &el_ml_vlist);

/*=== show battery ===*/

#ifdef USE_BATTERY_ADC
M2_ALIGN(el_show_battery, "|0", &el_goto_home);
#endif

/*=== show system ===*/

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



#ifdef USE_BATTERY_ADC
M2_ROOT(el_info_show_battery, fmt_W64f8, "Battery", &el_show_battery);
#endif
M2_ROOT(el_info_show_system, fmt_W64f8, "System Info", &el_show_system);
M2_ROOT(el_info_show_gps_uart, fmt_W64f8, "GPS UART", &el_show_gps_uart);
M2_ROOT(el_info_show_gps_stat, fmt_W64f8, "GPS Status", &el_show_gps_stat);
M2_ROOT(el_info_back, fmt_W64f8, "Home", &el_home);
M2_LIST(list_info) = {
#ifdef USE_BATTERY_ADC
&el_info_show_battery,
#endif
&el_info_show_system,
&el_info_show_gps_uart,
&el_info_show_gps_stat,
Expand Down Expand Up @@ -988,6 +1035,7 @@ void draw(void)
{
u8g_SetDefaultForegroundColor(&u8g);
draw_status();
#ifdef USE_BATTERY_ADC
if ( m2_GetRoot() == &el_show_battery )
{
u8g_SetFont(&u8g, NORMAL_FONT);
Expand All @@ -997,7 +1045,9 @@ void draw(void)
u8g_DrawStr(&u8g, 0, 12*3, "mV: ");
u8g_DrawStr(&u8g, 30, 12*3, u8g_u16toa((gps_tracker_variables.adc_battery*3300UL)/1024, 4));
}
else if ( m2_GetRoot() == &el_show_system )
else
#endif
if ( m2_GetRoot() == &el_show_system )
{
uint32_t h = 8;
u8g_SetFont(&u8g, SMALL_FONT);
Expand Down
94 changes: 94 additions & 0 deletions sys/arm_u8g/gps/helvB08_gps.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
Fontname: -Adobe-Helvetica-Bold-R-Normal--11-80-100-100-P-60-ISO10646-1
Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved.
Capital A Height: 8, '1' Height: 8
Calculated Max Values w=10 h=10 x= 1 y= 7 dx=11 dy= 0 ascent= 9 len=18
Font Bounding box w=12 h=19 x=-1 y=-5
Calculated Min Values x=-1 y=-2 dx= 0 dy= 0
Pure Font ascent = 8 descent=-2
X Font ascent = 8 descent=-2
Max Font ascent = 9 descent=-2
*/
#include "u8g.h"
const u8g_fntpgm_uint8_t helvB08_gps[1295] U8G_FONT_SECTION("helvB08_gps") = {
0,12,19,255,251,8,1,182,3,122,32,127,254,9,254,8,
254,0,0,0,3,0,1,2,8,8,4,1,0,192,192,192,
192,128,128,0,192,3,3,3,5,1,5,160,160,160,7,7,
7,6,255,0,40,40,126,40,252,80,80,5,10,10,6,0,
255,32,112,168,224,112,56,40,168,112,32,7,8,8,8,0,
0,98,180,104,16,16,44,86,140,7,8,8,8,0,0,112,
216,216,112,222,204,220,118,1,3,3,3,1,5,128,128,128,
3,10,10,4,0,254,32,96,64,192,192,192,192,64,96,32,
3,10,10,4,0,254,128,192,64,96,96,96,96,64,192,128,
3,3,3,4,0,5,160,64,160,6,5,5,6,0,1,48,
48,252,48,48,2,4,4,3,0,254,192,192,64,128,4,1,
1,5,0,3,240,2,2,2,3,0,0,192,192,4,8,8,
4,0,0,16,16,32,32,64,64,128,128,5,8,8,6,0,
0,112,216,216,216,216,216,216,112,3,8,8,6,1,0,96,
224,96,96,96,96,96,96,5,8,8,6,0,0,112,216,24,
24,48,96,192,248,5,8,8,6,0,0,112,216,24,48,24,
24,216,112,6,8,8,6,0,0,8,24,56,88,152,252,24,
24,5,8,8,6,0,0,248,192,192,240,24,152,216,112,5,
8,8,6,0,0,112,216,192,240,216,216,216,112,5,8,8,
6,0,0,248,24,24,48,48,96,96,96,5,8,8,6,0,
0,112,216,216,112,216,216,216,112,5,8,8,6,0,0,112,
216,216,216,120,24,216,112,2,6,6,3,0,0,192,192,0,
0,192,192,2,8,8,3,0,254,192,192,0,0,192,192,64,
128,4,5,5,5,0,1,48,96,192,96,48,5,3,3,6,
0,2,248,0,248,4,5,5,5,0,1,192,96,48,96,192,
5,8,8,6,0,0,112,216,24,48,96,96,0,96,10,9,
18,11,0,255,31,0,96,128,77,64,146,64,162,64,164,128,
155,0,64,0,62,0,7,8,8,8,0,0,56,56,108,108,
108,254,198,198,6,8,8,7,0,0,248,204,204,248,204,204,
204,248,7,8,8,8,0,0,60,102,194,192,192,194,102,60,
6,8,8,7,0,0,240,216,204,204,204,204,216,240,5,8,
8,6,0,0,248,192,192,248,192,192,192,248,5,8,8,6,
0,0,248,192,192,240,192,192,192,192,7,8,8,8,0,0,
60,102,194,192,206,198,102,58,6,8,8,7,0,0,204,204,
204,252,204,204,204,204,2,8,8,3,0,0,192,192,192,192,
192,192,192,192,5,8,8,6,0,0,24,24,24,24,24,24,
216,112,7,8,8,7,0,0,204,216,240,224,240,216,204,198,
5,8,8,6,0,0,192,192,192,192,192,192,192,248,9,8,
16,10,0,0,193,128,227,128,227,128,247,128,213,128,221,128,
201,128,201,128,7,8,8,8,0,0,198,230,230,214,214,206,
206,198,7,8,8,8,0,0,56,108,198,198,198,198,108,56,
6,8,8,7,0,0,248,204,204,204,248,192,192,192,7,9,
9,8,0,255,56,108,198,198,198,214,108,60,2,6,8,8,
7,0,0,248,204,204,204,248,204,204,204,6,8,8,7,0,
0,120,204,224,120,28,140,204,120,6,8,8,7,0,0,252,
48,48,48,48,48,48,48,6,8,8,7,0,0,204,204,204,
204,204,204,204,120,7,8,8,8,0,0,198,198,108,108,108,
56,56,16,10,8,16,11,0,0,204,192,204,192,204,192,109,
128,109,128,127,128,51,0,51,0,7,8,8,8,0,0,198,
198,108,56,56,108,198,198,8,8,8,9,0,0,195,195,102,
102,60,24,24,24,6,8,8,7,0,0,252,12,24,48,112,
96,192,252,3,10,10,4,0,254,224,192,192,192,192,192,192,
192,192,224,4,8,8,4,0,0,128,128,64,64,32,32,16,
16,3,10,10,4,0,254,224,96,96,96,96,96,96,96,96,
224,4,4,4,5,0,4,96,240,144,144,6,1,1,6,0,
254,252,2,2,2,3,0,7,128,64,6,6,6,6,0,0,
112,152,120,216,216,108,5,8,8,6,0,0,192,192,240,216,
216,216,216,240,4,6,6,5,0,0,112,208,192,192,208,112,
5,8,8,6,0,0,24,24,120,216,216,216,216,120,5,6,
6,6,0,0,112,216,248,192,216,112,5,8,8,4,255,0,
56,96,240,96,96,96,96,96,5,8,8,6,0,254,104,216,
216,216,216,120,24,112,5,8,8,6,0,0,192,192,240,216,
216,216,216,216,2,8,8,3,0,0,192,0,192,192,192,192,
192,192,3,10,10,3,255,254,96,0,96,96,96,96,96,96,
96,192,6,8,8,6,0,0,192,192,216,240,224,240,216,204,
2,8,8,3,0,0,192,192,192,192,192,192,192,192,8,6,
6,9,0,0,182,219,219,219,219,219,5,6,6,6,0,0,
176,216,216,216,216,216,5,6,6,6,0,0,112,216,216,216,
216,112,5,8,8,6,0,254,176,216,216,216,216,240,192,192,
5,8,8,6,0,254,104,216,216,216,216,120,24,24,4,6,
6,4,0,0,176,224,192,192,192,192,5,6,6,6,0,0,
112,216,112,24,216,112,4,8,8,4,255,0,96,96,240,96,
96,96,96,48,5,6,6,6,0,0,216,216,216,216,216,104,
5,6,6,6,0,0,216,216,216,80,112,32,7,6,6,8,
0,0,214,214,214,108,108,108,6,6,6,7,0,0,204,120,
48,120,204,204,5,8,8,6,0,254,216,216,216,216,120,48,
48,96,5,6,6,6,0,0,248,24,48,96,192,248,4,10,
10,5,0,254,48,96,96,96,192,96,96,96,96,48,1,10,
10,3,1,254,128,128,128,128,128,128,128,128,128,128,4,10,
10,5,0,254,192,96,96,96,48,96,96,96,96,192,5,2,
2,6,0,3,104,176,3,3,3,4,0,5,224,160,224};
18 changes: 16 additions & 2 deletions sys/arm_u8g/gps/info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,37 @@ Implementation Plan
- edit target identifier
--> done
- draw circle for special targets
--> done (not tested)
--> done (not tested) --> ok
- display sats, battery, time(?) on all screens
--> sat & bat

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

- edit pos: zero or current pos: preferences
better: [0] [x]
copy from pq.interface.pos
--> done, testing required
--> done, testing required --> ok

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

- degree symbol not show, change font?
--> done

- Store some text with the position
--> M2_TEXT requires 900 Bytes extra --> too much
--> will not be implemented

- Show "course" on the GPS map
--> started, not tested --> needs more testing

- target position: clear map special char with "0"
--> done

- allow switching of baud rate (4800, 9600)

- low power modes?

9 changes: 7 additions & 2 deletions sys/arm_u8g/gps/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
#include "pq.h"
#include "u8g.h"

#define NORMAL_FONT u8g_font_helvB08r
extern const u8g_fntpgm_uint8_t helvB08_gps[1295] U8G_FONT_SECTION("helvB08_gps");

//#define NORMAL_FONT u8g_font_helvB08r
#define NORMAL_FONT helvB08_gps
#define SMALL_FONT u8g_font_5x8r

#define MAP_POS_CNT 4
#define MAP_POS_CNT 10

struct gps_map_pos_struct
{
Expand Down Expand Up @@ -51,6 +54,8 @@ struct gps_tracker_variables_struct {
uint8_t gps_frac_lat_n_s;
uint8_t gps_frac_lon_e_w;

//char gps_pos_text[8];

uint32_t gps_frac_lat; /* M2 Data Entry */
uint32_t gps_frac_lon; /* M2 Data Entry */

Expand Down
2 changes: 1 addition & 1 deletion sys/arm_u8g/gps/pq.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void pq_DegreeMinutesToStr(pq_t *pq, uint8_t is_lat, char *s)
{
pq_SetSignPrefix(is_lat, pq->pos_is_neg, s);
pq_itoa(s+2, pq->pos_degree, 3);
s[5] = '°';
s[5] = '\x7f'; /* degree symbol of helvB08 font */
s[6] = ' ';
pq_itoa(s+7, pq->pos_minutes, 2);
s[9] = '.';
Expand Down
Loading

0 comments on commit 393ceea

Please sign in to comment.