Several fixes for better displaying values.

master
Holger Wirtz 4 years ago
parent e666161ef7
commit 6f8890a099
  1. 90
      WLAN_Thermometer.ino

@ -24,7 +24,6 @@
#define KRATE_TEMP 5000
#define KRATE_TIME 500
#define KRATE_RESET_AP_DATA 5000
#define MEDIAN_SAMPLES 60
#define ONBOARD_LED 2
#define NTP_TIMEOUT 15000
#define WIFI_CONNECT_TIMEOUT 30
@ -46,6 +45,7 @@ const uint8_t degree_sign[8] = { B00010, B00101, B00010, B00000, B00000, B00000,
uint8_t add_summertime = 0;
bool last_reset_ap_check = false;
bool minmax_enabled = false;
char date_string_old[9];
enum {
ACT,
@ -158,7 +158,9 @@ void setup()
heat[MIN] = heat[ACT];
heat[MAX] = heat[ACT];
lcd.clear();
strcpy(date_string_old, "--:--:----");
setup_screen();
show_time();
show_temperature();
}
@ -348,7 +350,8 @@ void check_reset_ap_data(void)
void show_time(void)
{
char dt[21];
char date_string[11];
char time_string[9];
if (DateTime.isTimeValid())
{
@ -365,18 +368,29 @@ void show_time(void)
add_summertime = 0;
}
sprintf(dt, "%02d.%02d.%4d %02d:%02d:%02d", p.getMonthDay(), p.getMonth() + 1, p.getYear(), p.getHours() + add_summertime, p.getMinutes(), p.getSeconds());
DEBUG_MSG("%s", dt);
sprintf(date_string, "%02d.%02d.%4d", p.getMonthDay(), p.getMonth() + 1, p.getYear());
sprintf(time_string, "%02d:%02d:%02d", p.getHours() + add_summertime, p.getMinutes(), p.getSeconds());
DEBUG_MSG("%s %s", date_string, time_string);
if (add_summertime > 0)
DEBUG_MSG(" Summertime\n");
else
DEBUG_MSG(" Wintertime\n");
}
else
sprintf(dt, "--:--:---- --:--:--");
{
strcpy(date_string, "--:--:----");
strcpy(time_string, "--:--:--");
}
lcd.setCursor(0, 0);
lcd.print(dt);
if (strcmp(date_string, date_string_old))
{
lcd.setCursor(0, 0);
lcd.print(date_string);
strcpy(date_string_old, date_string);
}
lcd.setCursor(12, 0);
lcd.print(time_string);
digitalWrite(ONBOARD_LED, led_state);
led_state = !led_state;
@ -388,25 +402,50 @@ void show_temperature(void)
DEBUG_MSG("Temperature: %02.2f\n", temp[ACT]);
lcd.setCursor(0, 1);
lcd.print("Temperatur: ");
lcd.print(temp[ACT], 1);
lcd.write(0);
lcd.print("C");
lcd.setCursor(14, 1);
if (isnan(temp[ACT]))
lcd.print("--.-");
else
lcd.print(round_float(temp[ACT], 1), 1);
if (millis() > FIRST_MIN_MAX)
{
lcd.setCursor(0, 2);
lcd.print("Min: ");
lcd.print(temp[MIN], 1);
lcd.print(" Max: ");
lcd.print(temp[MAX], 1);
lcd.setCursor(5, 2);
if (isnan(temp[MIN]))
lcd.print("--.-");
else
lcd.print(round_float(temp[MIN], 1), 1);
lcd.setCursor(16, 2);
if (isnan(temp[MAX]))
lcd.print("--.-");
else
lcd.print(round_float(temp[MAX], 1), 1);
}
lcd.setCursor(5, 3);
if (isnan(hum[ACT]))
lcd.print("--.-");
else
lcd.print(round_float(hum[ACT], 1), 1);
lcd.setCursor(16, 3);
if (isnan(heat[ACT]))
lcd.print("--.-");
else
lcd.print(round_float(heat[ACT], 1), 1);
}
void setup_screen(void)
{
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Temperatur:");
lcd.setCursor(18, 1);
lcd.write(0);
lcd.print("C");
lcd.setCursor(0, 2);
lcd.print("Min: --.- Max: --.-");
lcd.setCursor(0, 3);
lcd.print("LF: ");
lcd.print(hum[ACT], 1);
lcd.print("%");
lcd.print(" GT: ");
lcd.print(heat[ACT], 1);
lcd.print("LF: % GT:");
}
bool is_wintertime(time_t t)
@ -518,3 +557,8 @@ void ConfigAPStarted(WiFiManager * wm)
lcd.clear();
DEBUG_MSG("Config-AP started\n");
}
float round_float(float num, uint8_t dec_place)
{
return ((round(num * powf(10, dec_place))) / powf(10, dec_place));
}

Loading…
Cancel
Save