/Designs/GPSnavigator/SW/GPS/GPS.c
11,6 → 11,9
//************************************************************************
// defines
 
#define MY_LAT 48*60+57.7647
#define MY_LON 14*60+28.0836
 
#define KEY_TIME_DEAD 5 //cca 50ms 8*5
//#define KEY_TIME_START_REPEAT 100 //cca 1s
//#define KEY_TIME_REPEAT 20 //cca 240ms
19,6 → 22,7
#define TEMP_TIME_REPEAT 100
 
#define OFF_TIME 200
#define TIME_KEY_LONG 200
 
#define REFRESH_TIME 100
 
271,9 → 275,9
cli();
buffer_clr();
gotoxy(2,3);
fprintf(&mystdout2,"programing");
gotoxy(6,5);
fprintf(&mystdout2,"mod");
fprintf(&mystdout2,"update");
gotoxy(2,5);
fprintf(&mystdout2,"firmware");
lcd_refresh();
delay_ms(1000);
BOOT();
312,6 → 316,7
volatile uint8_t timer_off;
volatile uint8_t timer_refresh;
volatile uint8_t timer_status;
volatile uint8_t timer_key_long;
 
void timer1_tik(void)
{
323,6 → 328,7
if (timer_status) timer_status--;
if (timer_refresh) timer_refresh--;
if (timer_off) timer_off--;
if (timer_key_long) timer_key_long--;
if (timer_temp) timer_temp--;
if (timer_key) timer_key--;
else
331,12 → 337,17
if (!TL1_INPUT) key_temp = _BV(KEY1);
if (!TL2_INPUT) key_temp |= _BV(KEY2);
if (!TL3_INPUT) key_temp |= _BV(KEY3);
if (key_temp != key_press)
//if (key_temp != key_press)
{
if (key_temp != key_press)
{
timer_off= OFF_TIME;
timer_key_long=TIME_KEY_LONG;
}
timer_key = KEY_TIME_DEAD;
key_press = key_temp;
if (!key_flag) key_flag = key_press;
timer_off= OFF_TIME;
}
}
}
511,6 → 522,44
}
 
//*********************************************************************
// key
 
uint8_t test_key(void)
{
static uint8_t key_next = 0;
 
if (key_press)
{
if (key_next)
{
key_read();
return 0;
}
 
if(!timer_key_long)
{
key_next = 1;
timer_key = KEY_TIME_FIRST;
switch(key_read())
{
case _BV(KEY1): return KEY1_LONG;
case _BV(KEY2): return KEY2_LONG;
case _BV(KEY3): return KEY3_LONG;
}
}
return 0;
}
key_next=0;
switch(key_read())
{
case _BV(KEY1): return KEY1_SHORT;
case _BV(KEY2): return KEY2_SHORT;
case _BV(KEY3): return KEY3_SHORT;
}
return 0;
}
 
//*********************************************************************
//status
 
void status(void)
563,6 → 612,17
void displ_time(void)
{
GPS_ON;
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
583,6 → 643,16
uint8_t a,b;
uint8_t *ptr;
 
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
609,6 → 679,16
 
void displ_speed(void)
{
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
624,6 → 704,16
 
void displ_course(void)
{
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
648,11 → 738,21
static uint8_t c = 0;
double elevace,azimut;
 
switch(test_key())
{
case KEY1_LONG:if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: c=0;id_mod=ID_OFF;return;
case KEY3_LONG: c=0;return;
case KEY1_SHORT:c=0;timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:c=0;d++;timer_refresh = 0;break;
case KEY3_SHORT: break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
if (c--) return;
c=3;
c=5;
buffer_clr();
//status();
#ifdef DEBUG
660,11 → 760,11
{
printf("error view satelites");
lcd_refresh();
c=20;
c=5;
return;
}
#endif
if (++d >= gps.gsv_satelites_view) d = 0;
if (d >= gps.gsv_satelites_view) d = 0;
gotoxy(12,1);
printf("%d",gps.gsv_satelites_view);
gotoxy(12,2);
713,6 → 813,17
 
void displ_all_position()
{
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
742,6 → 853,16
uint8_t a,b;
uint8_t *ptr;
 
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
748,7 → 869,7
buffer_clr();
status();
const float gc_lat=48*60+57.7647,gc_lon=14*60+28.0836; // DOMA
const float gc_lat= MY_LAT,gc_lon=MY_LON; // DOMA
 
lon=(gc_lon-gps.longitude*60)*1214;
lat=(gc_lat-gps.latitude*60)*1854;
840,7 → 961,17
void displ_service(char *buf)
{
uint8_t a;
 
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
860,6 → 991,16
//uint8_t xs,ys;
double course;
 
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
914,6 → 1055,16
{
uint8_t a;
 
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
case KEY2_SHORT:
case KEY3_SHORT:break;
}
 
if (!timer_refresh)
{
timer_refresh = CLOCK1S;
949,15 → 1100,9
}
}
 
void displ_temp()
void temp(void)
{
//GPS_OFF;
//ADC_OFF;
//REF_OFF;
 
if(!timer_temp)
{
timer_temp = TEMP_TIME_REPEAT;
timer_temp = TEMP_TIME_REPEAT;
now.temperature=read_temp();
now.time=actual_time();
now.date=actual_date();
997,9 → 1142,41
print_time(min.time);
lcd_refresh();
start_MCP9800();
}
 
void displ_temp()
{
//GPS_OFF;
//ADC_OFF;
//REF_OFF;
 
switch(test_key())
{
case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
case KEY2_LONG: id_mod=ID_OFF;return;
case KEY3_LONG: return;
case KEY1_SHORT:timer_refresh = 0;id_mod++;return;
case KEY2_SHORT:timer_temp = 0; max.temperature=0x8000;min.temperature=0x7FFF;
if (GPS_INPUT && (gps.status == 'A'))
{
sRTC=gps.second;
mRTC=gps.minute;
hRTC=gps.hour+2;
 
dRTC=gps.day;
mdRTC=gps.month;
yRTC=gps.year;
}break;
case KEY3_SHORT: break;
}
 
if(!timer_temp)
{
temp();
}
}
 
 
void displ_start(void)
{
buffer_clr();
1008,11 → 1185,12
lcd_refresh();
delay_ms(1000);
id_mod = ID_TEMP;
 
}
 
void all_off(void)
{
uint8_t temp_wiev;
 
buffer_clr();
gotoxy(6,3);
fprintf(&mystdout2,"OFF");
1019,13 → 1197,29
lcd_refresh();
GPS_OFF;
REF_OFF;
ADC_OFF;
delay_ms(1000);
LED_OFF;
N5110_send_command(POWER_DOWN);
temp_wiev = 0;
while (TL2_INPUT)
{
sleep_cpu();
if (!TL1_INPUT)
{
if (!temp_wiev) N5110_send_command(ACTIVE_CHIP);
temp_wiev = 1;
timer1_ovf = 0;
while ((!TL1_INPUT) && (timer1_ovf<200));
if (timer1_ovf==200)
{
max.temperature=0x8000;
min.temperature=0x7FFF;
}
}
if (!TL3_INPUT) {N5110_send_command(POWER_DOWN);temp_wiev = 0;}
if (temp_wiev) temp();
 
}
null_variables();
1166,7 → 1360,7
 
timer1_tik();
 
id_mod = key(id_mod);
//id_mod = key(id_mod);
 
}
return 0;