Rev 1213 Rev 1217
1 /* mija 2008 1 /* mija 2008
2 demo for LCD NOKIA5110 and MCP9800 and GPS modul 2 demo for LCD NOKIA5110 and MCP9800 and GPS modul
3   3  
4 CPU ATMEGA644P 4 CPU ATMEGA644P
5 fcpu = 1MHz 5 fcpu = 1MHz
6   6  
7 !! define PIN,PORT,DDR for IOpin !! 7 !! define PIN,PORT,DDR for IOpin !!
8 */ 8 */
9   9  
10   10  
11 //************************************************************************ 11 //************************************************************************
12 // defines 12 // defines
13   13  
14 #define KEY_TIME_DEAD 5 //cca 50ms 8*5 14 #define KEY_TIME_DEAD 5 //cca 50ms 8*5
15 //#define KEY_TIME_START_REPEAT 100 //cca 1s 15 //#define KEY_TIME_START_REPEAT 100 //cca 1s
16 //#define KEY_TIME_REPEAT 20 //cca 240ms 16 //#define KEY_TIME_REPEAT 20 //cca 240ms
17 #define KEY_TIME_FIRST 50 17 #define KEY_TIME_FIRST 50
18   18  
19 #define TEMP_TIME_REPEAT 100 19 #define TEMP_TIME_REPEAT 100
20   20  
21 #define OFF_TIME 200 21 #define OFF_TIME 200
22   22  
23 #define REFRESH_TIME 100 23 #define REFRESH_TIME 100
24   24  
25 #define STATUS_REFRESH_TIME 100 25 #define STATUS_REFRESH_TIME 100
26   26  
27 #define CLOCK1S 100 27 #define CLOCK1S 100
28 #define CLOCK2S 200 28 #define CLOCK2S 200
29 #define CLOCK5S 255; 29 #define CLOCK5S 255;
30 #define CLOCK50MS 5 30 #define CLOCK50MS 5
31   31  
32 #define DEBUG 32 #define DEBUG
33   33  
34 //************************************************************************ 34 //************************************************************************
35 //including 35 //including
36   36  
37 #include <avr/io.h> 37 #include <avr/io.h>
38 #include <stdlib.h> 38 #include <stdlib.h>
39 #include <avr/pgmspace.h> 39 #include <avr/pgmspace.h>
40 #include <avr/interrupt.h> 40 #include <avr/interrupt.h>
41 #include <avr/sleep.h> 41 #include <avr/sleep.h>
42 #include <util/delay.h> 42 #include <util/delay.h>
43 #include <stdio.h> 43 #include <stdio.h>
44 #include <math.h> 44 #include <math.h>
45 //#include "ascii_table.h" 45 //#include "ascii_table.h"
46 #include "lcd.h" //define PINs LCD 46 #include "lcd.h" //define PINs LCD
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};
57   58  
58 #define WIDTH_CHAR_SIGNALL_2D 7 59 #define WIDTH_CHAR_SIGNALL_2D 7
59 prog_uint8_t CHAR_SIGNALL_2D[WIDTH_CHAR_SIGNALL_2D]={1,2,4,127,4,2,1}; 60 prog_uint8_t CHAR_SIGNALL_2D[WIDTH_CHAR_SIGNALL_2D]={1,2,4,127,4,2,1};
60   61  
61 #define WIDTH_CHAR_SIGNALL_3D 7 62 #define WIDTH_CHAR_SIGNALL_3D 7
62 prog_uint8_t CHAR_SIGNALL_3D[WIDTH_CHAR_SIGNALL_3D]={124,68,71,69,125,17,31}; 63 prog_uint8_t CHAR_SIGNALL_3D[WIDTH_CHAR_SIGNALL_3D]={124,68,71,69,125,17,31};
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];
76 POINT_T now,max,min; 79 POINT_T now,max,min;
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)
92 { 99 {
93 //*** IO_PIN *** 100 //*** IO_PIN ***
94 TL1_INIT; 101 TL1_INIT;
95 TL1_PULLUP; 102 TL1_PULLUP;
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;
108 REF_OFF; 115 REF_OFF;
109   116  
110 nSCLK_INIT; 117 nSCLK_INIT;
111 nSDIN_INIT; 118 nSDIN_INIT;
112 nDC_INIT; 119 nDC_INIT;
113 nCS_INIT; 120 nCS_INIT;
114 nRESET_INIT; 121 nRESET_INIT;
115   122  
116 SCL_INIT; 123 SCL_INIT;
117 SDA_FLOAT; 124 SDA_FLOAT;
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
125 //PCICR = _BV(PCIE1); //pin change TL1,TL2,TL3 -  
126 //PCMSK1 = _BV(PCINT10) | _BV(PCINT11) |_BV(PCINT12); //pin change TL1,TL2,TL3 -  
-   132
127   133  
-   134 //*** PIN CHANGE INTERRUPTS PCINT29
-   135 PCICR = _BV(PCIE1);
-   136 PCMSK1 = _BV(PCINT10) | _BV(PCINT11) |_BV(PCINT12); //pin change TL1,TL2,TL3
-   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);
138 TIMSK2 = _BV(TOIE2); 151 TIMSK2 = _BV(TOIE2);
139   152  
140 //*** SLEEP *** 153 //*** SLEEP ***
141 SMCR = _BV(SM1) | _BV(SM0) | _BV(SE); 154 SMCR = _BV(SM1) | _BV(SM0) | _BV(SE);
142   155  
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 /
165   182  
166 volatile uint8_t RTC_flag; 183 volatile uint8_t RTC_flag;
167 volatile uint8_t sRTC,mRTC,hRTC,dRTC,mdRTC,yRTC; 184 volatile uint8_t sRTC,mRTC,hRTC,dRTC,mdRTC,yRTC;
168   185  
169 uint8_t modulo(uint8_t h,uint8_t m) //pomocna fce pro modulo x 186 uint8_t modulo(uint8_t h,uint8_t m) //pomocna fce pro modulo x
170 { 187 {
171 if (h<m) return (h); 188 if (h<m) return (h);
172 return(h-m); 189 return(h-m);
173 } 190 }
174   191  
175 void set_date(void) //citac datumu 192 void set_date(void) //citac datumu
176 { 193 {
177 dRTC++; 194 dRTC++;
178 switch (mdRTC) 195 switch (mdRTC)
179 { 196 {
180 case 1: 197 case 1:
181 case 3: 198 case 3:
182 case 5: 199 case 5:
183 case 7: 200 case 7:
184 case 8: 201 case 8:
185 case 10: 202 case 10:
186 case 12: if(dRTC>=32) {dRTC=1;mdRTC++;if(mdRTC==13) {mdRTC =1;yRTC=modulo(yRTC++,100);}} break; 203 case 12: if(dRTC>=32) {dRTC=1;mdRTC++;if(mdRTC==13) {mdRTC =1;yRTC=modulo(yRTC++,100);}} break;
187 case 4: 204 case 4:
188 case 6: 205 case 6:
189 case 9: 206 case 9:
190 case 11: if(dRTC>=31) {dRTC=1;mdRTC++;} break; 207 case 11: if(dRTC>=31) {dRTC=1;mdRTC++;} break;
191 case 2: if (dRTC >= 30) {dRTC=1;mdRTC++;break;} 208 case 2: if (dRTC >= 30) {dRTC=1;mdRTC++;break;}
192 if (dRTC ==29) {if (!(yRTC & 0x03)) break;dRTC=1;mdRTC++;} 209 if (dRTC ==29) {if (!(yRTC & 0x03)) break;dRTC=1;mdRTC++;}
193 } 210 }
194 } 211 }
195   212  
196   213  
197 volatile uint8_t timer1_ovf; 214 volatile uint8_t timer1_ovf;
198   215  
199 ISR(TIMER1_OVF_vect) 216 ISR(TIMER1_OVF_vect)
200 { 217 {
201 timer1_ovf ++; 218 timer1_ovf ++;
202 } 219 }
203   220  
204   221  
205 ISR(TIMER2_OVF_vect) 222 ISR(TIMER2_OVF_vect)
206 { 223 {
207 sRTC += 8; 224 sRTC += 8;
208 if (sRTC >= 60) 225 if (sRTC >= 60)
209 { 226 {
210 sRTC=modulo(sRTC,60); //1min 227 sRTC=modulo(sRTC,60); //1min
211 if (++mRTC>=60) 228 if (++mRTC>=60)
212 { 229 {
213 mRTC=0; //1hod 230 mRTC=0; //1hod
214 if (++hRTC>=24) 231 if (++hRTC>=24)
215 { 232 {
216 hRTC=0; 233 hRTC=0;
217 set_date(); //1den 234 set_date(); //1den
218 } 235 }
219 } 236 }
220 } 237 }
221 } 238 }
222   239  
223 char rx_buf[MAX_RX_BUF]; 240 char rx_buf[MAX_RX_BUF];
224 volatile uint8_t rx_shift; 241 volatile uint8_t rx_shift;
225   242  
226 ISR(USART0_RX_vect) 243 ISR(USART0_RX_vect)
227 { 244 {
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  
246 void delay_ms(uint16_t time) 291 void delay_ms(uint16_t time)
247 { 292 {
248 while(time--) _delay_ms(1); 293 while(time--) _delay_ms(1);
249 } 294 }
250 //************************************************************************ 295 //************************************************************************
251 // static navigation 296 // static navigation
252   297  
253 void gps_put(char c) 298 void gps_put(char c)
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;
296 volatile uint8_t key_flag; 309 volatile uint8_t key_flag;
297 volatile uint8_t timer_key; 310 volatile uint8_t timer_key;
298 volatile uint8_t timer_temp; 311 volatile uint8_t timer_temp;
299 volatile uint8_t timer_off; 312 volatile uint8_t timer_off;
300 volatile uint8_t timer_refresh; 313 volatile uint8_t timer_refresh;
301 volatile uint8_t timer_status; 314 volatile uint8_t timer_status;
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;
324 timer_off= OFF_TIME; 339 timer_off= OFF_TIME;
325 } 340 }
326 } 341 }
327 } 342 }
328 } 343 }
329   344  
330 uint8_t key_read(void) 345 uint8_t key_read(void)
331 { 346 {
332 uint8_t key_send; 347 uint8_t key_send;
333   348  
334 key_send = key_flag; 349 key_send = key_flag;
335 key_flag = 0; 350 key_flag = 0;
336 return key_send; 351 return key_send;
337 } 352 }
338   353  
339 //************************************************************************ 354 //************************************************************************
340 // SW I2C /define SDA, SCL; tested for fosc 1Mhz/ 355 // SW I2C /define SDA, SCL; tested for fosc 1Mhz/
341   356  
342 void I2C_start(void) 357 void I2C_start(void)
343 { 358 {
344 SDA_OUT; 359 SDA_OUT;
345 SDA_L; 360 SDA_L;
346 SCL_L; 361 SCL_L;
347 } 362 }
348   363  
349 void I2C_stop(void) 364 void I2C_stop(void)
350 { 365 {
351 SCL_H; 366 SCL_H;
352 SDA_OUT; 367 SDA_OUT;
353 SDA_H; 368 SDA_H;
354 SDA_FLOAT; 369 SDA_FLOAT;
355 } 370 }
356   371  
357 void I2C_write(uint8_t data) 372 void I2C_write(uint8_t data)
358 { 373 {
359 uint8_t a; 374 uint8_t a;
360 375
361 SDA_OUT; 376 SDA_OUT;
362 for(a=0;a<8;a++) 377 for(a=0;a<8;a++)
363 { 378 {
364 SCL_L; 379 SCL_L;
365 if (data & 0x80) SDA_H; 380 if (data & 0x80) SDA_H;
366 else SDA_L; 381 else SDA_L;
367 SCL_H; 382 SCL_H;
368 data <<= 1; 383 data <<= 1;
369 } 384 }
370 SCL_L; 385 SCL_L;
371 SDA_FLOAT; 386 SDA_FLOAT;
372 SCL_H; 387 SCL_H;
373 SCL_L; 388 SCL_L;
374 } 389 }
375   390  
376 uint8_t I2C_read(uint8_t ack) 391 uint8_t I2C_read(uint8_t ack)
377 { 392 {
378 uint8_t a; 393 uint8_t a;
379 uint8_t data; 394 uint8_t data;
380   395  
381 SDA_IN; 396 SDA_IN;
382 data=0; 397 data=0;
383 for(a=0;a<8;a++) 398 for(a=0;a<8;a++)
384 { 399 {
385 SCL_H; 400 SCL_H;
386 if (SDA_INPUT) data |=1; 401 if (SDA_INPUT) data |=1;
387 SCL_L; 402 SCL_L;
388 if (a != 7)data <<= 1; 403 if (a != 7)data <<= 1;
389 } 404 }
390 405
391 if (ack) {SDA_OUT;SDA_L;} 406 if (ack) {SDA_OUT;SDA_L;}
392 else SDA_FLOAT; 407 else SDA_FLOAT;
393 SCL_H; 408 SCL_H;
394 SCL_L; 409 SCL_L;
395 SDA_FLOAT; 410 SDA_FLOAT;
396 return data; 411 return data;
397 } 412 }
398   413  
399 //************************************************************************ 414 //************************************************************************
400 // temperature sensor MCP9800 of MICROCHIP 415 // temperature sensor MCP9800 of MICROCHIP
401   416  
402 void start_MCP9800(void) 417 void start_MCP9800(void)
403 { 418 {
404 I2C_start(); 419 I2C_start();
405 I2C_write(0x90); 420 I2C_write(0x90);
406 I2C_write(0x1); // configuration pointer MCP9800 421 I2C_write(0x1); // configuration pointer MCP9800
407 //I2C_write(0xE1); // 12bit + only 1 convert and then sleep 422 //I2C_write(0xE1); // 12bit + only 1 convert and then sleep
408 I2C_write(0x81); // 9bit + only 1 convert and then sleep 423 I2C_write(0x81); // 9bit + only 1 convert and then sleep
409 I2C_stop(); 424 I2C_stop();
410 I2C_start(); 425 I2C_start();
411 I2C_write(0x90); 426 I2C_write(0x90);
412 I2C_write(0x0); // temperature pointer 427 I2C_write(0x0); // temperature pointer
413 I2C_stop(); 428 I2C_stop();
414 } 429 }
415   430  
416 uint16_t read_temp(void) 431 uint16_t read_temp(void)
417 { 432 {
418 uint16_t temp; 433 uint16_t temp;
419   434  
420 I2C_start(); 435 I2C_start();
421 I2C_write(0x91); 436 I2C_write(0x91);
422 temp = I2C_read(1) << 8; 437 temp = I2C_read(1) << 8;
423 temp |= I2C_read(0); 438 temp |= I2C_read(0);
424 I2C_stop(); 439 I2C_stop();
425 return temp; 440 return temp;
426 } 441 }
427   442  
428 //************************************************************************ 443 //************************************************************************
429 // templota 444 // templota
430   445  
431 void print_temp(int16_t teplota) 446 void print_temp(int16_t teplota)
432 { 447 {
433 printf("%d.%01dC",((teplota>>8) & 0x807F) | (teplota & 0x8000),5*((teplota>>7)& 0x1)); 448 printf("%d.%01dC",((teplota>>8) & 0x807F) | (teplota & 0x8000),5*((teplota>>7)& 0x1));
434 } 449 }
435   450  
436 void print_time(TIME_T time) 451 void print_time(TIME_T time)
437 { 452 {
438 uint8_t temp; 453 uint8_t temp;
439 454
440 temp = time.hour/10; 455 temp = time.hour/10;
441 if (temp == 0) lcd_put(' ',0); 456 if (temp == 0) lcd_put(' ',0);
442 else lcd_put(temp + 0x30,0); 457 else lcd_put(temp + 0x30,0);
443 lcd_put(time.hour%10 + 0x30,0); 458 lcd_put(time.hour%10 + 0x30,0);
444 //put_lcd(':'); 459 //put_lcd(':');
445 *(offset_text++) = 0x36; 460 *(offset_text++) = 0x36;
446 offset_text++; 461 offset_text++;
447 lcd_put(time.min/10 + 0x30,0); 462 lcd_put(time.min/10 + 0x30,0);
448 lcd_put(time.min%10 + 0x30,0); 463 lcd_put(time.min%10 + 0x30,0);
449 //put_lcd(':'); 464 //put_lcd(':');
450 //put_lcd(sRTC/10 + 0x30); 465 //put_lcd(sRTC/10 + 0x30);
451 //put_lcd(sRTC%10 + 0x30); 466 //put_lcd(sRTC%10 + 0x30);
452 } 467 }
453   468  
454 void print_date(DATE_T date) 469 void print_date(DATE_T date)
455 { 470 {
456 uint8_t temp; 471 uint8_t temp;
457 472
458 temp = date.day/10; 473 temp = date.day/10;
459 if (temp == 0) lcd_put(' ',0); 474 if (temp == 0) lcd_put(' ',0);
460 else lcd_put(temp + 0x30,0); 475 else lcd_put(temp + 0x30,0);
461 lcd_put(date.day%10 + 0x30,0); 476 lcd_put(date.day%10 + 0x30,0);
462 //put_lcd('/'); 477 //put_lcd('/');
463 *(offset_text++) = 0x60; 478 *(offset_text++) = 0x60;
464 offset_text++; 479 offset_text++;
465 temp = date.mon/10; 480 temp = date.mon/10;
466 if (temp != 0) lcd_put(temp + 0x30,0); 481 if (temp != 0) lcd_put(temp + 0x30,0);
467 lcd_put(date.mon%10 + 0x30,0); 482 lcd_put(date.mon%10 + 0x30,0);
468 if (temp == 0) 483 if (temp == 0)
469 { 484 {
470 *(offset_text++) = 0x60; 485 *(offset_text++) = 0x60;
471 offset_text++; 486 offset_text++;
472 } 487 }
473 //put_lcd('/'); 488 //put_lcd('/');
474 //put_lcd(yRTC/10 + 0x30); 489 //put_lcd(yRTC/10 + 0x30);
475 //put_lcd(yRTC%10 + 0x30); 490 //put_lcd(yRTC%10 + 0x30);
476 } 491 }
477   492  
478 TIME_T actual_time(void) 493 TIME_T actual_time(void)
479 { 494 {
480 TIME_T time; 495 TIME_T time;
481   496  
482 time.sec=sRTC; 497 time.sec=sRTC;
483 time.min=mRTC; 498 time.min=mRTC;
484 time.hour=hRTC; 499 time.hour=hRTC;
485 return time; 500 return time;
486 } 501 }
487   502  
488 DATE_T actual_date(void) 503 DATE_T actual_date(void)
489 { 504 {
490 DATE_T date; 505 DATE_T date;
491   506  
492 date.day=dRTC; 507 date.day=dRTC;
493 date.mon=mdRTC; 508 date.mon=mdRTC;
494 date.year=yRTC; 509 date.year=yRTC;
495 return date; 510 return date;
496 } 511 }
497   512  
498 //********************************************************************* 513 //*********************************************************************
499 //status 514 //status
500   515  
501 void status(void) 516 void status(void)
502 { 517 {
503 uint8_t a,b; 518 uint8_t a,b;
504 uint8_t *ptr; 519 uint8_t *ptr;
505 520
506 start_MCP9800(); 521 start_MCP9800();
507 REF_ON; 522 REF_ON;
508 ADC_ON; 523 ADC_ON;
509 ADCSRA |= _BV(ADSC); 524 ADCSRA |= _BV(ADSC);
510 while (!(ADCSRA & _BV(ADIF))); 525 while (!(ADCSRA & _BV(ADIF)));
511 526
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 {
535 ptr= CHAR_LIGHT;b=WIDTH_CHAR_LIGHT; 553 ptr= CHAR_LIGHT;b=WIDTH_CHAR_LIGHT;
536 offset_text = video_buf + LCD_WIDTH - WIDTH_CHAR_LIGHT; 554 offset_text = video_buf + LCD_WIDTH - WIDTH_CHAR_LIGHT;
537 for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++); 555 for (a=0;a<b;a++) *(offset_text++) =pgm_read_byte(ptr++);
538 } 556 }
539 557
540 } 558 }
541   559  
542 //************************************************************************ 560 //************************************************************************
543 // mod 561 // mod
544   562  
545 void displ_time(void) 563 void displ_time(void)
546 { 564 {
547 GPS_ON; 565 GPS_ON;
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;
577 fprintf(&mystdout2,"%c %3d%.4f'",gps.we_indicator,(uint8_t)gps.longitude,(gps.longitude - 1.0*(uint8_t)gps.longitude)*60); 605 fprintf(&mystdout2,"%c %3d%.4f'",gps.we_indicator,(uint8_t)gps.longitude,(gps.longitude - 1.0*(uint8_t)gps.longitude)*60);
578 lcd_refresh(); 606 lcd_refresh();
579 } 607 }
580 } 608 }
581   609  
582 void displ_speed(void) 610 void displ_speed(void)
583 { 611 {
584 if (!timer_refresh) 612 if (!timer_refresh)
585 { 613 {
586 timer_refresh = CLOCK1S; 614 timer_refresh = CLOCK1S;
587 buffer_clr(); 615 buffer_clr();
588 status(); 616 status();
589 gotoxy(1,2); 617 gotoxy(1,2);
590 printf("speed"); 618 printf("speed");
591 gotoxy(1,4); 619 gotoxy(1,4);
592 fprintf(&mystdout2," %3.1f km/h",gps.speed); 620 fprintf(&mystdout2," %3.1f km/h",gps.speed);
593 lcd_refresh(); 621 lcd_refresh();
594 } 622 }
595 } 623 }
596   624  
597 void displ_course(void) 625 void displ_course(void)
598 { 626 {
599 if (!timer_refresh) 627 if (!timer_refresh)
600 { 628 {
601 timer_refresh = CLOCK1S; 629 timer_refresh = CLOCK1S;
602 buffer_clr(); 630 buffer_clr();
603 status(); 631 status();
604 //gotoxy(1,2); 632 //gotoxy(1,2);
605 //printf("course"); 633 //printf("course");
606 gotoxy(1,3); 634 gotoxy(1,3);
607 fprintf(&mystdout2," %3.1f km/h",gps.speed); 635 fprintf(&mystdout2," %3.1f km/h",gps.speed);
608 gotoxy(6,5); 636 gotoxy(6,5);
609 fprintf(&mystdout2,"%3.0f",gps.course); 637 fprintf(&mystdout2,"%3.0f",gps.course);
610 lcd_refresh(); 638 lcd_refresh();
611 } 639 }
612 } 640 }
613   641  
614 void displ_satelites(void) 642 void displ_satelites(void)
615 { 643 {
616 #define WIDTH_REC 60 644 #define WIDTH_REC 60
617   645  
618 uint8_t a,x,y,b; 646 uint8_t a,x,y,b;
619 static uint8_t d = 0; 647 static uint8_t d = 0;
620 static uint8_t c = 0; 648 static uint8_t c = 0;
621 double elevace,azimut; 649 double elevace,azimut;
622   650  
623 if (!timer_refresh) 651 if (!timer_refresh)
624 { 652 {
625 timer_refresh = CLOCK1S; 653 timer_refresh = CLOCK1S;
626 if (c--) return; 654 if (c--) return;
627 c=3; 655 c=3;
628 buffer_clr(); 656 buffer_clr();
629 //status(); 657 //status();
630 #ifdef DEBUG 658 #ifdef DEBUG
631 if(gps.gsv_satelites_view > 12) 659 if(gps.gsv_satelites_view > 12)
632 { 660 {
633 printf("error view satelites"); 661 printf("error view satelites");
634 lcd_refresh(); 662 lcd_refresh();
635 c=20; 663 c=20;
636 return; 664 return;
637 } 665 }
638 #endif 666 #endif
639 if (++d >= gps.gsv_satelites_view) d = 0; 667 if (++d >= gps.gsv_satelites_view) d = 0;
640 gotoxy(12,1); 668 gotoxy(12,1);
641 printf("%d",gps.gsv_satelites_view); 669 printf("%d",gps.gsv_satelites_view);
642 gotoxy(12,2); 670 gotoxy(12,2);
643 printf("%d",gps.satelit_detail[d].id); 671 printf("%d",gps.satelit_detail[d].id);
644 gotoxy(12,3); 672 gotoxy(12,3);
645 printf("%d",gps.satelit_detail[d].azimut); 673 printf("%d",gps.satelit_detail[d].azimut);
646 gotoxy(12,4); 674 gotoxy(12,4);
647 printf("%d",gps.satelit_detail[d].elevation); 675 printf("%d",gps.satelit_detail[d].elevation);
648 gotoxy(12,5); 676 gotoxy(12,5);
649 printf("%d",gps.satelit_detail[d].SNR); 677 printf("%d",gps.satelit_detail[d].SNR);
650 gotoxy(12,6); 678 gotoxy(12,6);
651   679  
652 for (a=0;a<gps.gsv_satelites_view;a++) 680 for (a=0;a<gps.gsv_satelites_view;a++)
653 { 681 {
654 azimut = (double)gps.satelit_detail[a].azimut; 682 azimut = (double)gps.satelit_detail[a].azimut;
655 elevace = (double)gps.satelit_detail[a].elevation; 683 elevace = (double)gps.satelit_detail[a].elevation;
656 684
657 x=(uint8_t)((WIDTH_REC-4)/2.0/90.0*(90.0-elevace)*sin(M_PI/180*azimut) + WIDTH_REC/2.0); 685 x=(uint8_t)((WIDTH_REC-4)/2.0/90.0*(90.0-elevace)*sin(M_PI/180*azimut) + WIDTH_REC/2.0);
658 y=(uint8_t)((LCD_HEIGHT-4)/2.0/90.0*(90.0-elevace)*cos(M_PI/180*azimut) + LCD_HEIGHT/2.0); 686 y=(uint8_t)((LCD_HEIGHT-4)/2.0/90.0*(90.0-elevace)*cos(M_PI/180*azimut) + LCD_HEIGHT/2.0);
659 if (gps.satelit_detail[a].SNR) 687 if (gps.satelit_detail[a].SNR)
660 { 688 {
661 lcd_plot(x-1,y);lcd_plot(x+1,y);lcd_plot(x,y-1);lcd_plot(x,y+1); 689 lcd_plot(x-1,y);lcd_plot(x+1,y);lcd_plot(x,y-1);lcd_plot(x,y+1);
662 for (b=0;b<gps.satelites_used;b++) 690 for (b=0;b<gps.satelites_used;b++)
663 if (gps.satelit_detail[a].id == gps.satelite_id[b]) 691 if (gps.satelit_detail[a].id == gps.satelite_id[b])
664 lcd_plot(x,y); 692 lcd_plot(x,y);
665 } 693 }
666 else lcd_plot(x,y); 694 else lcd_plot(x,y);
667 695
668 if (d == a) 696 if (d == a)
669 { 697 {
670 lcd_line(x-2,y-2,x-2,y+2); 698 lcd_line(x-2,y-2,x-2,y+2);
671 lcd_line(x+2,y+2,x+2,y-2); 699 lcd_line(x+2,y+2,x+2,y-2);
672 lcd_line(x+2,y+2,x-2,y+2); 700 lcd_line(x+2,y+2,x-2,y+2);
673 lcd_line(x-2,y-2,x+2,y-2); 701 lcd_line(x-2,y-2,x+2,y-2);
674 } 702 }
675 } 703 }
676   704  
677 lcd_line(0,0,WIDTH_REC,0); 705 lcd_line(0,0,WIDTH_REC,0);
678 lcd_line(0,LCD_HEIGHT-1,WIDTH_REC,LCD_HEIGHT-1); 706 lcd_line(0,LCD_HEIGHT-1,WIDTH_REC,LCD_HEIGHT-1);
679 lcd_line(0,0,0,LCD_HEIGHT-1); 707 lcd_line(0,0,0,LCD_HEIGHT-1);
680 lcd_line(WIDTH_REC,0,WIDTH_REC,LCD_HEIGHT-1); 708 lcd_line(WIDTH_REC,0,WIDTH_REC,LCD_HEIGHT-1);
681   709  
682 lcd_refresh(); 710 lcd_refresh();
683 } 711 }
684 } 712 }
685   713  
686 void displ_all_position() 714 void displ_all_position()
687 { 715 {
688 if (!timer_refresh) 716 if (!timer_refresh)
689 { 717 {
690 timer_refresh = CLOCK1S; 718 timer_refresh = CLOCK1S;
691 buffer_clr(); 719 buffer_clr();
692 status(); 720 status();
693 721
694 gotoxy(1,2); 722 gotoxy(1,2);
695 printf("%c %3d%.4f'",gps.ns_indicator,(uint8_t)gps.latitude,(gps.latitude - 1.0*(uint8_t)gps.latitude)*60); 723 printf("%c %3d%.4f'",gps.ns_indicator,(uint8_t)gps.latitude,(gps.latitude - 1.0*(uint8_t)gps.latitude)*60);
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();
719 status(); 749 status();
720 750
721 const float gc_lat=48*60+57.7647,gc_lon=14*60+28.0836; // DOMA 751 const float gc_lat=48*60+57.7647,gc_lon=14*60+28.0836; // DOMA
722   752  
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;
743 if (temp < 1000) 785 if (temp < 1000)
744 { 786 {
745 if (temp < 100) 787 if (temp < 100)
746 { 788 {
747 fprintf(&mystdout2,"%.2f ",temp); 789 fprintf(&mystdout2,"%.2f ",temp);
748 } 790 }
749 else 791 else
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));
761 if (lon<0) lon+=2*M_PI; 803 if (lon<0) lon+=2*M_PI;
762 if (lon>(2*M_PI)) lon-=2*M_PI; 804 if (lon>(2*M_PI)) lon-=2*M_PI;
763 //printf(lcd_putc,"BE%2.0g*",lon); 805 //printf(lcd_putc,"BE%2.0g*",lon);
764 lat=M_PI/180*gps.course; 806 lat=M_PI/180*gps.course;
765 lon=lon-lat; 807 lon=lon-lat;
766 if (lon<0) lon+=2*M_PI; 808 if (lon<0) lon+=2*M_PI;
767 if (lon>2*M_PI) lon-=2*M_PI; 809 if (lon>2*M_PI) lon-=2*M_PI;
768 //printf(lcd_putc,"HE%2.0g*AZ%2.0g* ",lon,lat); 810 //printf(lcd_putc,"HE%2.0g*AZ%2.0g* ",lon,lat);
769 811
770 #define WIDTH_REC_NAV 43 812 #define WIDTH_REC_NAV 43
771 #define LCD_HEIGHT_NAV 35 813 #define LCD_HEIGHT_NAV 35
772 814
773 course = lon; 815 course = lon;
774 x=(uint8_t)(WIDTH_REC_NAV/2.0*sin(course) +WIDTH_REC_NAV/2); 816 x=(uint8_t)(WIDTH_REC_NAV/2.0*sin(course) +WIDTH_REC_NAV/2);
775 y=(uint8_t)((LCD_HEIGHT_NAV)/2.0*cos(course) +(LCD_HEIGHT_NAV)/2); 817 y=(uint8_t)((LCD_HEIGHT_NAV)/2.0*cos(course) +(LCD_HEIGHT_NAV)/2);
776   818  
777 xl=(uint8_t)(WIDTH_REC_NAV/2.0*sin((course-2.62))+WIDTH_REC_NAV/2 ); 819 xl=(uint8_t)(WIDTH_REC_NAV/2.0*sin((course-2.62))+WIDTH_REC_NAV/2 );
778 yl=(uint8_t)((LCD_HEIGHT_NAV)/2.0*cos((course-2.62))+(LCD_HEIGHT_NAV)/2 ); 820 yl=(uint8_t)((LCD_HEIGHT_NAV)/2.0*cos((course-2.62))+(LCD_HEIGHT_NAV)/2 );
779   821  
780 xp=(uint8_t)(WIDTH_REC_NAV/2.0*sin((course+2.62))+WIDTH_REC_NAV/2 ); 822 xp=(uint8_t)(WIDTH_REC_NAV/2.0*sin((course+2.62))+WIDTH_REC_NAV/2 );
781 yp=(uint8_t)((LCD_HEIGHT_NAV)/2.0*cos((course+2.62)) +(LCD_HEIGHT_NAV)/2); 823 yp=(uint8_t)((LCD_HEIGHT_NAV)/2.0*cos((course+2.62)) +(LCD_HEIGHT_NAV)/2);
782   824  
783 //xs=(uint8_t)((WIDTH_REC_NORTH-26)/2.0*sin(M_PI/180*(course+180.0))+WIDTH_REC_NORTH/2 ); 825 //xs=(uint8_t)((WIDTH_REC_NORTH-26)/2.0*sin(M_PI/180*(course+180.0))+WIDTH_REC_NORTH/2 );
784 //ys=(uint8_t)(((LCD_HEIGHT_NORTH-20))/2.0*cos(M_PI/180*(course+180.0)) +(LCD_HEIGHT_NORTH)/2); 826 //ys=(uint8_t)(((LCD_HEIGHT_NORTH-20))/2.0*cos(M_PI/180*(course+180.0)) +(LCD_HEIGHT_NORTH)/2);
785   827  
786 lcd_line( x,y,xl,yl); 828 lcd_line( x,y,xl,yl);
787 lcd_line( x,y,xp,yp); 829 lcd_line( x,y,xp,yp);
788 //lcd_line( xp,yp,xl,yl); 830 //lcd_line( xp,yp,xl,yl);
789 lcd_line(xl,yl,WIDTH_REC_NAV/2,(LCD_HEIGHT_NAV)/2); 831 lcd_line(xl,yl,WIDTH_REC_NAV/2,(LCD_HEIGHT_NAV)/2);
790 lcd_line(xp,yp,WIDTH_REC_NAV/2,(LCD_HEIGHT_NAV)/2); 832 lcd_line(xp,yp,WIDTH_REC_NAV/2,(LCD_HEIGHT_NAV)/2);
791 833
792 //lcd_line(xl,yl,xs,ys); 834 //lcd_line(xl,yl,xs,ys);
793 //lcd_line(xp,yp,xs,ys); 835 //lcd_line(xp,yp,xs,ys);
794 lcd_refresh(); 836 lcd_refresh();
795 } 837 }
796 } 838 }
797   839  
798 void displ_service(char *buf) 840 void displ_service(char *buf)
799 { 841 {
800 uint8_t a; 842 uint8_t a;
801   843  
802 if (!timer_refresh) 844 if (!timer_refresh)
803 { 845 {
804 timer_refresh = CLOCK1S; 846 timer_refresh = CLOCK1S;
805 buffer_clr(); 847 buffer_clr();
806 for (a = 0; a<80; a++) putchar(*(buf++)); 848 for (a = 0; a<80; a++) putchar(*(buf++));
807 lcd_refresh(); 849 lcd_refresh();
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;
819   862  
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  
833 course = 360-gps.course; 888 course = 360-gps.course;
834 x=(uint8_t)(WIDTH_REC_NORTH/2.0*sin(M_PI/180*course) +WIDTH_REC_NORTH/2); 889 x=(uint8_t)(WIDTH_REC_NORTH/2.0*sin(M_PI/180*course) +WIDTH_REC_NORTH/2);
835 y=(uint8_t)((LCD_HEIGHT_NORTH)/2.0*cos(M_PI/180*course) +(LCD_HEIGHT_NORTH)/2); 890 y=(uint8_t)((LCD_HEIGHT_NORTH)/2.0*cos(M_PI/180*course) +(LCD_HEIGHT_NORTH)/2);
836   891  
837 xl=(uint8_t)(WIDTH_REC_NORTH/2.0*sin(M_PI/180*(course-150.0))+WIDTH_REC_NORTH/2 ); 892 xl=(uint8_t)(WIDTH_REC_NORTH/2.0*sin(M_PI/180*(course-150.0))+WIDTH_REC_NORTH/2 );
838 yl=(uint8_t)((LCD_HEIGHT_NORTH)/2.0*cos(M_PI/180*(course-150.0))+(LCD_HEIGHT_NORTH)/2 ); 893 yl=(uint8_t)((LCD_HEIGHT_NORTH)/2.0*cos(M_PI/180*(course-150.0))+(LCD_HEIGHT_NORTH)/2 );
839   894  
840 xp=(uint8_t)(WIDTH_REC_NORTH/2.0*sin(M_PI/180*(course+150.0))+WIDTH_REC_NORTH/2 ); 895 xp=(uint8_t)(WIDTH_REC_NORTH/2.0*sin(M_PI/180*(course+150.0))+WIDTH_REC_NORTH/2 );
841 yp=(uint8_t)((LCD_HEIGHT_NORTH)/2.0*cos(M_PI/180*(course+150.0)) +(LCD_HEIGHT_NORTH)/2); 896 yp=(uint8_t)((LCD_HEIGHT_NORTH)/2.0*cos(M_PI/180*(course+150.0)) +(LCD_HEIGHT_NORTH)/2);
842   897  
843 //xs=(uint8_t)((WIDTH_REC_NORTH-26)/2.0*sin(M_PI/180*(course+180.0))+WIDTH_REC_NORTH/2 ); 898 //xs=(uint8_t)((WIDTH_REC_NORTH-26)/2.0*sin(M_PI/180*(course+180.0))+WIDTH_REC_NORTH/2 );
844 //ys=(uint8_t)(((LCD_HEIGHT_NORTH-20))/2.0*cos(M_PI/180*(course+180.0)) +(LCD_HEIGHT_NORTH)/2); 899 //ys=(uint8_t)(((LCD_HEIGHT_NORTH-20))/2.0*cos(M_PI/180*(course+180.0)) +(LCD_HEIGHT_NORTH)/2);
845   900  
846 lcd_line( x,y,xl,yl); 901 lcd_line( x,y,xl,yl);
847 lcd_line( x,y,xp,yp); 902 lcd_line( x,y,xp,yp);
848 //lcd_line( xp,yp,xl,yl); 903 //lcd_line( xp,yp,xl,yl);
849 lcd_line(xl,yl,WIDTH_REC_NORTH/2,(LCD_HEIGHT_NORTH)/2); 904 lcd_line(xl,yl,WIDTH_REC_NORTH/2,(LCD_HEIGHT_NORTH)/2);
850 lcd_line(xp,yp,WIDTH_REC_NORTH/2,(LCD_HEIGHT_NORTH)/2); 905 lcd_line(xp,yp,WIDTH_REC_NORTH/2,(LCD_HEIGHT_NORTH)/2);
851 906
852 //lcd_line(xl,yl,xs,ys); 907 //lcd_line(xl,yl,xs,ys);
853 //lcd_line(xp,yp,xs,ys); 908 //lcd_line(xp,yp,xs,ys);
854 lcd_refresh(); 909 lcd_refresh();
855 } 910 }
856 } 911 }
857   912  
858 void displ_all_service(void) 913 void displ_all_service(void)
859 { 914 {
860 uint8_t a; 915 uint8_t a;
861   916  
862 if (!timer_refresh) 917 if (!timer_refresh)
863 { 918 {
864 timer_refresh = CLOCK1S; 919 timer_refresh = CLOCK1S;
865 buffer_clr(); 920 buffer_clr();
866 status(); 921 status();
867   922  
868 gotoxy(1,2); 923 gotoxy(1,2);
869 printf("d=%d %ds",gps.diff_id,gps.age_diff_corr); 924 printf("d=%d %ds",gps.diff_id,gps.age_diff_corr);
870 gotoxy(1,3); 925 gotoxy(1,3);
871 printf("%c st=%cD ",gps.mode1,gps.mode2); 926 printf("%c st=%cD ",gps.mode1,gps.mode2);
872 switch (gps.fix_position) 927 switch (gps.fix_position)
873 { 928 {
874 case 0: printf("nofix");break; 929 case 0: printf("nofix");break;
875 case 1: printf("SPSfix");break; 930 case 1: printf("SPSfix");break;
876 case 2: printf(" Dfix");break; 931 case 2: printf(" Dfix");break;
877 default: printf("nopref"); 932 default: printf("nopref");
878 } 933 }
879 gotoxy(1,4); 934 gotoxy(1,4);
880 printf("GSV %d %d %d",gps.gsv_num_msg,gps.gsv_msg,gps.gsv_satelites_view); 935 printf("GSV %d %d %d",gps.gsv_num_msg,gps.gsv_msg,gps.gsv_satelites_view);
881 gotoxy(1,5); 936 gotoxy(1,5);
882 for(a=0;a<6;a++) 937 for(a=0;a<6;a++)
883 { 938 {
884 printf("%2d",gps.satelite_id[a]); 939 printf("%2d",gps.satelite_id[a]);
885 offset_text+=2; 940 offset_text+=2;
886 } 941 }
887 gotoxy(1,6); 942 gotoxy(1,6);
888 for(a=6;a<12;a++) 943 for(a=6;a<12;a++)
889 { 944 {
890 printf("%2d",gps.satelite_id[a]); 945 printf("%2d",gps.satelite_id[a]);
891 if (a != 11) offset_text+=2; 946 if (a != 11) offset_text+=2;
892 } 947 }
893 lcd_refresh(); 948 lcd_refresh();
894 } 949 }
895 } 950 }
896   951  
897 void displ_temp() 952 void displ_temp()
898 { 953 {
899 //GPS_OFF; 954 //GPS_OFF;
900 //ADC_OFF; 955 //ADC_OFF;
901 //REF_OFF; 956 //REF_OFF;
902   957  
903 if(!timer_temp) 958 if(!timer_temp)
904 { 959 {
905 timer_temp = TEMP_TIME_REPEAT; 960 timer_temp = TEMP_TIME_REPEAT;
906 now.temperature=read_temp(); 961 now.temperature=read_temp();
907 now.time=actual_time(); 962 now.time=actual_time();
908 now.date=actual_date(); 963 now.date=actual_date();
909 964
910 buffer_clr(); 965 buffer_clr();
911 gotoxy(1,1); 966 gotoxy(1,1);
912 stdout = &mystdout2; 967 stdout = &mystdout2;
913 print_temp(now.temperature); 968 print_temp(now.temperature);
914 stdout = &mystdout; 969 stdout = &mystdout;
915 gotoxy(11,1); 970 gotoxy(11,1);
916 offset_text-= 2; 971 offset_text-= 2;
917 print_time(now.time); 972 print_time(now.time);
918 gotoxy(11,2); 973 gotoxy(11,2);
919 offset_text-= 2; 974 offset_text-= 2;
920 print_date(now.date); 975 print_date(now.date);
921 gotoxy(1,4); 976 gotoxy(1,4);
922 if (now.temperature > max.temperature) max=now; 977 if (now.temperature > max.temperature) max=now;
923 print_temp(max.temperature); 978 print_temp(max.temperature);
924 gotoxy(11,4); 979 gotoxy(11,4);
925 offset_text-= 2; 980 offset_text-= 2;
926 print_date(max.date); 981 print_date(max.date);
927 gotoxy(6,3); 982 gotoxy(6,3);
928 printf("max"); 983 printf("max");
929 gotoxy(11,3); 984 gotoxy(11,3);
930 offset_text-= 2; 985 offset_text-= 2;
931 print_time(max.time); 986 print_time(max.time);
932 gotoxy(1,6); 987 gotoxy(1,6);
933 if (now.temperature < min.temperature) min=now; 988 if (now.temperature < min.temperature) min=now;
934 print_temp(min.temperature); 989 print_temp(min.temperature);
935 gotoxy(11,6); 990 gotoxy(11,6);
936 offset_text-= 2; 991 offset_text-= 2;
937 print_date(min.date); 992 print_date(min.date);
938 gotoxy(6,5); 993 gotoxy(6,5);
939 printf("min"); 994 printf("min");
940 gotoxy(11,5); 995 gotoxy(11,5);
941 offset_text-= 2; 996 offset_text-= 2;
942 print_time(min.time); 997 print_time(min.time);
943 lcd_refresh(); 998 lcd_refresh();
944 start_MCP9800(); 999 start_MCP9800();
945 } 1000 }
946 } 1001 }
947   1002  
948 void displ_start(void) 1003 void displ_start(void)
949 { 1004 {
950 buffer_clr(); 1005 buffer_clr();
951 gotoxy(6,3); 1006 gotoxy(6,3);
952 fprintf(&mystdout2,"GPS"); 1007 fprintf(&mystdout2,"GPS");
953 lcd_refresh(); 1008 lcd_refresh();
954 delay_ms(1000); 1009 delay_ms(1000);
955 id_mod = ID_TEMP; 1010 id_mod = ID_TEMP;
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  
-   1030 }
-   1031 null_variables();
981 LCD_N5110_INIT(); 1032 LCD_N5110_INIT();
982 id_mod = ID_START; 1033 displ_start();
983 } -  
984 } 1034 }
985   1035  
986 //************************************************************************ 1036 //************************************************************************
987 // spol key 1037 // spol key
988   1038  
989 uint8_t key(uint8_t mod) 1039 uint8_t key(uint8_t mod)
990 { 1040 {
991 if(key_press) 1041 if(key_press)
992 { 1042 {
993 if (!timer_off) 1043 if (!timer_off)
994 { 1044 {
995 if (key_read() == _BV(KEY2)) 1045 if (key_read() == _BV(KEY2))
996 { 1046 {
997 timer_refresh = 0; 1047 timer_refresh = 0;
998 timer_key = CLOCK2S; 1048 timer_key = CLOCK2S;
999 key_read(); 1049 key_read();
1000 return ID_OFF; 1050 return ID_OFF;
1001 } 1051 }
1002 } 1052 }
1003 } 1053 }
1004 else 1054 else
1005 { 1055 {
1006 if (key_flag == _BV(KEY1)) 1056 if (key_flag == _BV(KEY1))
1007 { 1057 {
1008 timer_key = KEY_TIME_FIRST; 1058 timer_key = KEY_TIME_FIRST;
1009 key_read(); 1059 key_read();
1010 timer_refresh = 0; 1060 timer_refresh = 0;
1011 ++mod; 1061 ++mod;
1012 } 1062 }
1013 if (key_flag == _BV(KEY2)) 1063 if (key_flag == _BV(KEY2))
1014 { 1064 {
1015 if (LED_INPUT) LED_OFF; 1065 if (LED_INPUT) LED_OFF;
1016 else LED_ON; 1066 else LED_ON;
1017 timer_key = KEY_TIME_FIRST; 1067 timer_key = KEY_TIME_FIRST;
1018 key_read(); 1068 key_read();
1019 } 1069 }
1020 if (key_flag == _BV(KEY3)) 1070 if (key_flag == _BV(KEY3))
1021 { 1071 {
1022 max.temperature=0x8000; 1072 max.temperature=0x8000;
1023 min.temperature=0x7FFF; 1073 min.temperature=0x7FFF;
1024 if (GPS_INPUT && (gps.status == 'A')) 1074 if (GPS_INPUT && (gps.status == 'A'))
1025 { 1075 {
1026 sRTC=gps.second; 1076 sRTC=gps.second;
1027 mRTC=gps.minute; 1077 mRTC=gps.minute;
1028 hRTC=gps.hour+2; 1078 hRTC=gps.hour+2;
1029   1079  
1030 dRTC=gps.day; 1080 dRTC=gps.day;
1031 mdRTC=gps.month; 1081 mdRTC=gps.month;
1032 yRTC=gps.year; 1082 yRTC=gps.year;
1033 } 1083 }
1034   1084  
1035 timer_key = KEY_TIME_FIRST; 1085 timer_key = KEY_TIME_FIRST;
1036 key_read(); 1086 key_read();
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; -  
1051 min.temperature=0x7FFF; -  
1052 id_mod = ID_NORTH; -  
1053 1125
-   1126 null_variables();
-   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