|
@@ -98,52 +98,50 @@ void battery_state_display(void) {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-void disp_func_startup(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- strcpy_P(disp.line1, PSTR("Uruchamianie..."));
|
|
|
-}
|
|
|
-
|
|
|
-void disp_func_poweroff(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- strcpy_P(disp.line1, PSTR("Wylaczanie..."));
|
|
|
-}
|
|
|
-
|
|
|
-void disp_func_poweroff_lowbat(unsigned char changed) {
|
|
|
- disp_func_poweroff(changed);
|
|
|
- strcpy_P(disp.line2, PSTR("Bateria slaba!"));
|
|
|
-}
|
|
|
-
|
|
|
-void disp_func_start_message(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- strcpy_P(disp.line1, PSTR("Start"));
|
|
|
- switch(System.status){
|
|
|
- case STATUS_NO_POWER: case STATUS_OK: case STATUS_NO_GPS: disp.line2[0] = '\0'; break;
|
|
|
- case STATUS_NO_DISK: strcpy_P(disp.line2, PSTR("Brak karty!")); break;
|
|
|
- case STATUS_DISK_ERROR: strcpy_P(disp.line2, PSTR("Blad karty!")); break;
|
|
|
- case STATUS_FILE_WRITE_ERROR: strcpy_P(disp.line2, PSTR("Blad zapisu!")); break;
|
|
|
- case STATUS_FILE_SYNC_ERROR: strcpy_P(disp.line2, PSTR("Blad zapisu FAT!")); break;
|
|
|
- case STATUS_FILE_CLOSE_ERROR: strcpy_P(disp.line2, PSTR("Blad zamk.pliku!")); break;
|
|
|
- case STATUS_FILE_OPEN_ERROR: strcpy_P(disp.line2, PSTR("Blad otw. pliku!")); break;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
__flash const char _gps_wait[] = "Czekam na GPS...";
|
|
|
__flash const char _gps_ok[] = "GPS OK!";
|
|
|
__flash const char _card_ok[] = "Karta OK!";
|
|
|
__flash const char _logging_active[] = "Zapis aktywny";
|
|
|
__flash const char _logging_paused[] = "Zapis wstrzymany";
|
|
|
|
|
|
-void disp_func_card_ok(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- strcpy_P(disp.line1, _card_ok);
|
|
|
- strcpy_P(disp.line2, _gps_wait);
|
|
|
-}
|
|
|
-
|
|
|
-void disp_func_file_open(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- strcpy_P(disp.line2, _logging_active);
|
|
|
-}
|
|
|
-
|
|
|
-void disp_func_file_closed(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- strcpy_P(disp.line2, PSTR("Pliki zamkniete"));
|
|
|
+void display_event(unsigned char event) { /* overrides display with current messages */
|
|
|
+ switch (event) {
|
|
|
+ case DISPLAY_EVENT_STARTUP:
|
|
|
+ strcpy_P(disp.line1, PSTR("Uruchamianie..."));
|
|
|
+ break;
|
|
|
+ case DISPLAY_EVENT_LOW_BATTERY:
|
|
|
+ strcpy_P(disp.line2, PSTR("Bateria slaba!"));
|
|
|
+ /* fall through */
|
|
|
+ case DISPLAY_EVENT_POWEROFF:
|
|
|
+ strcpy_P(disp.line1, PSTR("Wylaczanie..."));
|
|
|
+ break;
|
|
|
+ case DISPLAY_EVENT_INITIALIZED:
|
|
|
+ strcpy_P(disp.line1, PSTR("Start"));
|
|
|
+ switch(System.status){
|
|
|
+ case STATUS_NO_POWER: case STATUS_OK: case STATUS_NO_GPS: disp.line2[0] = '\0'; break;
|
|
|
+ case STATUS_NO_DISK: strcpy_P(disp.line2, PSTR("Brak karty!")); break;
|
|
|
+ case STATUS_DISK_ERROR: strcpy_P(disp.line2, PSTR("Blad karty!")); break;
|
|
|
+ case STATUS_FILE_WRITE_ERROR: strcpy_P(disp.line2, PSTR("Blad zapisu!")); break;
|
|
|
+ case STATUS_FILE_SYNC_ERROR: strcpy_P(disp.line2, PSTR("Blad zapisu FAT!")); break;
|
|
|
+ case STATUS_FILE_CLOSE_ERROR: strcpy_P(disp.line2, PSTR("Blad zamk.pliku!")); break;
|
|
|
+ case STATUS_FILE_OPEN_ERROR: strcpy_P(disp.line2, PSTR("Blad otw. pliku!")); break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case DISPLAY_EVENT_CARD_INITIALIZED:
|
|
|
+ strcpy_P(disp.line1, _card_ok);
|
|
|
+ strcpy_P(disp.line2, _gps_wait);
|
|
|
+ break;
|
|
|
+ case DISPLAY_EVENT_FILE_CLOSED:
|
|
|
+ strcpy_P(disp.line2, PSTR("Pliki zamkniete"));
|
|
|
+ break;
|
|
|
+ case DISPLAY_EVENT_FILE_OPEN:
|
|
|
+ strcpy_P(disp.line2, PSTR("Pliki otwarte"));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ display_refresh(1);
|
|
|
}
|
|
|
|
|
|
-void disp_func_main_default(__attribute__ ((unused)) unsigned char changed) {
|
|
|
+void disp_func_main_default(void) {
|
|
|
if (FLAGS & F_FILEOPEN) {
|
|
|
if (System.tracking_paused)
|
|
|
strcpy_P(disp.line1, _logging_paused);
|
|
@@ -158,7 +156,7 @@ void disp_func_main_default(__attribute__ ((unused)) unsigned char changed) {
|
|
|
strcpy_P(disp.line2, _gps_wait);
|
|
|
}
|
|
|
|
|
|
-void disp_func_coord(__attribute__ ((unused)) unsigned char changed) {
|
|
|
+void disp_func_coord(void) {
|
|
|
if (System.location_valid == LOC_INVALID) {
|
|
|
strcpy_P(disp.line1, PSTR("??? N/S"));
|
|
|
strcpy_P(disp.line2, PSTR("??? E/W"));
|
|
@@ -168,7 +166,7 @@ void disp_func_coord(__attribute__ ((unused)) unsigned char changed) {
|
|
|
xsprintf(disp.line2, PSTR("%3.6f%c"), (location.lon < 0)?(-location.lon):location.lon, (location.lon < 0)?'W':'E');
|
|
|
}
|
|
|
|
|
|
-void disp_func_ele_sat(__attribute__ ((unused)) unsigned char changed) {
|
|
|
+void disp_func_ele_sat(void) {
|
|
|
if (System.location_valid == LOC_INVALID) {
|
|
|
strcpy_P(disp.line1, PSTR("ele = ???"));
|
|
|
} else {
|
|
@@ -179,7 +177,7 @@ void disp_func_ele_sat(__attribute__ ((unused)) unsigned char changed) {
|
|
|
strcat_P(disp.line2, PSTR(", DGPS"));
|
|
|
}
|
|
|
|
|
|
-void disp_distance_and_time(__attribute__ ((unused)) unsigned char changed) {
|
|
|
+void disp_distance_and_time(void) {
|
|
|
xsprintf(disp.line1, PSTR("%.2f km"), (float)System.distance / 100000.0);
|
|
|
if (utc > 0 && System.time_start > 0) {
|
|
|
xsprintf(disp.line2, PSTR("t=%u s"), (unsigned int)(utc - System.time_start));
|
|
@@ -188,7 +186,7 @@ void disp_distance_and_time(__attribute__ ((unused)) unsigned char changed) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void disp_speed(__attribute__ ((unused)) unsigned char changed) {
|
|
|
+void disp_speed(void) {
|
|
|
strcpy_P(disp.line1, PSTR("Predkosc:"));
|
|
|
if (utc > 0 && System.time_start > 0) {
|
|
|
xsprintf(disp.line2, PSTR("%.2f km/h"), (float)System.distance / (float)(utc - System.time_start) * 0.036);
|
|
@@ -197,7 +195,7 @@ void disp_speed(__attribute__ ((unused)) unsigned char changed) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void disp_time(__attribute__ ((unused)) unsigned char changed) {
|
|
|
+void disp_time(void) {
|
|
|
if (utc == 0) {
|
|
|
strcpy_P(disp.line1, PSTR("?"));
|
|
|
strcpy_P(disp.line2, PSTR("?"));
|
|
@@ -211,7 +209,7 @@ void disp_time(__attribute__ ((unused)) unsigned char changed) {
|
|
|
xsprintf(disp.line2, PSTR("%d:%02d:%02d"), ct->tm_hour, ct->tm_min, ct->tm_sec);
|
|
|
}
|
|
|
|
|
|
-void disp_func_temperature(__attribute__ ((unused)) unsigned char changed) {
|
|
|
+void disp_func_temperature(void) {
|
|
|
strcpy_P(disp.line1, PSTR("Temperatura"));
|
|
|
if (System.temperature_ok) {
|
|
|
xsprintf(disp.line2, PSTR("%.1f stC"), System.temperature);
|
|
@@ -219,48 +217,15 @@ void disp_func_temperature(__attribute__ ((unused)) unsigned char changed) {
|
|
|
strcpy_P(disp.line2, PSTR("Blad!"));
|
|
|
}
|
|
|
}
|
|
|
-void disp_func_main_menu(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- display_main_menu_item();
|
|
|
-}
|
|
|
-
|
|
|
-void disp_func_settings_menu(__attribute__ ((unused)) unsigned char changed) {
|
|
|
- display_settings_menu_item();
|
|
|
-}
|
|
|
|
|
|
-void (*__flash const disp_funcs[])(unsigned char) = {
|
|
|
- [DISPLAY_STATE_STARTUP] = disp_func_startup,
|
|
|
- [DISPLAY_STATE_POWEROFF] = disp_func_poweroff,
|
|
|
- [DISPLAY_STATE_POWEROFF_LOWBAT] = disp_func_poweroff_lowbat,
|
|
|
- [DISPLAY_STATE_START_MESSAGE] = disp_func_start_message,
|
|
|
- [DISPLAY_STATE_CARD_OK] = disp_func_card_ok,
|
|
|
- [DISPLAY_STATE_FILE_OPEN] = disp_func_file_open,
|
|
|
- [DISPLAY_STATE_FILE_CLOSED] = disp_func_file_closed,
|
|
|
- [DISPLAY_STATE_MAIN_DEFAULT] = disp_func_main_default,
|
|
|
- [DISPLAY_STATE_COORD] = disp_func_coord,
|
|
|
- [DISPLAY_STATE_ELE_SAT] = disp_func_ele_sat,
|
|
|
- [DISPLAY_STATE_DIST_TIME] = disp_distance_and_time,
|
|
|
- [DISPLAY_STATE_SPEED] = disp_speed,
|
|
|
- [DISPLAY_STATE_TIME] = disp_time,
|
|
|
- [DISPLAY_STATE_MAIN_MENU] = disp_func_main_menu,
|
|
|
- [DISPLAY_STATE_SETTINGS_MENU] = disp_func_settings_menu,
|
|
|
- [DISPLAY_STATE_TEMPERATURE] = disp_func_temperature,
|
|
|
-};
|
|
|
-
|
|
|
-void display_refresh(unsigned char newstate) {
|
|
|
- unsigned char changed = 0;
|
|
|
-
|
|
|
- if (newstate)
|
|
|
- changed = 1;
|
|
|
-
|
|
|
- disp_funcs[System.display_state](changed);
|
|
|
-
|
|
|
+void display_refresh(unsigned char changed) {
|
|
|
if (timer_expired(lcd)) {
|
|
|
changed = 1;
|
|
|
- set_timer(lcd, 1000);
|
|
|
}
|
|
|
|
|
|
/* write to LCD */
|
|
|
if (changed) {
|
|
|
+ set_timer(lcd, 1000);
|
|
|
battery_state_display();
|
|
|
unsigned char len;
|
|
|
LCD_GoTo(0,0);
|
|
@@ -281,8 +246,3 @@ void display_refresh(unsigned char newstate) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void display_state(unsigned char newstate) {
|
|
|
- System.display_state = newstate;
|
|
|
- display_refresh(newstate);
|
|
|
-}
|
|
|
-
|