Update weather station example

Corrected jpeg render fn to handle any width image
Minor tweaks
Remove version number from sketch name, put in settings.h
This commit is contained in:
Bodmer
2018-04-23 20:05:50 +01:00
parent 54b3f0f63d
commit 235887d860
9 changed files with 38 additions and 24 deletions

View File

@@ -22,7 +22,7 @@ See more at http://blog.squix.ch
// In case of problems make sure that you are using the font file with the correct version! // In case of problems make sure that you are using the font file with the correct version!
// Bodmer fix: End character is 0x7D not 0x7E, so bug in last line of the file corrected // Bodmer fix: End character is 0x7D not 0x7E, so bug in last line of the file corrected
// this avoids screen corruption if ~ is printer // this avoids screen corruption if ~ is printed
// Bodmer change: '`' changed to tiny degree symbol (typically this character is on top left key of a QWERTY keyboard) // Bodmer change: '`' changed to tiny degree symbol (typically this character is on top left key of a QWERTY keyboard)

View File

@@ -275,30 +275,35 @@ void GfxUi::jpegRender(int xpos, int ypos) {
int mcu_x = JpegDec.MCUx * mcu_w + xpos; int mcu_x = JpegDec.MCUx * mcu_w + xpos;
int mcu_y = JpegDec.MCUy * mcu_h + ypos; int mcu_y = JpegDec.MCUy * mcu_h + ypos;
// check if the image block size needs to be changed for the right and bottom edges // check if the image block size needs to be changed for the right edge
if (mcu_x + mcu_w <= max_x) win_w = mcu_w; if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
else win_w = min_w; else win_w = min_w;
// check if the image block size needs to be changed for the bottom edge
if (mcu_y + mcu_h <= max_y) win_h = mcu_h; if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
else win_h = min_h; else win_h = min_h;
// calculate how many pixels must be drawn // copy pixels into a contiguous block
uint32_t mcu_pixels = win_w * win_h; if (win_w != mcu_w)
{
uint16_t *cImg;
int p = 0;
cImg = pImg + win_w;
for (int h = 1; h < win_h; h++)
{
p += mcu_w;
for (int w = 0; w < win_w; w++)
{
*cImg = *(pImg + w + p);
cImg++;
}
}
}
// draw image MCU block only if it will fit on the screen // draw image MCU block only if it will fit on the screen
if ( ( mcu_x + win_w) <= _tft->width() && ( mcu_y + win_h) <= _tft->height()) if ( ( mcu_x + win_w) <= _tft->width() && ( mcu_y + win_h) <= _tft->height())
{ {
#ifdef USE_SPI_BUFFER _tft->pushImage(mcu_x, mcu_y, win_w, win_h, pImg);
// Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
_tft->setWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
// Write all MCU pixels to the TFT window
uint8_t *pImg8 = (uint8_t*)pImg; // Convert 16 bit pointer to an 8 bit pointer
_tft->pushColors(pImg8, mcu_pixels*2); // Send bytes via 64 byte SPI port buffer
#else
// Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
_tft->setAddrWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
// Write all MCU pixels to the TFT window
while (mcu_pixels--) _tft->pushColor(*pImg++);
#endif
} }
else if ( ( mcu_y + win_h) >= _tft->height()) JpegDec.abort(); else if ( ( mcu_y + win_h) >= _tft->height()) JpegDec.abort();

View File

@@ -18,22 +18,30 @@ SOFTWARE.
See more at http://blog.squix.ch See more at http://blog.squix.ch
Adapted by Bodmer to use the faster TFT_ILI9341_ESP library: Adapted by Bodmer to use the faster TFT_ILI9341_ESP library:
https://github.com/Bodmer/TFT_ILI9341_ESP https://github.com/Bodmer/TFT_eSPI
Version 9
*/ */
// ***************************************************************************************
// WARNING - READ THIS
//
// 3M Flash Size MUST be allocated to SPIFFS using the IDE Tools menu option or else the
// ESP8266 may crash or do strange things (due to lack of error checks in SPIFFS library?)
// ***************************************************************************************
//
// Setup // Setup
const int UPDATE_INTERVAL_SECS = 10 * 60; // Update every 10 minutes const int UPDATE_INTERVAL_SECS = 10 * 60; // Update every 10 minutes
// Pins for the TFT interface are defined in the User_Config.h file inside the TFT_ILI9341_ESP library // Pins for the TFT interface are defined in the User_Config.h file inside the TFT_eSPI library
// TimeClient settings // TimeClient settings
const float UTC_OFFSET = 1; const float UTC_OFFSET = 1;
// Wunderground Settings, EDIT TO SUIT YOUR LOCATION // Wunderground Settings, EDIT to suit your Wunderground key and location
const boolean IS_METRIC = true; // Temperature only? Wind speed units appear to stay in mph. To do: investigate <<<<<<<<<<<<<<<<<<<<<<<<< const boolean IS_METRIC = true; // Temperature only? Wind speed units appear to stay in mph. To do: investigate <<<<<<<<<<<<<<<<<<<<<<<<<
const String WUNDERGRROUND_API_KEY = "<WUNDERGROUND KEY HERE>"; //const String WUNDERGRROUND_API_KEY = "WUNDERGROUND KEY HERE";
//const String WUNDERGRROUND_API_KEY = "1c265fajf48s0a82"; // Random key example showing how the above line should look const String WUNDERGRROUND_API_KEY = "1c265fajf48s0a82"; // Random key example showing how the above line should look
// For language codes see https://www.wunderground.com/weather/api/d/docs?d=language-support&_ga=1.55148395.1951311424.1484425551 // For language codes see https://www.wunderground.com/weather/api/d/docs?d=language-support&_ga=1.55148395.1951311424.1484425551
const String WUNDERGRROUND_LANGUAGE = "EN"; // Language EN = English const String WUNDERGRROUND_LANGUAGE = "EN"; // Language EN = English
@@ -53,8 +61,8 @@ const String WUNDERGROUND_CITY = "Base_Naval"; // City, "London", "FL/Boca_Raton
#define WIND_SPEED_UNITS " kph" #define WIND_SPEED_UNITS " kph"
//Thingspeak Settings - not used, no need to populate this at the moment //Thingspeak Settings - not used, no need to populate this at the moment
const String THINGSPEAK_CHANNEL_ID = "<CHANNEL_ID_HERE>"; const String THINGSPEAK_CHANNEL_ID = "CHANNEL_ID_HERE";
const String THINGSPEAK_API_READ_KEY = "<API_READ_KEY_HERE>"; const String THINGSPEAK_API_READ_KEY = "API_READ_KEY_HERE";
// List, so that the downloader knows what to fetch // List, so that the downloader knows what to fetch
String wundergroundIcons [] = {"chanceflurries","chancerain","chancesleet","chancesnow","clear","cloudy","flurries","fog","hazy","mostlycloudy","mostlysunny","partlycloudy","partlysunny","rain","sleet","snow","sunny","tstorms","unknown"}; String wundergroundIcons [] = {"chanceflurries","chancerain","chancesleet","chancesnow","clear","cloudy","flurries","fog","hazy","mostlycloudy","mostlysunny","partlycloudy","partlysunny","rain","sleet","snow","sunny","tstorms","unknown"};

View File

@@ -30,6 +30,7 @@
New smart WU splash startup screen and updated progress messages New smart WU splash startup screen and updated progress messages
Display does not need to be blanked between updates Display does not need to be blanked between updates
Icons nudged about slightly to add wind direction + speed Icons nudged about slightly to add wind direction + speed
Barometric pressure added
*/ */
#define SERIAL_MESSAGES #define SERIAL_MESSAGES