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