More rendering optimizations

This commit is contained in:
sinseman 2015-02-12 16:30:44 +01:00
parent a9f9d97b23
commit 8b67a419ff

View File

@ -240,7 +240,6 @@ void renderVario()
display.clearDisplay(); display.clearDisplay();
//ALtitude //ALtitude
display.setCursor(0, 0);
display.setTextColor(BLACK); display.setTextColor(BLACK);
display.setTextSize(2); display.setTextSize(2);
display.print((int)Altitude); display.print((int)Altitude);
@ -285,9 +284,11 @@ void renderVario()
} }
//Vario //Vario
display.setTextColor(WHITE, BLACK);
display.setCursor(48, 24);
display.print(F("m/s"));
display.setTextSize(2); display.setTextSize(2);
display.setCursor(0, 16); display.setCursor(0, 16);
display.setTextColor(WHITE, BLACK);
float vario_abs = abs(vario); float vario_abs = abs(vario);
display.print((vario <= -0.05) ? F("-") : (vario >= 0.05) ? F("+") : F(" ")); display.print((vario <= -0.05) ? F("-") : (vario >= 0.05) ? F("+") : F(" "));
@ -295,9 +296,6 @@ void renderVario()
display.print(m); display.print(m);
display.print(F(".")); display.print(F("."));
display.print(round(10 * vario_abs) - (10 * m)); display.print(round(10 * vario_abs) - (10 * m));
display.setTextSize(1);
display.setCursor(48, 24);
display.print(F("m/s"));
//vario bar //vario bar
if (vario >= 0) if (vario >= 0)
@ -354,6 +352,8 @@ void renderStatItem(float value, const __FlashStringHelper *unit, bool integer =
display.print((int)value); display.print((int)value);
} }
else { else {
display.print(value, 1);
/*
if (value < 0) if (value < 0)
display.print(F("-")); display.print(F("-"));
float value_abs = abs(value); float value_abs = abs(value);
@ -361,8 +361,8 @@ void renderStatItem(float value, const __FlashStringHelper *unit, bool integer =
display.print(m); display.print(m);
display.print(F(".")); display.print(F("."));
display.print(round(10 * value_abs) - (10 * m)); display.print(round(10 * value_abs) - (10 * m));
*/
} }
display.setTextSize(1);
display.print(unit); display.print(unit);
} }
@ -381,8 +381,7 @@ void renderDateTime(DateTime d, uint8_t bold = 0)
renderZero(d.day()); renderZero(d.day());
display.print(d.day()); display.print(d.day());
if (bold != 0) display.setTextColor(BLACK);
display.setTextColor(BLACK);
display.print(F("/")); display.print(F("/"));
if (bold == DATE_MONTH) if (bold == DATE_MONTH)
@ -390,8 +389,7 @@ void renderDateTime(DateTime d, uint8_t bold = 0)
renderZero(d.month()); renderZero(d.month());
display.print(d.month()); display.print(d.month());
if (bold != 0) display.setTextColor(BLACK);
display.setTextColor(BLACK);
display.print(F("/")); display.print(F("/"));
if (bold == DATE_YEAR) if (bold == DATE_YEAR)
@ -399,8 +397,7 @@ void renderDateTime(DateTime d, uint8_t bold = 0)
renderZero(d.year() - 2000); renderZero(d.year() - 2000);
display.print(d.year() - 2000); //reduces the length of the year string display.print(d.year() - 2000); //reduces the length of the year string
if (bold != 0) display.setTextColor(BLACK);
display.setTextColor(BLACK);
display.print(F(" ")); display.print(F(" "));
//display time //display time
@ -409,8 +406,7 @@ void renderDateTime(DateTime d, uint8_t bold = 0)
renderZero(d.hour()); renderZero(d.hour());
display.print(d.hour()); display.print(d.hour());
if (bold != 0) display.setTextColor(BLACK);
display.setTextColor(BLACK);
display.print(F(":")); display.print(F(":"));
if (bold == DATE_MINUTE) if (bold == DATE_MINUTE)
@ -418,32 +414,32 @@ void renderDateTime(DateTime d, uint8_t bold = 0)
renderZero(d.minute()); renderZero(d.minute());
display.print(d.minute()); display.print(d.minute());
if (bold != 0) //display.setTextColor(BLACK);
display.setTextColor(BLACK);
} }
void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2) void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
{ {
display.clearDisplay(); display.clearDisplay();
display.setTextSize(1); display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0, 0);
display.setTextSize(1);
display.setTextColor(WHITE, BLACK); display.setTextColor(WHITE, BLACK);
if (newMenuItem.getShortkey() != MENU_LEFT) if (newMenuItem.getShortkey() != MENU_LEFT){
if (newMenuItem.getShortkey() < 10) if (newMenuItem.getShortkey() < 10)
display.println(F("Accueil")); display.println(F("Accueil"));
else if (newMenuItem.getShortkey() >= 10 && newMenuItem.getShortkey() < 20) else if (newMenuItem.getShortkey() >= 10 && newMenuItem.getShortkey() < 20)
display.println(F("Options")); display.println(F("Options"));
else if (newMenuItem.getShortkey() >= 20 && newMenuItem.getShortkey() < 30) else if (newMenuItem.getShortkey() == MENU_RECRESET)
display.println(F("Statistiques")); display.println(F("Statistiques"));
}
display.setTextSize(2); if (newMenuItem.getShortkey() != MENU_STAT){
display.println(newMenuItem.getName());
if (!menuUsed) display.setTextSize(2);
display.setTextColor(BLACK); display.println(newMenuItem.getName());
if (!menuUsed)
display.setTextColor(BLACK);
}
if (varioState == true && menuUsed) { if (varioState == true && menuUsed) {
varioState = false; varioState = false;
@ -562,10 +558,11 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
case MENU_DATE: case MENU_DATE:
{ {
display.setTextSize(1);
if (menuUsed_last == false) { if (menuUsed_last == false) {
menuUsed_last = true; menuUsed_last = true;
display.setTextSize(1);
DateTime now = rtc.now(); DateTime now = rtc.now();
renderDateTime(now); renderDateTime(now);
@ -578,8 +575,6 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
} }
else { else {
display.setTextSize(1);
if (dir != MENU_RIGHT && dir != MENU_LEFT) { if (dir != MENU_RIGHT && dir != MENU_LEFT) {
if (conf_date_displayed < 5) { if (conf_date_displayed < 5) {
@ -592,9 +587,8 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
menuUsed = false; menuUsed = false;
menuUsed_last = true; menuUsed_last = true;
conf_date_displayed = 0; conf_date_displayed = 0;
display.setTextColor(BLACK);
rtc.adjust(DateTime(date_year, date_month, date_day, date_hour, date_minute, 0)); rtc.adjust(DateTime(date_year, date_month, date_day, date_hour, date_minute, 0));
display.setTextSize(1); display.setTextColor(BLACK);
renderDateTime(rtc.now()); renderDateTime(rtc.now());
} }
} }
@ -641,10 +635,6 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
Stat stat_to_display; Stat stat_to_display;
readStat(stat_displayed - 1, stat_to_display); readStat(stat_displayed - 1, stat_to_display);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE, BLACK);
if (stat_to_display.chrono == 0) { if (stat_to_display.chrono == 0) {
display.print(F("M")); display.print(F("M"));
display.print(stat_displayed); display.print(stat_displayed);
@ -653,13 +643,12 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
else { else {
//if (stat_blink_status) { //if (stat_blink_status) {
display.setTextColor(BLACK);
renderDateTime(DateTime(stat_to_display.chrono_start)); renderDateTime(DateTime(stat_to_display.chrono_start));
display.println(); display.println();
//} //}
//else { //else {
display.setTextColor(BLACK);
display.print(F("Chrono:")); display.print(F("Chrono:"));
renderChrono(stat_to_display); renderChrono(stat_to_display);
display.println(); display.println();
@ -667,7 +656,6 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
//} //}
//stat_blink_status = !stat_blink_status; //stat_blink_status = !stat_blink_status;
display.print(F("Alt max:")); display.print(F("Alt max:"));
renderStatItem(stat_to_display.alti_max, F("m"), true); renderStatItem(stat_to_display.alti_max, F("m"), true);
display.println(); display.println();