11,9 → 11,6 |
//************************************************************************ |
// 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 |
22,7 → 19,6 |
#define TEMP_TIME_REPEAT 100 |
|
#define OFF_TIME 200 |
#define TIME_KEY_LONG 200 |
|
#define REFRESH_TIME 100 |
|
275,9 → 271,9 |
cli(); |
buffer_clr(); |
gotoxy(2,3); |
fprintf(&mystdout2,"update"); |
gotoxy(2,5); |
fprintf(&mystdout2,"firmware"); |
fprintf(&mystdout2,"programing"); |
gotoxy(6,5); |
fprintf(&mystdout2,"mod"); |
lcd_refresh(); |
delay_ms(1000); |
BOOT(); |
316,7 → 312,6 |
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) |
{ |
328,7 → 323,6 |
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 |
337,17 → 331,12 |
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) |
{ |
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; |
} |
} |
} |
522,44 → 511,6 |
} |
|
//********************************************************************* |
// 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) |
612,17 → 563,6 |
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; |
643,16 → 583,6 |
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; |
679,16 → 609,6 |
|
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; |
704,16 → 624,6 |
|
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; |
738,21 → 648,11 |
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=5; |
c=3; |
buffer_clr(); |
//status(); |
#ifdef DEBUG |
760,11 → 660,11 |
{ |
printf("error view satelites"); |
lcd_refresh(); |
c=5; |
c=20; |
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); |
813,17 → 713,6 |
|
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; |
853,16 → 742,6 |
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; |
869,7 → 748,7 |
buffer_clr(); |
status(); |
|
const float gc_lat= MY_LAT,gc_lon=MY_LON; // DOMA |
const float gc_lat=48*60+57.7647,gc_lon=14*60+28.0836; // DOMA |
|
lon=(gc_lon-gps.longitude*60)*1214; |
lat=(gc_lat-gps.latitude*60)*1854; |
962,16 → 841,6 |
{ |
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; |
991,16 → 860,6 |
//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; |
1055,16 → 914,6 |
{ |
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; |
1100,8 → 949,14 |
} |
} |
|
void temp(void) |
void displ_temp() |
{ |
//GPS_OFF; |
//ADC_OFF; |
//REF_OFF; |
|
if(!timer_temp) |
{ |
timer_temp = TEMP_TIME_REPEAT; |
now.temperature=read_temp(); |
now.time=actual_time(); |
1143,40 → 998,8 |
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(); |
1185,12 → 1008,11 |
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"); |
1197,29 → 1019,13 |
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(); |
1360,7 → 1166,7 |
|
timer1_tik(); |
|
//id_mod = key(id_mod); |
id_mod = key(id_mod); |
|
} |
return 0; |