Skip to content

Commit

Permalink
Fix display paging, new debug option, documentation clarity improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lmarzen committed Sep 10, 2023
1 parent 3c304f4 commit 326e738
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 64 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,22 @@ esp32-weather-epd is licensed under the [GNU General Public License v3.0](LICENS
| [Adafruit-GFX-Library: fontconvert](https://github.com/adafruit/Adafruit-GFX-Library/tree/master/fontconvert) | [BSD License](fonts/fontconvert/license.txt) | CLI tool for preprocessing fonts to be used with the Adafruit_GFX Arduino library. |
| [pollutant-concentration-to-aqi](https://github.com/lmarzen/pollutant-concentration-to-aqi) | [GNU Lesser General Public License v2.1](platformio/lib/pollutant-concentration-to-aqi/LICENSE) | C library that converts pollutant concentrations to Air Quality Index(AQI). |
| [GNU FreeFont](https://www.gnu.org/software/freefont/) | [GNU General Public License v3.0](https://www.gnu.org/software/freefont/license.html) | Font Family |
| [Lato](https://fonts.google.com/specimen/Lato) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | Font Family |
| [Montserrat](https://fonts.google.com/specimen/Montserrat) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | Font Family |
| [Open Sans](https://fonts.google.com/specimen/Open+Sans) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | Font Family |
| [Poppins](https://fonts.google.com/specimen/Poppins) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | Font Family |
| [Quicksand](https://fonts.google.com/specimen/Quicksand) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | Font Family |
| [Raleway](https://fonts.google.com/specimen/Raleway) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | Font Family |
| [Lato](https://fonts.google.com/specimen/Lato) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | Font Family |
| [Montserrat](https://fonts.google.com/specimen/Montserrat) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | Font Family |
| [Open Sans](https://fonts.google.com/specimen/Open+Sans) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | Font Family |
| [Poppins](https://fonts.google.com/specimen/Poppins) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | Font Family |
| [Quicksand](https://fonts.google.com/specimen/Quicksand) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | Font Family |
| [Raleway](https://fonts.google.com/specimen/Raleway) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | Font Family |
| [Roboto](https://fonts.google.com/specimen/Roboto) | [Apache License v2.0](https://www.apache.org/licenses/LICENSE-2.0) | Font Family |
| [Roboto Mono](https://fonts.google.com/specimen/Roboto+Mono) | [Apache License v2.0](https://www.apache.org/licenses/LICENSE-2.0) | Font Family |
| [Roboto Slab](https://fonts.google.com/specimen/Roboto+Slab) | [Apache License v2.0](https://www.apache.org/licenses/LICENSE-2.0) | Font Family |
| [Ubuntu font](https://design.ubuntu.com/font) | [Ubuntu Font Licence v1.0](https://ubuntu.com/legal/font-licence) | Font Family |
| [Weather Themed Icons](https://github.com/erikflowers/weather-icons) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | (wi-**.svg) Weather icon family by Lukas Bischoff/Erik Flowers. |
| [Weather Themed Icons](https://github.com/erikflowers/weather-icons) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | (wi-**.svg) Weather icon family by Lukas Bischoff/Erik Flowers. |
| [Google Icons](https://fonts.google.com/icons) | [Apache License v2.0](https://www.apache.org/licenses/LICENSE-2.0) | (battery**.svg, visibility_icon.svg) Battery and visibility icons from Google Icons. |
| [Biological Hazard Symbol](https://svgsilh.com/image/37775.html) | [CC0 1.0](https://en.wikipedia.org/wiki/Public_domain) | (biological_hazard_symbol.svg) Biohazard icon. |
| [Biological Hazard Symbol](https://svgsilh.com/image/37775.html) | [CC0 v1.0](https://en.wikipedia.org/wiki/Public_domain) | (biological_hazard_symbol.svg) Biohazard icon. |
| [House Icon](https://seekicon.com/free-icon/house_16) | [MIT License](http://opensource.org/licenses/mit-license.html) | (house.svg) House icon. |
| [Indoor Temerature/Humidity Icons](icons/svg) | [SIL OFL 1.1](http://scripts.sil.org/OFL) | (house_**.svg) Indoor temerature/humidity icons. |
| [Ionizing Radiation Symbol](https://svgsilh.com/image/309911.html) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) | (ionizing_radiation_symbol.svg) Ionizing radiation icons. |
| [Indoor Temerature/Humidity Icons](icons/svg) | [SIL OFL v1.1](http://scripts.sil.org/OFL) | (house_**.svg) Indoor temerature/humidity icons. |
| [Ionizing Radiation Symbol](https://svgsilh.com/image/309911.html) | [CC0 v1.0](https://creativecommons.org/publicdomain/zero/1.0/) | (ionizing_radiation_symbol.svg) Ionizing radiation icons. |
| [Phosphor Icons](https://github.com/phosphor-icons/homepage) | [MIT License](http://opensource.org/licenses/mit-license.html) | (wifi**.svg, warning_icon.svg, error_icon.svg) WiFi, Warning, and Error icons from Phosphor Icons. |
| [Wind Direction Icon](https://www.onlinewebfonts.com/icon/251550) | [CC BY 3.0](http://creativecommons.org/licenses/by/3.0) | (meteorological_wind_direction_**deg.svg) Meteorological wind direction icon from Online Web Fonts. |
| [Wind Direction Icon](https://www.onlinewebfonts.com/icon/251550) | [CC BY v3.0](http://creativecommons.org/licenses/by/3.0) | (meteorological_wind_direction_**deg.svg) Meteorological wind direction icon from Online Web Fonts. |

37 changes: 21 additions & 16 deletions platformio/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,21 @@
// project for your convenience. Change the font by selecting its corresponding
// header file.
//
// FONT HEADER FILE FAMILY LICENSE
// FreeMono "fonts/FreeMono.h" GNU FreeFont GNU GPL v3.0
// FreeSans "fonts/FreeSans.h" GNU FreeFont GNU GPL v3.0
// FreeSerif "fonts/FreeSerif.h" GNU FreeFont GNU GPL v3.0
// Lato "fonts/Lato_Regular.h Lato SIL OFL 1.1
// Montserrat "fonts/Montserrat_Regular.h Montserrat SIL OFL 1.1
// Open Sans "fonts/OpenSans_Regular.h Open Sans SIL OFL 1.1
// Poppins "fonts/Poppins_Regular.h Poppins SIL OFL 1.1
// Quicksand "fonts/Quicksand_Regular.h Quicksand SIL OFL 1.1
// Raleway "fonts/Raleway_Regular.h Raleway SIL OFL 1.1
// Roboto "fonts/Roboto_Regular.h Roboto Apache v2.0
// Roboto Mono "fonts/RobotoMono_Regular.h Roboto Mono Apache v2.0
// Roboto Slab "fonts/RobotoSlab_Regular.h Roboto Slab Apache v2.0
// Ubuntu "fonts/Ubuntu_R.h Ubuntu font UFL v1.0
// Ubuntu Mono "fonts/UbuntuMono_R.h Ubuntu font UFL v1.0
// FONT HEADER FILE FAMILY LICENSE
// FreeMono FreeMono.h GNU FreeFont GNU GPL v3.0
// FreeSans FreeSans.h GNU FreeFont GNU GPL v3.0
// FreeSerif FreeSerif.h GNU FreeFont GNU GPL v3.0
// Lato Lato_Regular.h Lato SIL OFL v1.1
// Montserrat Montserrat_Regular.h Montserrat SIL OFL v1.1
// Open Sans OpenSans_Regular.h Open Sans SIL OFL v1.1
// Poppins Poppins_Regular.h Poppins SIL OFL v1.1
// Quicksand Quicksand_Regular.h Quicksand SIL OFL v1.1
// Raleway Raleway_Regular.h Raleway SIL OFL v1.1
// Roboto Roboto_Regular.h Roboto Apache v2.0
// Roboto Mono RobotoMono_Regular.h Roboto Mono Apache v2.0
// Roboto Slab RobotoSlab_Regular.h Roboto Slab Apache v2.0
// Ubuntu Ubuntu_R.h Ubuntu font UFL v1.0
// Ubuntu Mono UbuntuMono_R.h Ubuntu font UFL v1.0
//
// Adding new fonts is relatively straightforward, see fonts/README.
//
Expand All @@ -189,6 +189,12 @@
// Disable alerts by defining the DISABLE_ALERTS macro.
// #define DISABLE_ALERTS

// DEBUG
// If defined, enables increase verbosity over the serial port.
// level 0: basic status information, assists troubleshooting (default)
// level 1: increased verbosity for debugging
#define DEBUG_LEVEL 0

// Set the below constants in "config.cpp"
extern const uint8_t PIN_BAT_ADC;
extern const uint8_t PIN_EPD_BUSY;
Expand Down Expand Up @@ -219,7 +225,6 @@ extern const char *NTP_SERVER_2;
extern const long SLEEP_DURATION;
extern const int BED_TIME;
extern const int WAKE_TIME;
extern const char UNITS;
extern const int HOURLY_GRAPH_MAX;
extern const float BATTERY_WARN_VOLTAGE;
extern const float LOW_BATTERY_VOLTAGE;
Expand Down
1 change: 1 addition & 0 deletions platformio/include/display_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum alert_category getAlertCategory(const owm_alerts_t &alert);
const uint8_t *getWindBitmap24(int windDeg);
const char *getHttpResponsePhrase(int code);
const char *getWifiStatusPhrase(wl_status_t status);
void printHeapUsage();

#endif

17 changes: 9 additions & 8 deletions platformio/include/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ typedef enum alignment
CENTER
} alignment_t;

uint16_t getStringWidth(String text);
uint16_t getStringHeight(String text);
void drawString(int16_t x, int16_t y, String text, alignment_t alignment,
uint16_t getStringWidth(const String &text);
uint16_t getStringHeight(const String &text);
void drawString(int16_t x, int16_t y, const String &text, alignment_t alignment,
uint16_t color=GxEPD_BLACK);
void drawMultiLnString(int16_t x, int16_t y, String text, alignment_t alignment,
uint16_t max_width, uint16_t max_lines,
int16_t line_spacing, uint16_t color=GxEPD_BLACK);
void drawMultiLnString(int16_t x, int16_t y, const String &text,
alignment_t alignment, uint16_t max_width,
uint16_t max_lines, int16_t line_spacing,
uint16_t color=GxEPD_BLACK);
void initDisplay();
void drawCurrentConditions(const owm_current_t &current,
const owm_daily_t &today,
Expand All @@ -77,8 +78,8 @@ void drawAlerts(std::vector<owm_alerts_t> &alerts,
const String &city, const String &date);
void drawLocationDate(const String &city, const String &date);
void drawOutlookGraph(owm_hourly_t *const hourly, tm timeInfo);
void drawStatusBar(String statusStr, String refreshTimeStr, int rssi,
double batVoltage);
void drawStatusBar(const String &statusStr, const String &refreshTimeStr,
int rssi, double batVoltage);
void drawError(const uint8_t *bitmap_196x196,
const String &errMsgLn1, const String &errMsgLn2);

Expand Down
14 changes: 14 additions & 0 deletions platformio/src/client_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,17 @@ bool setupTime(tm *timeInfo)
return httpResponse;
} // getOWMairpollution

/* Prints debug information about heap usage.
*/
void printHeapUsage() {
Serial.println("[debug] Heap Size : "
+ String(ESP.getHeapSize()) + " B");
Serial.println("[debug] Available Heap : "
+ String(ESP.getFreeHeap()) + " B");
Serial.println("[debug] Min Free Heap : "
+ String(ESP.getMinFreeHeap()) + " B");
Serial.println("[debug] Max Allocatable : "
+ String(ESP.getMaxAllocHeap()) + " B");
return;
}

24 changes: 12 additions & 12 deletions platformio/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@

// PINS
// ADC pin used to measure battery voltage
const uint8_t PIN_BAT_ADC = A2;
const uint8_t PIN_BAT_ADC = A2; // A0 for micro-usb firebeetle
// Pins for Waveshare e-paper Driver Board
const uint8_t PIN_EPD_BUSY = 13;
const uint8_t PIN_EPD_BUSY = 13; // 5 for micro-usb firebeetle
const uint8_t PIN_EPD_CS = 2;
const uint8_t PIN_EPD_RST = 21;
const uint8_t PIN_EPD_DC = 22;
const uint8_t PIN_EPD_SCK = 18;
const uint8_t PIN_EPD_MISO = 19; // 19 Master-In Slave-Out not used, as no data from display
const uint8_t PIN_EPD_MOSI = 23;
// I2C Pins used for BME280
const uint8_t PIN_BME_SDA = 17;
const uint8_t PIN_BME_SCL = 16;
const uint8_t PIN_BME_SDA = 17; // 27 for micro-usb firebeetle
const uint8_t PIN_BME_SCL = 16; // 26 for micro-usb firebeetle
const uint8_t BME_ADDRESS = 0x76; // if sensor does not work, try 0x77

// WIFI CREDENTIALS
Expand Down Expand Up @@ -64,7 +64,7 @@ const String OWM_ONECALL_VERSION = "3.0";
const String LAT = "40.7128";
const String LON = "-74.0060";
// City name that will be shown in the top-right corner of the display.
const String CITY_STRING = "New York, New York";
const String CITY_STRING = "New York";

// TIME
// For list of time zones see
Expand All @@ -80,12 +80,12 @@ const char *TIME_FORMAT = "%H:%M"; // 24-hour ex: 01:23 23:00
// https://man7.org/linux/man-pages/man3/strftime.3.html
// const char *HOUR_FORMAT = "%l%P"; // 12-hour ex: 1am 11pm
const char *HOUR_FORMAT = "%H"; // 24-hour ex: 01 23
// Date format used when displaying date in top-right corner. For more
// Date format used when displaying date in top-right corner.
// For more information about formatting see
// https://man7.org/linux/man-pages/man3/strftime.3.html
const char *DATE_FORMAT = "%A, %B %e"; // Saturday, January 1
// Date/Time format used when displaying the last refresh time along the bottom
// of the screen
// of the screen.
// For more information about formatting see
// https://man7.org/linux/man-pages/man3/strftime.3.html
const char *REFRESH_TIME_FORMAT = "%x %H:%M";
Expand All @@ -95,17 +95,17 @@ const char *REFRESH_TIME_FORMAT = "%x %H:%M";
const char *NTP_SERVER_1 = "us.pool.ntp.org";
const char *NTP_SERVER_2 = "time.nist.gov";
// Sleep duration in minutes. (aka how often esp32 will wake for an update)
// Aligned to the nearest minute boundary, so if 30 will always update at 00 or
// 30 past the hour. (range: 0-59)
// Aligned to the nearest minute boundary and must evenly divide 60.
// For example, if set to 30 (minutes) the display will update at 00 or 30
// minutes past the hour. (range: [2-60])
const long SLEEP_DURATION = 30;
// If BED_TIME == WAKE_TIME, then this battery saving feature will be disabled.
// (range: 0-23)
// (range: [0-23])
const int BED_TIME = 00; // Last update at 00:00 (midnight) until WAKE_TIME.
const int WAKE_TIME = 06; // Hour of first update after BED_TIME, 06:00.

// HOURLY OUTLOOK GRAPH
// Number of hours to display on the outlook graph.
// Value must be between 8-48 (inclusively).
// Number of hours to display on the outlook graph. (range: [8-48])
const int HOURLY_GRAPH_MAX = 24;

// BATTERY
Expand Down
8 changes: 8 additions & 0 deletions platformio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ void setup()
unsigned long startTime = millis();
Serial.begin(115200);

#if DEBUG_LEVEL >= 1
printHeapUsage();
#endif

// GET BATTERY VOLTAGE
// DFRobot FireBeetle Esp32-E V1.0 has voltage divider (1M+1M), so readings
// are multiplied by 2. Readings are divided by 1000 to convert mV to V.
Expand Down Expand Up @@ -322,6 +326,10 @@ void setup()
} while (display.nextPage());
display.powerOff();

#if DEBUG_LEVEL >= 1
printHeapUsage();
#endif

// DEEP-SLEEP
beginDeepSleep(startTime, &timeInfo);
} // end setup
Expand Down
Loading

0 comments on commit 326e738

Please sign in to comment.