Merged changes from master

This commit is contained in:
Daniel Eichhorn
2017-07-09 18:28:40 +02:00
3 changed files with 65 additions and 51 deletions

View File

@@ -9,28 +9,43 @@ Since it was sometimes complicated to find the right parts I created a kit which
https://blog.squix.org/product/esp8266-wifi-color-display-kit-2-4 https://blog.squix.org/product/esp8266-wifi-color-display-kit-2-4
By buying the kit from me you are supporting future development. Thank you! By buying the kit from me you are supporting future development. Thank you!
[![Squix ESP8266 Color Display Kit](resources/ESP8266ColorDisplayKit.png)](https://blog.squix.org/product/esp8266-wifi-color-display-kit-2-4)
## Software Requirements/ Libraries ## Software Requirements/ Libraries
* Mini Grafx by Daniel Eichhorn
* Arduino IDE with ESP8266 platform installed * ESP8266 WeatherStation by Daniel Eichhorn
* [Weather Station Library](https://github.com/squix78/esp8266-weather-station) or through Library Manager * Json Streaming Parser by Daniel Eichhorn
* [Adafruit ILI9341](https://github.com/adafruit/Adafruit_ILI9341) or through Library Manager * simpleDSTadjust by neptune2
* [Adafruit GFX](https://github.com/adafruit/Adafruit-GFX-Library) or through Library Manager
* [WifiManager](https://github.com/tzapu/WiFiManager)
You also need to get an API key for the Wunderground data: https://www.wunderground.com/ You also need to get an API key for the Wunderground data: https://www.wunderground.com/
## Settings
Please have a good look at the settings.h file. There you can:
* set your location for the weather information
* Set the clock mode: 12hour (am/pm) or 24hour mode
* Metric system for temperature
* Timezone and daytime saving options
* API key for the wunderground service
## Wiring ## Wiring
| ILI9341 | NodeMCU | ![Wiring](resources/PlaneSpotterWiring.png)
| Wemos D1 Mini | ILI9341 |
| ------------- |:-------------:| | ------------- |:-------------:|
| MISO | - | | D4 | T_IRQ |
| LED | 3V3 | | D6 | T_DO |
| SCK | D5 | | D7 | T_DIN |
| MOSI | D7 | | D3 | T_CS |
| DC/RS | D4 | | D5 | T_CLK |
| RESET | RST | | D6 | SDO |
| CS | D2 | | D8 | LED |
| D5 | SCK |
| D7 | SDI |
| D2 | D/C |
| RST | RESET |
| D1 | CS |
| GND | GND | | GND | GND |
| VCC | 3V3 | | 3V3 | VCC |

View File

@@ -72,8 +72,9 @@ int BITS_PER_PIXEL = 2; // 2^2 = 4 colors
ADC_MODE(ADC_VCC); ADC_MODE(ADC_VCC);
// HOSTNAME for OTA update #include "ArialRounded.h"
#define HOSTNAME "ESP8266-OTA-" #include "moonphases.h"
#include "weathericons.h"
ILI9341_SPI tft = ILI9341_SPI(TFT_CS, TFT_DC); ILI9341_SPI tft = ILI9341_SPI(TFT_CS, TFT_DC);
@@ -152,14 +153,14 @@ void setup() {
} }
touchController.saveCalibration(); touchController.saveCalibration();
} }
gfx.fillBuffer(MINI_BLACK); gfx.fillBuffer(MINI_BLACK);
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
gfx.setColor(MINI_YELLOW); gfx.setColor(MINI_YELLOW);
gfx.setTextAlignment(TEXT_ALIGN_CENTER); gfx.setTextAlignment(TEXT_ALIGN_CENTER);
gfx.drawString(120, 160, "Connecting to WiFi"); gfx.drawString(120, 160, "Connecting to WiFi");
gfx.commit(); gfx.commit();
carousel.setFrames(frames, frameCount); carousel.setFrames(frames, frameCount);
carousel.disableAllIndicators(); carousel.disableAllIndicators();
@@ -185,7 +186,7 @@ void loop() {
screen = (screen + 1) % screenCount; screen = (screen + 1) % screenCount;
} }
} }
gfx.fillBuffer(MINI_BLACK); gfx.fillBuffer(MINI_BLACK);
if (screen == 0) { if (screen == 0) {
drawTime(); drawTime();
@@ -209,9 +210,9 @@ void loop() {
} }
gfx.commit(); gfx.commit();
// Check if we should update weather information // Check if we should update weather information
if (millis() - lastDownloadUpdate > 1000 * UPDATE_INTERVAL_SECS) { if (millis() - lastDownloadUpdate > 1000 * UPDATE_INTERVAL_SECS) {
updateData(); updateData();
@@ -221,25 +222,25 @@ void loop() {
// Update the internet based information and update screen // Update the internet based information and update screen
void updateData() { void updateData() {
gfx.fillBuffer(MINI_BLACK); gfx.fillBuffer(MINI_BLACK);
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
drawProgress(10, "Updating time..."); drawProgress(10, "Updating time...");
configTime(UTC_OFFSET * 3600, 0, NTP_SERVERS); configTime(UTC_OFFSET * 3600, 0, NTP_SERVERS);
drawProgress(50, "Updating conditions..."); drawProgress(50, "Updating conditions...");
WundergroundConditions *conditionsClient = new WundergroundConditions(IS_METRIC); WundergroundConditions *conditionsClient = new WundergroundConditions(IS_METRIC);
conditionsClient->updateConditions(&conditions, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY); conditionsClient->updateConditions(&conditions, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY);
delete conditionsClient; delete conditionsClient;
conditionsClient = nullptr; conditionsClient = nullptr;
drawProgress(70, "Updating forecasts..."); drawProgress(70, "Updating forecasts...");
WundergroundForecast *forecastClient = new WundergroundForecast(IS_METRIC); WundergroundForecast *forecastClient = new WundergroundForecast(IS_METRIC);
forecastClient->updateForecast(forecasts, MAX_FORECASTS, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY); forecastClient->updateForecast(forecasts, MAX_FORECASTS, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY);
delete forecastClient; delete forecastClient;
forecastClient = nullptr; forecastClient = nullptr;
drawProgress(80, "Updating astronomy..."); drawProgress(80, "Updating astronomy...");
WundergroundAstronomy *astronomyClient = new WundergroundAstronomy(IS_STYLE_12HR); WundergroundAstronomy *astronomyClient = new WundergroundAstronomy(IS_STYLE_12HR);
astronomyClient->updateAstronomy(&astronomy, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY); astronomyClient->updateAstronomy(&astronomy, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY);
@@ -252,7 +253,7 @@ void updateData() {
alertClient->updateAlerts(alerts, MAX_ALERTS, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY); alertClient->updateAlerts(alerts, MAX_ALERTS, WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY);
delete alertClient; delete alertClient;
alertClient = nullptr; alertClient = nullptr;
delay(1000); delay(1000);
} }
@@ -261,7 +262,7 @@ void updateData() {
// Progress bar helper // Progress bar helper
void drawProgress(uint8_t percentage, String text) { void drawProgress(uint8_t percentage, String text) {
gfx.fillBuffer(MINI_BLACK); gfx.fillBuffer(MINI_BLACK);
gfx.drawPalettedBitmapFromPgm(23, 30, SquixLogo); gfx.drawPalettedBitmapFromPgm(23, 30, SquixLogo);
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
gfx.setTextAlignment(TEXT_ALIGN_CENTER); gfx.setTextAlignment(TEXT_ALIGN_CENTER);
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
@@ -284,16 +285,16 @@ void drawTime() {
char time_str[11]; char time_str[11];
time_t now = dstAdjusted.time(&dstAbbrev); time_t now = dstAdjusted.time(&dstAbbrev);
struct tm * timeinfo = localtime (&now); struct tm * timeinfo = localtime (&now);
gfx.setTextAlignment(TEXT_ALIGN_CENTER); gfx.setTextAlignment(TEXT_ALIGN_CENTER);
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
String date = ctime(&now); String date = ctime(&now);
date = date.substring(0,11) + String(1900 + timeinfo->tm_year); date = date.substring(0,11) + String(1900 + timeinfo->tm_year);
gfx.drawString(120, 6, date); gfx.drawString(120, 6, date);
gfx.setFont(ArialRoundedMTBold_36); gfx.setFont(ArialRoundedMTBold_36);
if (IS_STYLE_12HR) { if (IS_STYLE_12HR) {
int hour = (timeinfo->tm_hour+11)%12+1; // take care of noon and midnight int hour = (timeinfo->tm_hour+11)%12+1; // take care of noon and midnight
sprintf(time_str, "%2d:%02d:%02d\n",hour, timeinfo->tm_min, timeinfo->tm_sec); sprintf(time_str, "%2d:%02d:%02d\n",hour, timeinfo->tm_min, timeinfo->tm_sec);
@@ -352,7 +353,7 @@ void drawForecast1(MiniGrafx *display, CarouselState* state, int16_t x, int16_t
void drawForecast2(MiniGrafx *display, CarouselState* state, int16_t x, int16_t y) { void drawForecast2(MiniGrafx *display, CarouselState* state, int16_t x, int16_t y) {
drawForecastDetail(x + 10, y + 165, 6); drawForecastDetail(x + 10, y + 165, 6);
drawForecastDetail(x + 95, y + 165, 8); drawForecastDetail(x + 95, y + 165, 8);
drawForecastDetail(x + 180, y + 165, 10); drawForecastDetail(x + 180, y + 165, 10);
} }
@@ -375,17 +376,17 @@ void drawForecastDetail(uint16_t x, uint16_t y, uint8_t dayIndex) {
// draw moonphase and sunrise/set and moonrise/set // draw moonphase and sunrise/set and moonrise/set
void drawAstronomy() { void drawAstronomy() {
gfx.setFont(MoonPhases_Regular_36); gfx.setFont(MoonPhases_Regular_36);
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
gfx.setTextAlignment(TEXT_ALIGN_CENTER); gfx.setTextAlignment(TEXT_ALIGN_CENTER);
gfx.drawString(120, 275, moonAgeImage); gfx.drawString(120, 275, moonAgeImage);
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
gfx.setTextAlignment(TEXT_ALIGN_CENTER); gfx.setTextAlignment(TEXT_ALIGN_CENTER);
gfx.setColor(MINI_YELLOW); gfx.setColor(MINI_YELLOW);
gfx.drawString(120, 250, astronomy.moonPhase); gfx.drawString(120, 250, astronomy.moonPhase);
gfx.setTextAlignment(TEXT_ALIGN_LEFT); gfx.setTextAlignment(TEXT_ALIGN_LEFT);
gfx.setColor(MINI_YELLOW); gfx.setColor(MINI_YELLOW);
gfx.drawString(5, 250, "Sun"); gfx.drawString(5, 250, "Sun");
@@ -399,11 +400,11 @@ void drawAstronomy() {
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
gfx.drawString(235, 276, astronomy.moonriseTime); gfx.drawString(235, 276, astronomy.moonriseTime);
gfx.drawString(235, 291, astronomy.moonsetTime); gfx.drawString(235, 291, astronomy.moonsetTime);
} }
void drawAlert() { void drawAlert() {
} }
void drawCurrentWeatherDetail() { void drawCurrentWeatherDetail() {
@@ -464,10 +465,10 @@ void drawForecastTable(uint8_t start) {
break; break;
} }
gfx.drawPalettedBitmapFromPgm(0, y, getMiniMeteoconIconFromProgmem(forecasts[i].forecastIcon)); gfx.drawPalettedBitmapFromPgm(0, y, getMiniMeteoconIconFromProgmem(forecasts[i].forecastIcon));
gfx.setColor(MINI_YELLOW); gfx.setColor(MINI_YELLOW);
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
gfx.drawString(50, y, forecasts[i].forecastTitle); gfx.drawString(50, y, forecasts[i].forecastTitle);
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
gfx.drawString(50, y + 15, getShortText(forecasts[i].forecastIcon)); gfx.drawString(50, y + 15, getShortText(forecasts[i].forecastIcon));
@@ -483,23 +484,23 @@ void drawForecastTable(uint8_t start) {
gfx.drawString(235, y, temp + degreeSign); gfx.drawString(235, y, temp + degreeSign);
/*gfx.setColor(MINI_WHITE); /*gfx.setColor(MINI_WHITE);
gfx.drawString(x + 25, y, forecasts[dayIndex].forecastLowTemp + "|" + forecasts[dayIndex].forecastHighTemp); gfx.drawString(x + 25, y, forecasts[dayIndex].forecastLowTemp + "|" + forecasts[dayIndex].forecastHighTemp);
gfx.drawPalettedBitmapFromPgm(x, y + 15, getMiniMeteoconIconFromProgmem(forecasts[dayIndex].forecastIcon));*/ gfx.drawPalettedBitmapFromPgm(x, y + 15, getMiniMeteoconIconFromProgmem(forecasts[dayIndex].forecastIcon));*/
gfx.setColor(MINI_BLUE); gfx.setColor(MINI_BLUE);
gfx.drawString(235, y + 15, forecasts[i].PoP + "%"); gfx.drawString(235, y + 15, forecasts[i].PoP + "%");
} }
} }
void drawAbout() { void drawAbout() {
gfx.fillBuffer(MINI_BLACK); gfx.fillBuffer(MINI_BLACK);
gfx.drawPalettedBitmapFromPgm(23, 30, SquixLogo); gfx.drawPalettedBitmapFromPgm(23, 30, SquixLogo);
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
gfx.setTextAlignment(TEXT_ALIGN_CENTER); gfx.setTextAlignment(TEXT_ALIGN_CENTER);
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
gfx.drawString(120, 80, "https://blog.squix.org"); gfx.drawString(120, 80, "https://blog.squix.org");
gfx.setFont(ArialRoundedMTBold_14); gfx.setFont(ArialRoundedMTBold_14);
gfx.setTextAlignment(TEXT_ALIGN_CENTER); gfx.setTextAlignment(TEXT_ALIGN_CENTER);
gfx.setColor(MINI_WHITE); gfx.setColor(MINI_WHITE);
@@ -519,7 +520,7 @@ void calibrationCallback(int16_t x, int16_t y) {
// Helper function, should be part of the weather station library and should disappear soon // Helper function, should be part of the weather station library and should disappear soon
const char* getMeteoconIconFromProgmem(String iconText) { const char* getMeteoconIconFromProgmem(String iconText) {
if (iconText == "chanceflurries") return chanceflurries; if (iconText == "chanceflurries") return chanceflurries;
if (iconText == "chancerain") return chancerain; if (iconText == "chancerain") return chancerain;
if (iconText == "chancesleet") return chancesleet; if (iconText == "chancesleet") return chancesleet;
@@ -563,13 +564,13 @@ const char* getMiniMeteoconIconFromProgmem(String iconText) {
if (iconText == "snow") return minisnow; if (iconText == "snow") return minisnow;
if (iconText == "sunny") return minisunny; if (iconText == "sunny") return minisunny;
if (iconText == "tstorms") return minitstorms; if (iconText == "tstorms") return minitstorms;
return miniunknown; return miniunknown;
} }
// Helper function, should be part of the weather station library and should disappear soon // Helper function, should be part of the weather station library and should disappear soon
const String getShortText(String iconText) { const String getShortText(String iconText) {
if (iconText == "chanceflurries") return "Chance of Flurries"; if (iconText == "chanceflurries") return "Chance of Flurries";
if (iconText == "chancerain") return "Chance of Rain"; if (iconText == "chancerain") return "Chance of Rain";
if (iconText == "chancesleet") return "Chance of Sleet"; if (iconText == "chancesleet") return "Chance of Sleet";
@@ -589,9 +590,7 @@ const String getShortText(String iconText) {
if (iconText == "snow") return "Snow"; if (iconText == "snow") return "Snow";
if (iconText == "sunny") return "Sunny"; if (iconText == "sunny") return "Sunny";
if (iconText == "tstorms") return "Storms"; if (iconText == "tstorms") return "Storms";
return "-"; return "-";
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB