Line 47... |
Line 47... |
47 |
#include "GPS.h" //define PINs GPS,TL,LED,REF,I2C |
47 |
#include "GPS.h" //define PINs GPS,TL,LED,REF,I2C |
48 |
#include "nmea_scan.h" |
48 |
#include "nmea_scan.h" |
49 |
|
49 |
|
50 |
//************************************************************************ |
50 |
//************************************************************************ |
51 |
// pomocne |
51 |
// pomocne |
- |
|
52 |
|
52 |
#define WIDTH_CHAR_SIGNALL 8 |
53 |
#define WIDTH_CHAR_SIGNALL 8 |
53 |
prog_uint8_t CHAR_SIGNALL[WIDTH_CHAR_SIGNALL]={127,12,30,51,51,30,12,127}; |
54 |
prog_uint8_t CHAR_SIGNALL[WIDTH_CHAR_SIGNALL]={127,12,30,51,51,30,12,127}; |
54 |
|
55 |
|
55 |
#define WIDTH_CHAR_SIGNALL_D 8 |
56 |
#define WIDTH_CHAR_SIGNALL_D 8 |
56 |
prog_uint8_t CHAR_SIGNALL_D[WIDTH_CHAR_SIGNALL_D]={127,12,30,63,63,30,12,127}; |
57 |
prog_uint8_t CHAR_SIGNALL_D[WIDTH_CHAR_SIGNALL_D]={127,12,30,63,63,30,12,127}; |
Line 63... |
Line 64... |
63 |
|
64 |
|
64 |
#define WIDTH_CHAR_LIGHT 5 |
65 |
#define WIDTH_CHAR_LIGHT 5 |
65 |
prog_uint8_t CHAR_LIGHT[WIDTH_CHAR_LIGHT]={127,65,95,95,127}; |
66 |
prog_uint8_t CHAR_LIGHT[WIDTH_CHAR_LIGHT]={127,65,95,95,127}; |
66 |
|
67 |
|
67 |
|
68 |
|
68 |
|
- |
|
- |
|
69 |
#define BOOT() (((void(*)(void))(char *)0x7C00)()) |
- |
|
70 |
#define RESET() (((void(*)(void))(char *)0x0000)()) |
69 |
//*********************************************************************** |
71 |
//*********************************************************************** |
70 |
// global variables |
72 |
// global variables |
- |
|
73 |
|
71 |
extern uint8_t video_buf[504]; |
74 |
extern uint8_t video_buf[504]; |
72 |
extern uint8_t *offset_text; |
75 |
extern uint8_t *offset_text; |
73 |
|
76 |
|
74 |
uint8_t id_mod; |
77 |
uint8_t id_mod; |
75 |
char scan_buf[MAX_NMEA_LOAD]; |
78 |
char scan_buf[MAX_NMEA_LOAD]; |
Line 77... |
Line 80... |
77 |
DATA_GPS gps; |
80 |
DATA_GPS gps; |
78 |
DATA_GPS *pgps; |
81 |
DATA_GPS *pgps; |
79 |
|
82 |
|
80 |
enum {ID_TIME,ID_LOCATION,ID_COURSE,ID_ALL_POSITION,ID_ALL_SERVICE,ID_SERVICE,ID_TEMP,ID_SATELITES,ID_NORTH,ID_NAV}; |
83 |
enum {ID_TIME,ID_LOCATION,ID_COURSE,ID_ALL_POSITION,ID_ALL_SERVICE,ID_SERVICE,ID_TEMP,ID_SATELITES,ID_NORTH,ID_NAV}; |
81 |
|
84 |
|
- |
|
85 |
static FILE mystdout = FDEV_SETUP_STREAM(lcd_put, NULL,_FDEV_SETUP_WRITE); // in lcd.h |
- |
|
86 |
static FILE mystdout2 = FDEV_SETUP_STREAM(lcd_put2, NULL,_FDEV_SETUP_WRITE); // in lcd.h |
82 |
|
87 |
|
- |
|
88 |
//************************************************************************ |
- |
|
89 |
// prototypes |
- |
|
90 |
|
83 |
//static int lcd_put(char c, FILE *stream); |
91 |
//(*bootloader)(void) = 0x7C00; |
84 |
static FILE mystdout = FDEV_SETUP_STREAM(lcd_put, NULL,_FDEV_SETUP_WRITE); |
92 |
void delay_ms(uint16_t time); |
85 |
//static int lcd_put2(char c, FILE *stream); |
93 |
void null_variables(void); |
86 |
static FILE mystdout2 = FDEV_SETUP_STREAM(lcd_put2, NULL,_FDEV_SETUP_WRITE); |
- |
|
87 |
|
94 |
|
88 |
//************************************************************************ |
95 |
//************************************************************************ |
89 |
// general cpu init |
96 |
// general cpu init |
90 |
|
97 |
|
91 |
void general_cpu_init(void) |
98 |
void general_cpu_init(void) |
Line 96... |
Line 103... |
96 |
TL2_INIT; |
103 |
TL2_INIT; |
97 |
TL2_PULLUP; |
104 |
TL2_PULLUP; |
98 |
TL3_INIT; |
105 |
TL3_INIT; |
99 |
TL3_PULLUP; |
106 |
TL3_PULLUP; |
100 |
|
107 |
|
101 |
RX_INIT; |
108 |
USB_INIT; |
102 |
RX_PULLUP; |
109 |
//USB_PULLUP; |
103 |
|
110 |
|
104 |
GPS_INIT; |
111 |
GPS_INIT; |
105 |
GPS_OFF; |
112 |
GPS_OFF; |
106 |
|
113 |
|
107 |
REF_INIT; |
114 |
REF_INIT; |
Line 118... |
Line 125... |
118 |
|
125 |
|
119 |
LED_INIT; |
126 |
LED_INIT; |
120 |
LED_OFF; |
127 |
LED_OFF; |
121 |
|
128 |
|
122 |
//*** EXTERNAL PIN INTERRUPTS |
129 |
//*** EXTERNAL PIN INTERRUPTS |
123 |
EICRA = _BV(ISC21); //pin INT2 - TL2 |
130 |
//EICRA = _BV(ISC21); //pin INT2 - TL2 |
124 |
EIMSK = _BV(INT2); //pin INT2 - TL2 |
131 |
//EIMSK = _BV(INT2); //pin INT2 - TL2 |
- |
|
132 |
|
- |
|
133 |
|
- |
|
134 |
//*** PIN CHANGE INTERRUPTS PCINT29 |
125 |
//PCICR = _BV(PCIE1); //pin change TL1,TL2,TL3 |
135 |
PCICR = _BV(PCIE1); |
126 |
//PCMSK1 = _BV(PCINT10) | _BV(PCINT11) |_BV(PCINT12); //pin change TL1,TL2,TL3 |
136 |
PCMSK1 = _BV(PCINT10) | _BV(PCINT11) |_BV(PCINT12); //pin change TL1,TL2,TL3 |
127 |
|
137 |
|
- |
|
138 |
PCICR |= _BV(PCIE3); |
- |
|
139 |
PCMSK3 = _BV(PCINT29); // pin USB |
- |
|
140 |
|
128 |
//*** TIMER1 *** tik for TL fosc/8 /1024(TCNT1) cca 8ms |
141 |
//*** TIMER1 *** tik for TL fosc/64 /1024(TCNT1) cca 8ms |
129 |
TCNT1 = 0; |
142 |
TCNT1 = 0; |
130 |
OCR1A = 1024; |
143 |
OCR1A = 1024; |
131 |
TCCR1A = _BV(WGM11) | _BV(WGM10); |
144 |
TCCR1A = _BV(WGM11) | _BV(WGM10); |
132 |
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS11) ; // TIMER1 fast PWM |
145 |
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // TIMER1 fast PWM |
133 |
TIMSK1 = _BV(TOIE1); |
146 |
TIMSK1 = _BV(TOIE1); |
134 |
|
147 |
|
135 |
//*** TIMER2 *** RTC |
148 |
//*** TIMER2 *** RTC |
136 |
ASSR = _BV(AS2); |
149 |
ASSR = _BV(AS2); |
137 |
TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20); |
150 |
TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20); |
Line 143... |
Line 156... |
143 |
//*** WDT *** |
156 |
//*** WDT *** |
144 |
//WDTCSR = _BV(WDCE) | _BV(WDE); |
157 |
//WDTCSR = _BV(WDCE) | _BV(WDE); |
145 |
//WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0); |
158 |
//WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0); |
146 |
|
159 |
|
147 |
//*** USART0 *** RX PD0, TX PD1, GPS |
160 |
//*** USART0 *** RX PD0, TX PD1, GPS |
148 |
UBRR0 = 12; |
161 |
UBRR0 = 95; |
149 |
//UCSR0A = |
162 |
//UCSR0A = |
150 |
UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0); |
163 |
UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0); |
151 |
|
164 |
|
152 |
//*** USART1 *** RX PD2, TX PD3 PC |
165 |
//*** USART1 *** RX PD2, TX PD3 PC |
- |
|
166 |
#ifndef DEBUG |
153 |
UBRR1 = 12; |
167 |
UBRR1 = 95; |
- |
|
168 |
#else |
- |
|
169 |
UBRR1 = 3; |
- |
|
170 |
#endif |
154 |
//UCSR0A = |
171 |
//UCSR0A = |
155 |
UCSR1B = _BV(RXCIE1) | _BV(RXEN0) | _BV(TXEN1); |
172 |
UCSR1B = _BV(RXCIE1) | _BV(RXEN0) | _BV(TXEN1); |
156 |
|
173 |
|
157 |
//*** ADC *** |
174 |
//*** ADC *** |
158 |
ADMUX = _BV(REFS1) | _BV(MUX0); |
175 |
ADMUX = _BV(REFS1) | _BV(MUX0); |
159 |
ADCSRA = _BV(ADPS1) | _BV(ADPS0); |
176 |
ADCSRA = _BV(ADPS1) | _BV(ADPS2); |
160 |
|
177 |
|
161 |
} |
178 |
} |
162 |
|
179 |
|
163 |
//************************************************************************ |
180 |
//************************************************************************ |
164 |
// interrupts + RTC / clock 8s ... TIMER2 / |
181 |
// interrupts + RTC / clock 8s ... TIMER2 / |
Line 228... |
Line 245... |
228 |
if (++rx_shift >= MAX_RX_BUF) rx_shift =0; |
245 |
if (++rx_shift >= MAX_RX_BUF) rx_shift =0; |
229 |
rx_buf[rx_shift]=UDR0; |
246 |
rx_buf[rx_shift]=UDR0; |
230 |
UDR1 = UDR0; |
247 |
UDR1 = UDR0; |
231 |
} |
248 |
} |
232 |
|
249 |
|
- |
|
250 |
uint8_t first_char_usart1 = 0; |
- |
|
251 |
|
233 |
ISR(USART1_RX_vect) |
252 |
ISR(USART1_RX_vect) |
234 |
{ |
253 |
{ |
- |
|
254 |
#ifndef DEBUG |
235 |
UDR0 = UDR1; |
255 |
UDR0 = UDR1; |
- |
|
256 |
#else |
- |
|
257 |
if (TL1_INPUT && TL3_INPUT) BOOT(); |
- |
|
258 |
//bootloader(); |
- |
|
259 |
#endif |
- |
|
260 |
} |
- |
|
261 |
|
- |
|
262 |
ISR(PCINT1_vect) |
- |
|
263 |
{ |
- |
|
264 |
if ((!TL3_INPUT) && (!TL1_INPUT)) RESET(); |
- |
|
265 |
} |
- |
|
266 |
|
- |
|
267 |
ISR(PCINT3_vect) |
- |
|
268 |
{ |
- |
|
269 |
if (!TL2_INPUT && USB_INPUT) |
- |
|
270 |
{ |
- |
|
271 |
cli(); |
- |
|
272 |
buffer_clr(); |
- |
|
273 |
gotoxy(2,3); |
- |
|
274 |
fprintf(&mystdout2,"programing"); |
- |
|
275 |
gotoxy(6,5); |
- |
|
276 |
fprintf(&mystdout2,"mod"); |
- |
|
277 |
lcd_refresh(); |
- |
|
278 |
delay_ms(1000); |
- |
|
279 |
BOOT(); |
- |
|
280 |
} |
- |
|
281 |
|
236 |
} |
282 |
} |
237 |
|
283 |
|
238 |
EMPTY_INTERRUPT(INT0_vect) |
284 |
EMPTY_INTERRUPT(INT0_vect) |
239 |
EMPTY_INTERRUPT(INT2_vect) |
285 |
EMPTY_INTERRUPT(INT2_vect) |
240 |
EMPTY_INTERRUPT(PCINT1_vect) |
- |
|
241 |
EMPTY_INTERRUPT(WDT_vect) |
286 |
EMPTY_INTERRUPT(WDT_vect) |
242 |
|
287 |
|
243 |
//************************************************************************ |
288 |
//************************************************************************ |
244 |
// delay_ms functions /define fcpu / |
289 |
// delay_ms functions /define fcpu / |
245 |
|
290 |
|
Line 254... |
Line 299... |
254 |
{ |
299 |
{ |
255 |
while ( !( UCSR0A & _BV(UDRE0)) ); |
300 |
while ( !( UCSR0A & _BV(UDRE0)) ); |
256 |
UDR0 = c; |
301 |
UDR0 = c; |
257 |
} |
302 |
} |
258 |
|
303 |
|
259 |
void set_static_navigation(uint8_t static_nav) |
- |
|
260 |
{ |
- |
|
261 |
char chsum[3]; |
- |
|
262 |
char SWITCH_TO_SIRF[]="$PSRF100,0,4800,8,1,0" ; |
- |
|
263 |
uint8_t SET_STATIC_NAV[10]={0xa0,0xA2,0x00,0x02,0x8f,0x00,0x00,0x8f,0xB0,0xB3}; |
- |
|
264 |
uint8_t SWITCH_TO_NMEA[10]={0xa0,0xA2,0x00,0x02,0x87,0x02,0x00,0x89,0xB0,0xB3}; |
- |
|
265 |
uint8_t chksum; |
- |
|
266 |
uint8_t i; |
- |
|
267 |
|
- |
|
268 |
chksum=0; |
- |
|
269 |
for (i=0;i<21;i++) |
- |
|
270 |
{ |
- |
|
271 |
gps_put(SWITCH_TO_SIRF[i]); |
- |
|
272 |
chksum +=SWITCH_TO_SIRF[i]; |
- |
|
273 |
} |
- |
|
274 |
gps_put('*'); |
- |
|
275 |
sprintf(chsum,"%02X",chksum); |
- |
|
276 |
gps_put(chsum[0]); |
- |
|
277 |
gps_put(chsum[1]); |
- |
|
278 |
gps_put('\r'); |
- |
|
279 |
gps_put('\n'); |
- |
|
280 |
|
- |
|
281 |
if (static_nav) |
- |
|
282 |
{ |
- |
|
283 |
} |
- |
|
284 |
else |
- |
|
285 |
{ |
- |
|
286 |
for (i=0;i<10;i++) gps_put(SET_STATIC_NAV[i]); |
- |
|
287 |
} |
- |
|
288 |
//for (i=0;i<10;i++) gps_put(SWITCH_TO_NMEA[i]); |
- |
|
289 |
} |
- |
|
290 |
|
- |
|
291 |
//************************************************************************ |
304 |
//************************************************************************ |
292 |
// key + timer1_ovf |
305 |
// key + timer1_ovf |
293 |
|
306 |
|
294 |
|
307 |
|
295 |
volatile uint8_t key_press; |
308 |
volatile uint8_t key_press; |
Line 302... |
Line 315... |
302 |
|
315 |
|
303 |
void timer1_tik(void) |
316 |
void timer1_tik(void) |
304 |
{ |
317 |
{ |
305 |
uint8_t key_temp; |
318 |
uint8_t key_temp; |
306 |
|
319 |
|
307 |
timer1_ovf--; |
320 |
while (timer1_ovf) |
308 |
{ |
321 |
{ |
- |
|
322 |
timer1_ovf--; |
309 |
if (timer_status) timer_status--; |
323 |
if (timer_status) timer_status--; |
310 |
if (timer_refresh) timer_refresh--; |
324 |
if (timer_refresh) timer_refresh--; |
311 |
if (timer_off) timer_off--; |
325 |
if (timer_off) timer_off--; |
312 |
if (timer_temp) timer_temp--; |
326 |
if (timer_temp) timer_temp--; |
313 |
if (timer_key) timer_key--; |
327 |
if (timer_key) timer_key--; |
314 |
else |
328 |
else |
315 |
{ |
329 |
{ |
- |
|
330 |
key_temp = 0; |
316 |
if (!TL1_INPUT) key_temp = _BV(KEY1); else key_temp = 0; |
331 |
if (!TL1_INPUT) key_temp = _BV(KEY1); |
317 |
if (!TL2_INPUT) key_temp |= _BV(KEY2); else key_temp &= ~(_BV(KEY2)); |
332 |
if (!TL2_INPUT) key_temp |= _BV(KEY2); |
318 |
if (!TL3_INPUT) key_temp |= _BV(KEY3); else key_temp &= ~(_BV(KEY3)); |
333 |
if (!TL3_INPUT) key_temp |= _BV(KEY3); |
319 |
if (key_temp != key_press) |
334 |
if (key_temp != key_press) |
320 |
{ |
335 |
{ |
321 |
timer_key = KEY_TIME_DEAD; |
336 |
timer_key = KEY_TIME_DEAD; |
322 |
key_press = key_temp; |
337 |
key_press = key_temp; |
323 |
if (!key_flag) key_flag = key_press; |
338 |
if (!key_flag) key_flag = key_press; |
Line 512... |
Line 527... |
512 |
gotoxy(1,1); |
527 |
gotoxy(1,1); |
513 |
printf("%0.1fV %2d",1024.0*25/ADC/10,read_temp()>>8); |
528 |
printf("%0.1fV %2d",1024.0*25/ADC/10,read_temp()>>8); |
514 |
offset_text = video_buf + LCD_WIDTH - WIDTH_CHAR_LIGHT - 2*CHAR_WIDTH - WIDTH_CHAR_SIGNALL_3D - WIDTH_CHAR_SIGNALL - 2; |
529 |
offset_text = video_buf + LCD_WIDTH - WIDTH_CHAR_LIGHT - 2*CHAR_WIDTH - WIDTH_CHAR_SIGNALL_3D - WIDTH_CHAR_SIGNALL - 2; |
515 |
if (gps.fix_position) |
530 |
if (gps.fix_position) |
516 |
{ |
531 |
{ |
- |
|
532 |
|
- |
|
533 |
ptr= CHAR_SIGNALL_3D;b=WIDTH_CHAR_SIGNALL_3D;//offset_text++; |
- |
|
534 |
if (gps.mode2 == '3') |
- |
|
535 |
for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); |
- |
|
536 |
|
- |
|
537 |
offset_text = video_buf + LCD_WIDTH - WIDTH_CHAR_LIGHT - 2*CHAR_WIDTH - WIDTH_CHAR_SIGNALL_3D - 2; |
517 |
switch (gps.fix_position) |
538 |
switch (gps.fix_position) |
518 |
{ |
539 |
{ |
519 |
case 1: ptr= CHAR_SIGNALL;b=WIDTH_CHAR_SIGNALL;break; |
540 |
case 1: ptr= CHAR_SIGNALL;b=WIDTH_CHAR_SIGNALL;break; |
520 |
case 2: ptr= CHAR_SIGNALL_D;b=WIDTH_CHAR_SIGNALL_D;break; |
541 |
case 2: ptr= CHAR_SIGNALL_D;b=WIDTH_CHAR_SIGNALL_D;break; |
521 |
case 0: |
542 |
case 0: |
522 |
default:ptr= CHAR_SIGNALL;b=0; |
543 |
default:ptr= CHAR_SIGNALL;b=0; |
523 |
} |
544 |
} |
524 |
for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); |
545 |
for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); |
525 |
|
546 |
|
526 |
ptr= CHAR_SIGNALL_3D;b=WIDTH_CHAR_SIGNALL_3D;offset_text++; |
- |
|
527 |
if (gps.mode2 == '3') |
- |
|
528 |
for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); |
- |
|
529 |
offset_text++; |
547 |
|
530 |
} |
548 |
} |
531 |
offset_text = video_buf + LCD_WIDTH - WIDTH_CHAR_LIGHT-2*CHAR_WIDTH; |
549 |
offset_text = video_buf + LCD_WIDTH - WIDTH_CHAR_LIGHT-2*CHAR_WIDTH; |
532 |
printf("%d",gps.satelites_used); |
550 |
printf("%d",gps.satelites_used); |
533 |
if (LED_INPUT) |
551 |
if (LED_INPUT) |
534 |
{ |
552 |
{ |
Line 548... |
Line 566... |
548 |
if (!timer_refresh) |
566 |
if (!timer_refresh) |
549 |
{ |
567 |
{ |
550 |
timer_refresh = CLOCK1S; |
568 |
timer_refresh = CLOCK1S; |
551 |
buffer_clr(); |
569 |
buffer_clr(); |
552 |
status(); |
570 |
status(); |
553 |
gotoxy(1,2); |
571 |
//gotoxy(1,2); |
554 |
printf("time & date"); |
572 |
// printf("time & date"); |
555 |
gotoxy(1,3); |
573 |
gotoxy(1,3); |
556 |
fprintf(&mystdout2," %2d:%02d:%02d",gps.hour+2,gps.minute,gps.second); |
574 |
fprintf(&mystdout2," %2d:%02d:%02d",gps.hour+2,gps.minute,gps.second); |
557 |
gotoxy(1,5); |
575 |
gotoxy(1,5); |
558 |
fprintf(&mystdout2," %2d.%02d.20%02d",gps.day,gps.month,gps.year); |
576 |
fprintf(&mystdout2," %2d.%02d.20%02d",gps.day,gps.month,gps.year); |
559 |
lcd_refresh(); |
577 |
lcd_refresh(); |
560 |
} |
578 |
} |
561 |
} |
579 |
} |
562 |
|
580 |
|
563 |
void displ_location(void) |
581 |
void displ_location(void) |
564 |
{ |
582 |
{ |
- |
|
583 |
uint8_t a,b; |
- |
|
584 |
uint8_t *ptr; |
- |
|
585 |
|
565 |
if (!timer_refresh) |
586 |
if (!timer_refresh) |
566 |
{ |
587 |
{ |
567 |
timer_refresh = CLOCK1S; |
588 |
timer_refresh = CLOCK1S; |
568 |
buffer_clr(); |
589 |
buffer_clr(); |
569 |
status(); |
590 |
status(); |
- |
|
591 |
|
570 |
gotoxy(1,2); |
592 |
gotoxy(8,2); |
- |
|
593 |
offset_text -=2; |
- |
|
594 |
ptr= CHAR_SIGNALL_3D;b=WIDTH_CHAR_SIGNALL_3D;//offset_text++; |
- |
|
595 |
for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); |
- |
|
596 |
|
- |
|
597 |
//gotoxy(9,2); |
571 |
printf("location"); |
598 |
printf("%4.0fm",gps.altitude); |
- |
|
599 |
|
572 |
gotoxy(1,3); |
600 |
gotoxy(1,3); |
573 |
//gps.latitude = 14.5; |
601 |
//gps.latitude = 14.5; |
574 |
fprintf(&mystdout2,"%c %3d%.4f'",gps.ns_indicator,(uint8_t)gps.latitude,(gps.latitude - 1.0*(uint8_t)gps.latitude)*60); |
602 |
fprintf(&mystdout2,"%c %3d%.4f'",gps.ns_indicator,(uint8_t)gps.latitude,(gps.latitude - 1.0*(uint8_t)gps.latitude)*60); |
575 |
gotoxy(1,5); |
603 |
gotoxy(1,5); |
576 |
//gps.longitude = 48.25; |
604 |
//gps.longitude = 48.25; |
Line 696... |
Line 724... |
696 |
gotoxy(1,3); |
724 |
gotoxy(1,3); |
697 |
printf("%c %3d%.4f'",gps.we_indicator,(uint8_t)gps.longitude,(gps.longitude - 1.0*(uint8_t)gps.longitude)*60); |
725 |
printf("%c %3d%.4f'",gps.we_indicator,(uint8_t)gps.longitude,(gps.longitude - 1.0*(uint8_t)gps.longitude)*60); |
698 |
gotoxy(1,4); |
726 |
gotoxy(1,4); |
699 |
printf("alt%4.0fm V%2.1f",gps.altitude,gps.VDOP); |
727 |
printf("alt%4.0fm V%2.1f",gps.altitude,gps.VDOP); |
700 |
gotoxy(1,5); |
728 |
gotoxy(1,5); |
701 |
printf("geo%4.0fm H%2.1f",gps.geoid,gps.HDOP); |
729 |
printf("geo%4.1fm H%2.1f",gps.geoid,gps.HDOP); |
702 |
gotoxy(1,6); |
730 |
gotoxy(1,6); |
703 |
printf("%3.0fkm/h %3.0f",gps.speed,gps.course); |
731 |
printf("%3.0fkm/h %3.0f",gps.speed,gps.course); |
704 |
lcd_refresh(); |
732 |
lcd_refresh(); |
705 |
} |
733 |
} |
706 |
} |
734 |
} |
707 |
|
735 |
|
708 |
void displ_nav(void) |
736 |
void displ_nav(void) |
709 |
{ |
737 |
{ |
710 |
uint8_t a; |
738 |
|
711 |
double lon,lat,temp; |
739 |
double lon,lat,temp; |
712 |
double course; |
740 |
double course; |
713 |
uint8_t x,y,xl,yl,xp,yp; |
741 |
uint8_t x,y,xl,yl,xp,yp; |
- |
|
742 |
uint8_t a,b; |
- |
|
743 |
uint8_t *ptr; |
714 |
|
744 |
|
715 |
if (!timer_refresh) |
745 |
if (!timer_refresh) |
716 |
{ |
746 |
{ |
717 |
timer_refresh = CLOCK1S; |
747 |
timer_refresh = CLOCK1S; |
718 |
buffer_clr(); |
748 |
buffer_clr(); |
Line 723... |
Line 753... |
723 |
lon=(gc_lon-gps.longitude*60)*1214; |
753 |
lon=(gc_lon-gps.longitude*60)*1214; |
724 |
lat=(gc_lat-gps.latitude*60)*1854; |
754 |
lat=(gc_lat-gps.latitude*60)*1854; |
725 |
temp = sqrt((lon*lon) + (lat*lat)); |
755 |
temp = sqrt((lon*lon) + (lat*lat)); |
726 |
|
756 |
|
727 |
gotoxy(9,3); |
757 |
gotoxy(9,3); |
- |
|
758 |
offset_text -=2; |
- |
|
759 |
ptr= CHAR_SIGNALL_3D;b=WIDTH_CHAR_SIGNALL_3D; |
- |
|
760 |
for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); |
- |
|
761 |
//offset_text++; |
- |
|
762 |
|
- |
|
763 |
//gotoxy(10,3); |
- |
|
764 |
printf("%4.0fm",gps.altitude); |
- |
|
765 |
|
- |
|
766 |
gotoxy(7,2); |
- |
|
767 |
printf("go home"); |
- |
|
768 |
|
- |
|
769 |
gotoxy(9,4); |
728 |
if (temp < 10000) |
770 |
if (temp < 10000) |
729 |
{ |
771 |
{ |
730 |
if (temp<1000) fprintf(&mystdout2,"%.1f ",temp); |
772 |
if (temp<1000) fprintf(&mystdout2,"%.1f ",temp); |
731 |
else |
773 |
else |
732 |
{ |
774 |
{ |
733 |
fprintf(&mystdout2,"%.3f ",temp/1000); |
775 |
fprintf(&mystdout2,"%.3f ",temp/1000); |
734 |
gotoxy(12,5); |
776 |
gotoxy(12,6); |
735 |
printf("k"); |
777 |
printf("k"); |
736 |
} |
778 |
} |
737 |
gotoxy(13,5); |
779 |
gotoxy(13,6); |
738 |
printf("m"); |
780 |
printf("m"); |
739 |
} |
781 |
} |
740 |
else |
782 |
else |
741 |
{ |
783 |
{ |
742 |
temp=temp/1000; |
784 |
temp=temp/1000; |
Line 750... |
Line 792... |
750 |
{ |
792 |
{ |
751 |
fprintf(&mystdout2,"%.1f ",temp); |
793 |
fprintf(&mystdout2,"%.1f ",temp); |
752 |
} |
794 |
} |
753 |
} |
795 |
} |
754 |
else fprintf(&mystdout2,"%5.0f ",temp); |
796 |
else fprintf(&mystdout2,"%5.0f ",temp); |
755 |
gotoxy(12,5); |
797 |
gotoxy(12,6); |
756 |
printf("km"); |
798 |
printf("km"); |
757 |
} |
799 |
} |
758 |
|
800 |
|
759 |
if (lat==0) lat=0.001; |
801 |
if (lat==0) lat=0.001; |
760 |
lon=M_PI/2.0-(atan2(lat,lon)); |
802 |
lon=M_PI/2.0-(atan2(lat,lon)); |
Line 808... |
Line 850... |
808 |
} |
850 |
} |
809 |
} |
851 |
} |
810 |
|
852 |
|
811 |
void displ_north(void) |
853 |
void displ_north(void) |
812 |
{ |
854 |
{ |
813 |
//uint8_t a; |
855 |
uint8_t a,b; |
- |
|
856 |
uint8_t *ptr; |
814 |
uint8_t x,y; |
857 |
uint8_t x,y; |
815 |
uint8_t xp,yp; |
858 |
uint8_t xp,yp; |
816 |
uint8_t xl,yl; |
859 |
uint8_t xl,yl; |
817 |
//uint8_t xs,ys; |
860 |
//uint8_t xs,ys; |
818 |
double course; |
861 |
double course; |
Line 820... |
Line 863... |
820 |
if (!timer_refresh) |
863 |
if (!timer_refresh) |
821 |
{ |
864 |
{ |
822 |
timer_refresh = CLOCK1S; |
865 |
timer_refresh = CLOCK1S; |
823 |
buffer_clr(); |
866 |
buffer_clr(); |
824 |
status(); |
867 |
status(); |
- |
|
868 |
|
825 |
gotoxy(9,3); |
869 |
gotoxy(9,3); |
- |
|
870 |
offset_text -=2; |
- |
|
871 |
ptr= CHAR_SIGNALL_3D;b=WIDTH_CHAR_SIGNALL_3D;//offset_text++; |
- |
|
872 |
for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); |
- |
|
873 |
|
- |
|
874 |
//gotoxy(10,3); |
- |
|
875 |
printf("%4.0fm",gps.altitude); |
- |
|
876 |
|
- |
|
877 |
gotoxy(9,2); |
- |
|
878 |
printf("north"); |
- |
|
879 |
|
- |
|
880 |
gotoxy(9,4); |
826 |
fprintf(&mystdout2,"%3.1f",gps.speed); |
881 |
fprintf(&mystdout2,"%3.1f",gps.speed); |
827 |
gotoxy(10,5); |
882 |
gotoxy(10,6); |
828 |
printf("km/h"); |
883 |
printf("km/h"); |
829 |
|
884 |
|
830 |
#define WIDTH_REC_NORTH 43 |
885 |
#define WIDTH_REC_NORTH 43 |
831 |
#define LCD_HEIGHT_NORTH 35 |
886 |
#define LCD_HEIGHT_NORTH 35 |
832 |
|
887 |
|
Line 956... |
Line 1011... |
956 |
|
1011 |
|
957 |
} |
1012 |
} |
958 |
|
1013 |
|
959 |
void all_off(void) |
1014 |
void all_off(void) |
960 |
{ |
1015 |
{ |
961 |
if (!timer_refresh) |
- |
|
962 |
{ |
- |
|
963 |
buffer_clr(); |
1016 |
buffer_clr(); |
964 |
gotoxy(6,3); |
1017 |
gotoxy(6,3); |
965 |
fprintf(&mystdout2,"OFF"); |
1018 |
fprintf(&mystdout2,"OFF"); |
966 |
lcd_refresh(); |
1019 |
lcd_refresh(); |
967 |
timer_refresh = CLOCK1S; |
- |
|
968 |
return; |
- |
|
969 |
} |
- |
|
970 |
if (timer_refresh < CLOCK50MS) |
- |
|
971 |
{ |
- |
|
972 |
timer_refresh = 0; |
- |
|
973 |
LED_OFF; |
- |
|
974 |
GPS_OFF; |
1020 |
GPS_OFF; |
975 |
REF_OFF; |
1021 |
REF_OFF; |
- |
|
1022 |
delay_ms(1000); |
- |
|
1023 |
LED_OFF; |
976 |
N5110_send_command(POWER_DOWN); |
1024 |
N5110_send_command(POWER_DOWN); |
977 |
|
1025 |
|
978 |
while (TL2_INPUT) |
1026 |
while (TL2_INPUT) |
- |
|
1027 |
{ |
979 |
sleep_cpu(); |
1028 |
sleep_cpu(); |
980 |
|
1029 |
|
981 |
LCD_N5110_INIT(); |
- |
|
982 |
id_mod = ID_START; |
- |
|
983 |
} |
1030 |
} |
- |
|
1031 |
null_variables(); |
- |
|
1032 |
LCD_N5110_INIT(); |
- |
|
1033 |
displ_start(); |
984 |
} |
1034 |
} |
985 |
|
1035 |
|
986 |
//************************************************************************ |
1036 |
//************************************************************************ |
987 |
// spol key |
1037 |
// spol key |
988 |
|
1038 |
|
Line 1037... |
Line 1087... |
1037 |
} |
1087 |
} |
1038 |
} |
1088 |
} |
1039 |
return mod; |
1089 |
return mod; |
1040 |
} |
1090 |
} |
1041 |
|
1091 |
|
- |
|
1092 |
void null_variables(void) |
- |
|
1093 |
{ |
- |
|
1094 |
key_press = 0; |
- |
|
1095 |
key_flag = 0; |
- |
|
1096 |
|
- |
|
1097 |
timer_key = 0; |
- |
|
1098 |
timer_temp = 0; |
- |
|
1099 |
timer_off = OFF_TIME; |
- |
|
1100 |
timer_refresh = 0; |
- |
|
1101 |
timer_status = 0; |
- |
|
1102 |
timer1_ovf =0; |
- |
|
1103 |
|
- |
|
1104 |
//max.temperature=0x8000; |
- |
|
1105 |
//min.temperature=0x7FFF; |
- |
|
1106 |
|
- |
|
1107 |
//sRTC=0; |
- |
|
1108 |
//mRTC=15; |
- |
|
1109 |
//hRTC=17; |
- |
|
1110 |
|
- |
|
1111 |
//dRTC=25; |
- |
|
1112 |
//mdRTC=7; |
- |
|
1113 |
//yRTC=8; |
- |
|
1114 |
|
- |
|
1115 |
id_mod = ID_START; |
- |
|
1116 |
} |
- |
|
1117 |
|
1042 |
//************************************************************************ |
1118 |
//************************************************************************ |
1043 |
// main |
1119 |
// main |
1044 |
|
1120 |
|
1045 |
int main(void) |
1121 |
int main(void) |
1046 |
{ |
1122 |
{ |
1047 |
uint8_t temp; |
- |
|
1048 |
|
1123 |
|
1049 |
pgps = &gps; |
1124 |
pgps = &gps; |
1050 |
max.temperature=0x8000; |
1125 |
|
1051 |
min.temperature=0x7FFF; |
1126 |
null_variables(); |
1052 |
id_mod = ID_NORTH; |
- |
|
1053 |
|
1127 |
|
1054 |
general_cpu_init(); |
1128 |
general_cpu_init(); |
1055 |
//GPS_ON; |
1129 |
//GPS_ON; |
1056 |
LCD_N5110_INIT(); |
1130 |
LCD_N5110_INIT(); |
1057 |
|
1131 |
|
1058 |
//set_static_navigation(0); |
1132 |
//set_static_navigation(0); |
1059 |
|
1133 |
|
1060 |
sRTC=0; |
- |
|
1061 |
mRTC=15; |
- |
|
1062 |
hRTC=17; |
- |
|
1063 |
|
- |
|
1064 |
dRTC=25; |
- |
|
1065 |
mdRTC=7; |
- |
|
1066 |
yRTC=8; |
- |
|
1067 |
|
- |
|
1068 |
stdout = &mystdout; |
1134 |
stdout = &mystdout; |
1069 |
sei(); |
1135 |
sei(); |
1070 |
|
1136 |
|
1071 |
for (;;) |
1137 |
for (;;) |
1072 |
{ |
1138 |
{ |
1073 |
switch(id_mod) |
1139 |
switch(id_mod) |
1074 |
{ |
1140 |
{ |
1075 |
case ID_TIME: displ_time(); break; |
1141 |
case ID_TIME: displ_time(); break; |
1076 |
case ID_LOCATION: id_mod++;break;displ_location();break; |
1142 |
case ID_LOCATION: displ_location();break; |
1077 |
//case ID_SPEED: displ_speed(); break; |
1143 |
//case ID_SPEED: displ_speed(); break; |
1078 |
case ID_SATELITES: displ_satelites();break; |
1144 |
case ID_SATELITES: displ_satelites();break; |
1079 |
case ID_COURSE: id_mod++;break;displ_course(); break; |
1145 |
case ID_COURSE: id_mod++;break;displ_course(); break; |
1080 |
case ID_ALL_POSITION:displ_all_position(); break; |
1146 |
case ID_ALL_POSITION: displ_all_position(); break; |
1081 |
case ID_ALL_SERVICE:displ_all_service();break; |
1147 |
case ID_ALL_SERVICE: id_mod++;break;displ_all_service();break; |
1082 |
case ID_SERVICE: id_mod++; break;displ_service(scan_buf);break; |
1148 |
case ID_SERVICE: id_mod++;break;displ_service(scan_buf);break; |
1083 |
case ID_TEMP: displ_temp(); break; |
1149 |
case ID_TEMP: displ_temp(); break; |
1084 |
case ID_OFF: all_off(); break; |
1150 |
case ID_OFF: all_off(); break; |
1085 |
case ID_START: displ_start(); break; |
1151 |
case ID_START: displ_start(); break; |
1086 |
case ID_NAV: displ_nav();break; |
1152 |
case ID_NAV: displ_nav();break; |
1087 |
case ID_NORTH: displ_north();break; |
1153 |
case ID_NORTH: displ_north();break; |
1088 |
default : id_mod = 0; |
1154 |
default : id_mod = 0; |
1089 |
} |
1155 |
} |
1090 |
|
1156 |
|
1091 |
id_mod = key(id_mod); |
- |
|
1092 |
|
- |
|
1093 |
while(timer1_ovf)timer1_tik(); |
- |
|
1094 |
|
1157 |
|
1095 |
switch (load_nmea(rx_shift,rx_buf,scan_buf)) |
1158 |
switch (load_nmea(rx_shift,rx_buf,scan_buf)) |
1096 |
{ |
1159 |
{ |
1097 |
case RETURN_GGA: nmea_gga(scan_buf,pgps);break; |
1160 |
case RETURN_GGA: nmea_gga(scan_buf,pgps);break; |
1098 |
case RETURN_GSA: nmea_gsa(scan_buf,pgps);break; |
1161 |
case RETURN_GSA: nmea_gsa(scan_buf,pgps);break; |
1099 |
case RETURN_GSV: nmea_gsv(scan_buf,pgps);break; |
1162 |
case RETURN_GSV: nmea_gsv(scan_buf,pgps);break; |
1100 |
case RETURN_RMC: nmea_rmc(scan_buf,pgps);break; |
1163 |
case RETURN_RMC: nmea_rmc(scan_buf,pgps);break; |
1101 |
case RETURN_VTG: nmea_vtg(scan_buf,pgps);break; |
1164 |
case RETURN_VTG: nmea_vtg(scan_buf,pgps);break; |
1102 |
} |
1165 |
} |
- |
|
1166 |
|
- |
|
1167 |
timer1_tik(); |
- |
|
1168 |
|
- |
|
1169 |
id_mod = key(id_mod); |
- |
|
1170 |
|
1103 |
} |
1171 |
} |
1104 |
return 0; |
1172 |
return 0; |
1105 |
} |
1173 |
} |
1106 |
|
1174 |
|