|
@@ -47,6 +47,11 @@ __flash const unsigned char battery_states[][8] = {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+struct disp_s {
|
|
|
|
+ char line1[16];
|
|
|
|
+ char line2[17];
|
|
|
|
+} disp;
|
|
|
|
+
|
|
void battery_state_display(void) {
|
|
void battery_state_display(void) {
|
|
unsigned char i;
|
|
unsigned char i;
|
|
unsigned char index;
|
|
unsigned char index;
|
|
@@ -66,46 +71,90 @@ 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;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void disp_func_card_ok(__attribute__ ((unused)) unsigned char changed) {
|
|
|
|
+ strcpy_P(disp.line1, PSTR("Karta OK!"));
|
|
|
|
+ strcpy_P(disp.line2, PSTR("Czekam na GPS..."));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void disp_func_file_open(__attribute__ ((unused)) unsigned char changed) {
|
|
|
|
+ strcpy_P(disp.line2, PSTR("Zapis aktywny"));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void disp_func_file_closed(__attribute__ ((unused)) unsigned char changed) {
|
|
|
|
+ strcpy_P(disp.line2, PSTR("Pliki zamkniete"));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void disp_func_main_default(unsigned char changed) {
|
|
|
|
+ disp.line1[0] = '\0';
|
|
|
|
+ disp_func_file_open(changed);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void disp_func_coord(__attribute__ ((unused)) unsigned char changed) {
|
|
|
|
+ if (System.location_valid == LOC_INVALID) {
|
|
|
|
+ strcpy_P(disp.line1, PSTR("??? N/S"));
|
|
|
|
+ strcpy_P(disp.line2, PSTR("??? E/W"));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ xsprintf(disp.line1, PSTR("%2.6f%c"), (location.lat < 0)?(-location.lat):location.lat, (location.lat < 0)?'S':'N');
|
|
|
|
+ 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) {
|
|
|
|
+ if (System.location_valid == LOC_INVALID) {
|
|
|
|
+ strcpy_P(disp.line1, PSTR("ele = ???"));
|
|
|
|
+ } else {
|
|
|
|
+ xsprintf(disp.line1, PSTR("ele = %.1fm"), location.alt);
|
|
|
|
+ }
|
|
|
|
+ xsprintf(disp.line2, PSTR("%d satelit"), System.satellites_used);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+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,
|
|
|
|
+};
|
|
|
|
|
|
void display_refresh(unsigned char newstate) {
|
|
void display_refresh(unsigned char newstate) {
|
|
- static const char *line1, *line2;
|
|
|
|
unsigned char changed = 0;
|
|
unsigned char changed = 0;
|
|
-
|
|
|
|
- switch (System.display_state) {
|
|
|
|
- case DISPLAY_STATE_STARTUP:
|
|
|
|
- line1 = PSTR("Uruchamianie...");
|
|
|
|
- break;
|
|
|
|
- case DISPLAY_STATE_POWEROFF_LOWBAT:
|
|
|
|
- line2 = PSTR("Bateria slaba!");
|
|
|
|
- /* fall through */
|
|
|
|
- case DISPLAY_STATE_POWEROFF:
|
|
|
|
- line1 = PSTR("Wylaczanie...");
|
|
|
|
- break;
|
|
|
|
- case DISPLAY_STATE_START_MESSAGE:
|
|
|
|
- line1 = PSTR("Start");
|
|
|
|
- switch(System.status){
|
|
|
|
- case STATUS_NO_POWER: case STATUS_OK: case STATUS_NO_GPS: line2 = NULL; break;
|
|
|
|
- case STATUS_NO_DISK: line2 = PSTR("Brak karty!"); break;
|
|
|
|
- case STATUS_DISK_ERROR: line2 = PSTR("Blad karty!"); break;
|
|
|
|
- case STATUS_FILE_WRITE_ERROR: line2 = PSTR("Blad zapisu!"); break;
|
|
|
|
- case STATUS_FILE_SYNC_ERROR: line2 = PSTR("Blad zapisu FAT!"); break;
|
|
|
|
- case STATUS_FILE_CLOSE_ERROR: line2 = PSTR("Blad zamk.pliku!"); break;
|
|
|
|
- case STATUS_FILE_OPEN_ERROR: line2 = PSTR("Blad otw. pliku!"); break;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case DISPLAY_STATE_CARD_OK:
|
|
|
|
- line1 = PSTR("Karta OK!");
|
|
|
|
- line2 = PSTR("Czekam na GPS...");
|
|
|
|
- break;
|
|
|
|
- case DISPLAY_STATE_FILE_OPEN:
|
|
|
|
- line2 = PSTR("Zapis aktywny");
|
|
|
|
- break;
|
|
|
|
- case DISPLAY_STATE_FILE_CLOSED:
|
|
|
|
- line2 = PSTR("Pliki zamkniete");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
if (newstate)
|
|
if (newstate)
|
|
changed = 1;
|
|
changed = 1;
|
|
|
|
+
|
|
|
|
+ disp_funcs[System.display_state](changed);
|
|
|
|
+
|
|
if (timer_expired(lcd)) {
|
|
if (timer_expired(lcd)) {
|
|
changed = 1;
|
|
changed = 1;
|
|
set_timer(lcd, 1000);
|
|
set_timer(lcd, 1000);
|
|
@@ -116,35 +165,20 @@ void display_refresh(unsigned char newstate) {
|
|
battery_state_display();
|
|
battery_state_display();
|
|
unsigned char len;
|
|
unsigned char len;
|
|
LCD_GoTo(0,0);
|
|
LCD_GoTo(0,0);
|
|
- if (line1) {
|
|
|
|
- len = strlen_P(line1);
|
|
|
|
- if (len > 15)
|
|
|
|
- xprintf(PSTR("Warning: too long line1=%d, mem addr %4x\r\n"), (int)len, (unsigned int)line1);
|
|
|
|
- LCD_WriteTextP(line1);
|
|
|
|
- while (len<15) {
|
|
|
|
- len++;
|
|
|
|
- LCD_WriteData(' ');
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (len=0; len<15; len++)
|
|
|
|
- LCD_WriteData(' ');
|
|
|
|
|
|
+ len = strlen(disp.line1);
|
|
|
|
+ LCD_WriteText(disp.line1);
|
|
|
|
+ while (len<15) {
|
|
|
|
+ len++;
|
|
|
|
+ LCD_WriteData(' ');
|
|
}
|
|
}
|
|
|
|
+ LCD_WriteData(0); /* battery symbol */
|
|
LCD_GoTo(0,1);
|
|
LCD_GoTo(0,1);
|
|
- if (line2) {
|
|
|
|
- len = strlen_P(line2);
|
|
|
|
- if (len > 16)
|
|
|
|
- xprintf(PSTR("Warning: too long line2=%d, mem addr %4x\r\n"), (int)len, (unsigned int)line1);
|
|
|
|
- LCD_WriteTextP(line2);
|
|
|
|
- while (len<16) {
|
|
|
|
- len++;
|
|
|
|
- LCD_WriteData(' ');
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (len=0; len<16; len++)
|
|
|
|
- LCD_WriteData(' ');
|
|
|
|
|
|
+ len = strlen(disp.line2);
|
|
|
|
+ LCD_WriteText(disp.line2);
|
|
|
|
+ while (len<16) {
|
|
|
|
+ len++;
|
|
|
|
+ LCD_WriteData(' ');
|
|
}
|
|
}
|
|
- LCD_GoTo(15, 0);
|
|
|
|
- LCD_WriteData(0); /* battery symbol */
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -152,3 +186,4 @@ void display_state(unsigned char newstate) {
|
|
System.display_state = newstate;
|
|
System.display_state = newstate;
|
|
display_refresh(newstate);
|
|
display_refresh(newstate);
|
|
}
|
|
}
|
|
|
|
+
|