Among other things, I made them a weather station and save the code for each good operation and make a folder which library I use. Now I have bought a new display (S3) and want to use the working code, but again after an update I get the most strange messages while this code that is present on the same display just works. So the code is good. How is this possible?
I'm using the ESP32-8048S070
Get a status 1 message.
And get error messages from the original library that came with the display and has always worked.
/*******************************************************************************
******************************************************************************/
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
#define TFT_BL 2
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
//Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
//Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
Arduino_ESP32RGBPanel *bus = new Arduino_ESP32RGBPanel(
GFX_NOT_DEFINED /* CS */, GFX_NOT_DEFINED /* SCK */, GFX_NOT_DEFINED /* SDA */,
41 /* DE */, 40 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
14 /* R0 */, 21 /* R1 */, 47 /* R2 */, 48 /* R3 */, 45 /* R4 */,
9 /* G0 */, 46 /* G1 */, 3 /* G2 */, 8 /* G3 */, 16 /* G4 */, 1 /* G5 */,
15 /* B0 */, 7 /* B1 */, 6 /* B2 */, 5 /* B3 */, 4 /* B4 */
);
// option 1:
// 7寸 50PIN 800*480
Arduino_RPi_DPI_RGBPanel *gfx = new Arduino_RPi_DPI_RGBPanel(
bus,
// 800 /* width */, 0 /* hsync_polarity */, 8/* hsync_front_porch */, 2 /* hsync_pulse_width */, 43/* hsync_back_porch */,
// 480 /* height */, 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 2/* vsync_pulse_width */, 12 /* vsync_back_porch */,
// 1 /* pclk_active_neg */, 16000000 /* prefer_speed */, true /* auto_flush */);
800 /* width */, 0 /* hsync_polarity */, 210 /* hsync_front_porch */, 30 /* hsync_pulse_width */, 16 /* hsync_back_porch */,
480 /* height */, 0 /* vsync_polarity */, 22 /* vsync_front_porch */, 13 /* vsync_pulse_width */, 10 /* vsync_back_porch */,
1 /* pclk_active_neg */, 16000000 /* prefer_speed */, true /* auto_flush */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
//----------------
#include <WiFi.h>
#include <HTTPClient.h>
#include <WiFiClient.h>
#include <Arduino_JSON.h>
//fonts declare
//#include "FreeMono8pt7b.h"
/* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */
//https://oleddisplay.squix.ch/
//Kies lib version
//#include "Orbitron_Medium_12.h"
#include "fonts/Luckiest_Guy_Regular_18.h"
#include "fonts/Luckiest_Guy_Regular_24.h"
#include "fonts/Luckiest_Guy_Regular_26.h"
#include "fonts/Luckiest_Guy_Regular_28.h"
//#include "Montez_Regular_32.h"
#include "fonts/Dialog_plain_7.h"
#include "fonts/Dialog_plain_9.h"
#include "fonts/Dialog_plain_18.h"
#include "fonts/Dialog_plain_24.h"
#include "fonts/Dialog_bold_24.h"
#include "fonts/DialogInput_plain_32.h"
#include "fonts/Dialog_bold_32.h"
#include "fonts/Dialog_bold_40.h"
//#include "FreeSansBold10pt7b.h"
//#include "FreeSerifBoldItalic12pt7b.h"
#define SCALE0 0xC655 // accent color for unused rainbow scale segments
#define SCALE1 0x5DEE // accent color for unused rainbow scale segments
#define SCALE2 0x10CE // blue used as fill in baro panel
// #define RED2RED 0 // rainbow scale ring meter color scheme
// #define GREEN2GREEN 1
// #define BLUE2BLUE 2
// #define BLUE2RED 3
#define GREEN2RED 4
// #define RED2GREEN 5
#define DEG2RAD 0.0174532925
const char* ssid = "xxx"; // your wifi SSID here
const char* password = "xxxx";
// const char* ssid = "xxxxx"; // your wifi SSID here
// const char* password = "xxx"; // your wifi password here
String openWeatherMapApiKey = "xxxx"; // your OpenWeatherMap APIkey here
String city = "Eindhoven"; // replace with your city's name
String countryCode = "NL"; // replace with your country identification
String jsonBuffer;
String jsonDocument (1024);
// THE DEFAULT TIMER IS SET TO 10 SECONDS FOR TESTING PURPOSES
// for a final application, check the API call limits per hour/minute to avoid getting blocked/banned
unsigned long lastTime = 0;
// timer set to 10 minutes (600000)
unsigned long timerDelay = 600000; // currently one initial call and then every ten minutes
// set timer to 30 seconds (30000) // handy during the testing phase of your project
// unsigned long timerDelay = 30000;
//https://javl.github.io/image2cpp/
// 'OIP', 144x150px
const unsigned char epd_bitmap_OIP [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x80, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xc0, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x60, 0x00, 0x07, 0xe0, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x00, 0x1f, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x18, 0x00,
0x3c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0x8c, 0x00, 0x70, 0x1c, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3f, 0xc7, 0x00, 0xc0, 0x06, 0x08, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3f, 0xe1, 0x83, 0x80, 0x03, 0x04, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0xe3, 0x00, 0x01, 0x06, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xf8, 0x7e, 0x00, 0x01, 0x82, 0x0c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0xfe, 0x1e, 0x00, 0x00, 0x62, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xff, 0x0f, 0xe0, 0x00,
0x33, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xff, 0x83,
0x9c, 0x00, 0x10, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
0xff, 0xc1, 0xc7, 0x00, 0x10, 0x61, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0d, 0xff, 0xe0, 0xe1, 0x80, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0xff, 0xf0, 0x60, 0x40, 0x00, 0x10, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0xf8, 0x30, 0xe0, 0x00, 0x08, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x7f, 0xfc, 0x13, 0x00, 0x18, 0x08, 0xa0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x3f, 0xfe, 0x1e, 0x00, 0x07, 0x08,
0xa0, 0x03, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x9f, 0xff, 0x0c, 0x00,
0x01, 0xcc, 0x1f, 0xff, 0xc0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x8f, 0xff,
0x08, 0x1f, 0x00, 0x66, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x30,
0xcf, 0xff, 0x00, 0x27, 0xe0, 0x22, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x98, 0xc3, 0xff, 0x80, 0x0f, 0xf8, 0x32, 0x0e, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0xfe, 0x61, 0xff, 0x80, 0x0d, 0xfe, 0x12, 0x01, 0x1f, 0xfe, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x30, 0xff, 0x80, 0x0f, 0xff, 0x92, 0xc0, 0xff, 0xfc, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x3f, 0x80, 0xff, 0x8f, 0xc2, 0x80, 0x7f,
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x1c, 0x0f, 0x81, 0xde, 0x0f, 0xbb,
0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xbf, 0xe7, 0x03, 0x80, 0x1f,
0x87, 0xf7, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x05, 0x80,
0x00, 0x0f, 0xff, 0xf1, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
0x18, 0xc0, 0x00, 0x0f, 0xff, 0xf1, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x30, 0x5f, 0xe1, 0xb0, 0x00, 0x07, 0xff, 0xff, 0xc1, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xe0, 0x01, 0x00, 0x00, 0x03, 0xef, 0xc0, 0xf1, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0xf8, 0x02, 0x00, 0x00, 0x01, 0xff, 0xa8, 0x1f, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1f, 0x04, 0x00, 0x00, 0x00, 0x7d, 0x1c, 0x5f, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x03, 0xd8, 0x00, 0x00, 0x00, 0x02, 0x03,
0xbf, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x70, 0x00, 0x00, 0x00,
0x06, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x1c, 0x00,
0x00, 0x00, 0x0c, 0x48, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3f, 0xfc,
0x06, 0x00, 0x00, 0x00, 0x18, 0x48, 0x08, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0xe0, 0x07, 0x81, 0x80, 0x00, 0x00, 0x7b, 0xf8, 0x08, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xe0, 0x3d, 0x08, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x30, 0x60, 0x00, 0x03, 0x80, 0x07, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x01, 0xfe, 0x0c, 0x30, 0x00, 0x0f, 0x00, 0x0b, 0xf8, 0x30,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0f, 0x03, 0x86, 0x10, 0x00, 0x3c, 0x00, 0x10,
0x30, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x38, 0x00, 0x63, 0x08, 0x00, 0xf0,
0x00, 0x00, 0x61, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x60, 0x00, 0x18, 0x8c,
0x07, 0x80, 0x00, 0x01, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0xc0, 0x00,
0x0c, 0xc4, 0x10, 0x00, 0x00, 0x03, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x01,
0x80, 0x00, 0x02, 0x46, 0x00, 0x00, 0x00, 0x0c, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x03, 0x00, 0x00, 0x01, 0x23, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x93, 0xc1, 0x80, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x00, 0x00, 0x00, 0xd3, 0xec, 0x06, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x69, 0xf8, 0x38, 0x0f, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x18, 0x00, 0x00, 0x00, 0x29, 0xf9, 0xe0,
0x1d, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x18, 0x00, 0x00, 0x00, 0x15,
0xfe, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x30, 0x00, 0x00,
0x00, 0x0d, 0xfe, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x30,
0x00, 0x00, 0x00, 0x04, 0xff, 0x1f, 0x08, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x60, 0x00, 0x00, 0x00, 0x06, 0xff, 0xfe, 0x0c, 0x00, 0x06, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x02, 0xff, 0xfe, 0x04, 0x00, 0xcc, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfe, 0x04, 0x01, 0xf0, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x08, 0x06,
0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe,
0x18, 0x0c, 0x40, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xfe, 0x1c, 0x70, 0x40, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00,
0x00, 0x00, 0x1f, 0xfe, 0x26, 0x40, 0x40, 0x60, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80,
0x00, 0x80, 0x00, 0x00, 0x0f, 0xfe, 0x21, 0xc0, 0xe5, 0xc0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x80, 0x00, 0x80, 0x00, 0x00, 0x07, 0xfe, 0x40, 0x4f, 0x6f, 0x80, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0x07, 0xff, 0xe8, 0x39, 0x80, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0x00, 0x7f, 0xf8, 0x39, 0x80,
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x00, 0x00, 0x06, 0x00, 0x00, 0x98,
0x11, 0x80, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x00, 0x00, 0x06, 0x00,
0x01, 0x80, 0x01, 0xb1, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x80, 0x00, 0x00,
0x0c, 0x00, 0x01, 0x00, 0x03, 0xbf, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x80,
0x00, 0x00, 0x18, 0x00, 0x02, 0x00, 0x07, 0xf7, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
0x00, 0xc0, 0x20, 0x00, 0x30, 0x00, 0x06, 0x00, 0x07, 0xf9, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x60, 0x00, 0x04, 0x00, 0x0f, 0xff, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0c, 0x00, 0x00, 0xc0, 0x40, 0x00, 0xc0, 0x00, 0x0e, 0x00, 0x1f, 0xfe, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x20, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x3f, 0xff,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x30, 0x1c, 0x00, 0x00, 0x19, 0xf1,
0xff, 0xff, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x40, 0x07, 0xe0, 0x00, 0x00,
0x10, 0x3f, 0xff, 0xff, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, 0x00, 0x00,
0x00, 0x00, 0x30, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60,
0x00, 0x00, 0x00, 0x00, 0x30, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x7f, 0xff, 0xff, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x38, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0xff, 0xff, 0xa0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0xf0, 0xff, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x41, 0xff, 0x90, 0xfe,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xff,
0x90, 0xfe, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0xc7, 0xf9, 0x31, 0xfc, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x18, 0x00, 0x00,
0x00, 0x00, 0x8f, 0xf1, 0x33, 0xfc, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x1c,
0x00, 0x00, 0x00, 0x01, 0x8f, 0xf3, 0x37, 0xf8, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00,
0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x9f, 0xf2, 0x37, 0xf8, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x60, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x8f, 0xf2, 0x33, 0xf8, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x8f, 0xf2, 0x31, 0xf8, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x0f, 0xfa, 0x30, 0xf0,
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x01, 0x07, 0xfe,
0x30, 0x70, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03,
0x07, 0xfe, 0x30, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x01, 0xc0, 0x00,
0x00, 0x03, 0x07, 0xfc, 0x10, 0x11, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
0xe0, 0x00, 0x00, 0x03, 0x07, 0xfc, 0x10, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x00, 0xf0, 0x00, 0x00, 0x03, 0x07, 0xfe, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x03, 0x07, 0xfe, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x03, 0x0d, 0xfe, 0x18, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x02, 0x0d, 0xfe, 0x18, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x02, 0x0c, 0xfe,
0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x02,
0x1c, 0xfe, 0x08, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0,
0x00, 0x02, 0x1c, 0x7f, 0x08, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x01, 0xf0, 0x00, 0x02, 0x14, 0x7f, 0x8c, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x32, 0x7f, 0xc4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x02, 0x22, 0x3f, 0xe4, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x02, 0x22, 0x3f, 0xbe, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x07, 0xc0, 0x02, 0x62, 0x3f, 0xcf, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x30, 0x00, 0x03, 0xf0, 0x02, 0x62, 0x3f,
0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0xfe, 0x02,
0xe2, 0x3f, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x7f, 0x83, 0xe3, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x78, 0x00,
0x00, 0x00, 0x6f, 0xe3, 0xe1, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc6, 0x00, 0x1f,
0xc0, 0x00, 0x00, 0x00, 0xc1, 0xff, 0x61, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff,
0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3e, 0x61, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x04, 0x61, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x61, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x61, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
0x41, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x00, 0x41, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00,
0x00, 0x0c, 0x00, 0x00, 0x43, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0xe0, 0x00, 0x00, 0x18, 0x00, 0x00, 0x43, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x07, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x47, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0x47, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0xc8, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x60, 0x02, 0x00, 0x4f, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x60, 0x02, 0x00, 0x4f, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x02, 0x00,
0x4f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80,
0x02, 0x00, 0x4f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x02, 0x00, 0x4f, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x02, 0x00, 0x5f, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x02, 0x00, 0x5f, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, 0x00, 0x5f, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x02, 0x00, 0x5f, 0xc2, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x02, 0x00, 0x5f, 0xc3,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x02, 0x00,
0x1f, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00,
0x03, 0xff, 0xff, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
0x00, 0x00, 0x02, 0x00, 0x1f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x00,
0x00, 0x3f, 0xff, 0x00, 0x1e, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe,
0x00, 0x00, 0x03, 0xe0, 0x1f, 0xff, 0x80, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
};
int delayTime = 500;
// joint variables
float temp_01=10;
float hum_01;
int hum_02;
int press_02 = 960; // necessary for initial dynamic baro panel
float w_speed_01;
float w_speed_02;
float press_01;
float weather_01;
// rainbow scale ring meter variables
uint32_t runTime = -99999; // time for next update
int reading = 10; // value to be displayed in circular scale
int tesmod = 0;
int r_gauge_pos_x = 420 ; // these two variables govern the position ====> Nieuwe pos tbv 7"
int r_gauge_pos_y = 10; // of the square + gauge on the display
//org int r_gauge_pos_x; // these two variables govern the position
//org int r_gauge_pos_y; // of the square + gauge on the display
int ringmeter_radius = 150; // governs diameter of rainbow gauge
//org int ringmeter_radius = 65;
char* ringlabel[] = {"","*C","%","mBar"};
// some custom labels
float temp_rainbowgauge;
int t;
// x-position of numeric in rainbow scale center // governs position of numerical output rainbow scale
// small needle humidity meter
int j;
float center_x1; // center x of edge markers humidity gauge
float center_y1; // center y of edge markers humidity gauge
int radius_s = 135; // for scale markers
int needle_length = 120; // gauge needle length
int edgemarkerLength = 5; // edge marker length
float edge_x1, edge_y1, edge_x1_out, edge_y1_out;
float angle_needle = 0;
float needle_x, needle_y;
float needle_x_old, needle_y_old;
float angle_circle = 0;
int pivot_x; // pivot coordinates needle of small gauge hum panel
int pivot_y;
int static_num_panel_x;
int static_num_panel_y;
int baro_panel_x;
int baro_panel_y;
float barval;
int p1_x, p1_y, p1_x_old, p1_y_old; // barometer panel polygon points
int p2_x, p2_y, p2_x_old, p2_y_old;
int p3_x, p3_y, p3_x_old, p3_y_old;
int p4_x, p4_y, p4_x_old, p4_y_old;
float compassPivot_x; // wind compass direction pointer
float compassPivot_y;
float c_x1, c_x2,c_x3, c_x4;
float c_y1, c_y2,c_y3, c_y4;
float c_x1_old,c_x2_old,c_x3_old, c_x4_old;
float c_y1_old,c_y2_old,c_y3_old, c_y4_old;
float wind_dir_01;
int wind_dir_02;
float compass_angle;
int compass_r = 22;
char* sector [] = {"Noord", "Noord-Oost", "Oost", "Zuid-Oost", "Zuid", "Zuid-West", "West", "Noord-West"}; // wind sector labels
int h;
float max_temp_today; // mini max temp panel
float min_temp_today;
int minmax_panel_x;
int minmax_panel_y;
int t_meter_increase;
int t_meter_increase_old;
// TBV BEGIN POS KADERS
int kader_x;
int kader_y;
//------------------------------------------------------------------------
void setup(void)
{
//-------------------------------------------
Serial.begin(115200);
WiFi.begin (ssid, password);
Serial.println ("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(5000);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
Serial.println("Timer set to 10 seconds (timerDelay variable), it will take 10 seconds before publishing the first reading.");
//---------------------------------------------
gfx->begin();
gfx->fillScreen(BLACK);
#ifdef TFT_BL
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
#endif
draw_all_panel_frames ();
title_panel_text();
static_data_in_numeric_window ();
rainbowScaleMeter ();
static_data_in_rainbow_panel ();
humidity_static ();
build_dynamic_baropanel (); // to start dynamic baropanel
static_minmax_panel ();
compassGauge ();
Serial.println ("First run to get data. Next update according to timerDelay");
Serial.println ();
Serial.println ();
run_the_weatherstation (); // we do this here once to get the station up and running. next update: see timerDelay
}
void loop()
{
if ((millis() - lastTime) > timerDelay) // check WiFi connection status
{
if(WiFi.status()== WL_CONNECTED)
{
run_the_weatherstation ();
}
else
{
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
delay(10000);
gfx->drawBitmap(635, 325, epd_bitmap_OIP, 144, 150, CYAN); //x,y, naam, grote
}
// ######################################################################################
// # functions section #
// ######################################################################################
// ######################################################################################
// # static - draw all panel frames #
// ######################################################################################
void draw_all_panel_frames (){
// baro_panel_x = 162;
// baro_panel_y = 156;
baro_panel_x = 476; //extra tbv positie
baro_panel_y = 322;
minmax_panel_x = 242;
minmax_panel_y = 478;
kader_x = 3;
kader_y = 3 ;
gfx->drawRoundRect(kader_x, kader_y, 412, 38, 4, GREEN); // title panel frame m TEXT KOP
gfx->drawRoundRect ( kader_x, kader_y+40 , 412, 277, 4, GREEN); // left upper big panel frame / VERZAMEL KADER
gfx->drawRoundRect ( kader_x+444, kader_y, 335, 317, 4, GREEN); // right upper big panel frame // TEMP KADER VERZAMELRAINBOW => y= + 330
gfx->drawRoundRect ( 3, 322, 154, 156, 4, GREEN); // extreme left lowerpanel frame => kader WIND y+????
gfx->drawRoundRect ( 161, 322, 154, 156, 4, GREEN); // left-of-middle lower panel frame => HUM
gfx->drawRoundRect (minmax_panel_x+77, 322, 154, 156, 4, GREEN); // extreme right lower window e
gfx->drawRoundRect (476, 322, 154, 156, 4, GREEN); // barpmeter
}
// ######################################################################################
// # static data in the title panel #
// ######################################################################################
//https://github.com/moononournation/Arduino_GFX/blob/master/examples/HelloWorldGfxfont/HelloWorldGfxfont.ino
void title_panel_text(){
gfx->setTextColor (CYAN,BLACK);
gfx->setFont(&Luckiest_Guy_Regular_26);
gfx->setCursor (kader_x+40,kader_y+28);
gfx->print ("WEERONLINE EINDHOVEN");
}
// ######################################################################################
// # static data in the numeric panel #
// ######################################################################################
void static_data_in_numeric_window (){
static_num_panel_x = 20; //x org = 3 y org =3 (KADERS) // all coordinates in this panel relative to these two
static_num_panel_y = 35; // org=+5
gfx->setTextColor (YELLOW,BLACK);
gfx->setFont(&Dialog_bold_32);
gfx->setCursor (static_num_panel_x,static_num_panel_y+45); // basis postie laten staan
gfx->print ("temp");
gfx->setCursor (static_num_panel_x,static_num_panel_y+100); //alles Y+10 ivm grote
gfx->print ("druk");
gfx->setCursor (static_num_panel_x,static_num_panel_y+155);
gfx->print ("vocht");
gfx->setCursor (static_num_panel_x,static_num_panel_y+210);
gfx->print ("wind");
gfx->setCursor (static_num_panel_x,static_num_panel_y+265);
gfx->print ("richting");
//gfx->setTextColor (YELLOW,BLACK);
//gfx->setFreeFont(&FreeSans9pt7b);
gfx->setCursor (static_num_panel_x+310,static_num_panel_y+45); //Y+5 alles X+50 tbv opschuiven naar rechts
gfx->print ("C");
gfx->drawCircle(static_num_panel_x+300,static_num_panel_y+25,4,YELLOW); // degree character
gfx->drawCircle(static_num_panel_x+300,static_num_panel_y+25,5,YELLOW); // char degree character -> werkt alleen bij GFX // degree character
gfx->setCursor (static_num_panel_x+300,static_num_panel_y+100);
gfx->print ("mB");
gfx->setCursor (static_num_panel_x+300,static_num_panel_y+155);
gfx->print ("%");
gfx->setCursor (static_num_panel_x+300,static_num_panel_y+210);
gfx->print ("m/s");
gfx->setFont(0);
}
// ######################################################################################
// # static data in the rainbow scale panel #
// ######################################################################################
void static_data_in_rainbow_panel (){
gfx->setFont(&Dialog_plain_18);
gfx->setCursor (r_gauge_pos_x+45,r_gauge_pos_y+15);
gfx->setTextColor (YELLOW);
gfx->print ("temp");
gfx->drawCircle(r_gauge_pos_x+310,r_gauge_pos_y+5,3,YELLOW); // degree character
gfx->drawCircle(r_gauge_pos_x+310,r_gauge_pos_y+5,4,YELLOW);
gfx->setCursor (r_gauge_pos_x+320,r_gauge_pos_y+20);
gfx->print ("C");
gfx->setCursor (r_gauge_pos_x+145,r_gauge_pos_y+290);
gfx->setFont(&Dialog_plain_24);
gfx->print ("0");
gfx->setCursor (r_gauge_pos_x+230,r_gauge_pos_y+290); // 50 is top rainbow scale temperature
gfx->print ("50");
gfx->setFont(0);
}
// ######################################################################################
// # wind compass - static part #
// ######################################################################################
void compassGauge (){
compassPivot_x = 1; // these coordinates determine the position of wind compass and everything in it /positie aanpassin bij 7"
compassPivot_y = 301;
gfx->drawCircle ((compassPivot_x+80), (compassPivot_y+98), (compass_r+25), BLUE); // outer circle compass ===> centrum posistie van ringen
gfx->drawCircle ((compassPivot_x+80), (compassPivot_y+98), (compass_r+15), CYAN); // inner circle compass - pointer fits in here
gfx->setFont(&Dialog_plain_18);
gfx->setTextColor (WHITE, BLACK);
gfx->setCursor ((compassPivot_x+73), (compassPivot_y+42));
gfx->print ("N");
gfx->setCursor ((compassPivot_x+75), (compassPivot_y+165));
gfx->print ("Z");
gfx->setCursor ((compassPivot_x+133), (compassPivot_y+105));
gfx->print ("O");
gfx->setCursor ((compassPivot_x+10), (compassPivot_y+105));
gfx->print ("W");
gfx->setFont(&Dialog_plain_9);
gfx->setCursor ((compassPivot_x+40), (compassPivot_y+60));
gfx->print ("NW");
gfx->setCursor ((compassPivot_x+110), (compassPivot_y+60));
gfx->print ("NO");
gfx->setCursor ((compassPivot_x+40), (compassPivot_y+140));
gfx->print ("ZW");
gfx->setCursor ((compassPivot_x+110), (compassPivot_y+140));
gfx->print ("ZO");
gfx->setCursor ((compassPivot_x+10), (compassPivot_y+40));
gfx->setTextColor (YELLOW, BLACK);
gfx->setFont(&Dialog_plain_18);
gfx->print ("wind");
gfx->setFont(0);
}
//------------------------------------------
// ######################################################################################
// # wind compass - dynamic wind compass pointer #
// ######################################################################################
void compassPointer (){
compassPivot_x = 40; // these coordinates determine the position of wind compass and everything in it /positie aanpassin bij 7"
compassPivot_y = 360;
gfx->fillTriangle (c_x1_old,c_y1_old,c_x2_old,c_y2_old,c_x4_old,c_y4_old,BLACK); // remove old compass pointer by overwritig in white
gfx->fillTriangle (c_x1_old,c_y1_old,c_x3_old,c_y3_old,c_x4_old,c_y4_old,BLACK); // remove old compass pointer by overwritig in white
compass_angle = ((wind_dir_02-90)*DEG2RAD);
c_x1 = ((compassPivot_x+40) + (compass_r * cos (compass_angle))); // calculate coordinates compass pointer tip
c_y1 = ((compassPivot_y+40) + (compass_r * sin (compass_angle)));
c_x2 = ((compassPivot_x+40) + (compass_r * cos (compass_angle + 163*DEG2RAD))); // calculate coordinates compass pointer base point
c_y2 = ((compassPivot_y+40) + (compass_r * sin (compass_angle + 163*DEG2RAD)));
c_x3 = ((compassPivot_x+40) + (compass_r * cos (compass_angle - 163*DEG2RAD))); // calculate coordinates compass pointer base point
c_y3 = ((compassPivot_y+40) + (compass_r * sin (compass_angle - 163*DEG2RAD)));
c_x4 = ((compassPivot_x+40) + ((compass_r-4) * cos (compass_angle - 180*DEG2RAD))); // calculate coordinates compass pointer base point
c_y4 = ((compassPivot_y+40) + ((compass_r-4) * sin (compass_angle - 180*DEG2RAD)));
c_x1_old = c_x1; c_x2_old = c_x2; c_x3_old = c_x3; c_x4_old = c_x4;
c_y1_old = c_y1; c_y2_old = c_y2; c_y3_old = c_y3; c_y4_old = c_y4;
gfx->fillTriangle (c_x1, c_y1,c_x3, c_y3, c_x4, c_y4, 0x3A72); // print the new pointer to display
gfx->fillTriangle (c_x1, c_y1,c_x2, c_y2, c_x4, c_y4, CYAN); // print the new pointer to display
/*
tft.fillTriangle (c_x2, c_y2 ,c_x3, c_y3-20, c_x4, c_y4, CYAN);
2=rechterhoek, 3=top 4 = linkerhoek
Parameters:
x0:x coordinate of the apex
y0:y coordinate of the apex
x1:x coordinate of the bottom left point
y1:y coordinate of the bottom left point
x2:x coordinate of the bottom right point
y2:y coordinate of the bottom right point
color:the color of the triangle
1
* *
** **
* * * *
* * * *
* * 4 * *
* * * *
* * * *
3 2
*/
}
// ######################################################################################
// # wind sector calculator #
// ######################################################################################
void windSectorReporter (){
h = 0;
if (wind_dir_02 <22.5) h = 0;
if (wind_dir_02> 22.5) h = 1;
if (wind_dir_02> 67.5) h = 2;
if (wind_dir_02>112.5) h = 3;
if (wind_dir_02>157.5) h = 4;
if (wind_dir_02>202.5) h = 5;
if (wind_dir_02>247.5) h = 6;
if (wind_dir_02>292.5) h = 7;
if (wind_dir_02>337.5) h = 8;
}
// ######################################################################################
// # humidity needle meter panel - static part # // in right-of-middle lower window
// ######################################################################################
void humidity_static (){
// these four coordinates determine everything in the humidity meter panel
pivot_x = 167; // pivot coordinates needle of humidity meter -// pivot coordinates needle of small gauge -> punt begin lijn
pivot_y = 468; //165
center_x1 = 164; // center x of edge markers humidity gauge - different from pivot needle!
center_y1 = 470;
needle_x_old = pivot_x; // remember
needle_y_old = pivot_y; // remember
gfx->setFont(&Dialog_plain_18);
gfx->setTextColor (YELLOW, BLACK);
gfx->setCursor ((pivot_x+65), (pivot_y-128)); // display percent sign in small gauge scale
gfx->print ("% vocht");
gfx->fillCircle (pivot_x+2, pivot_y, 4, MAGENTA); // pivot needle middle small gauge // arbitrary seeding temp - avoids drawing black line from position 0.0
// gfx->setFont(&Dialog_plain_9);
gfx->setTextColor (WHITE, BLACK);
gfx->setCursor ((pivot_x),(pivot_y-110));
gfx->print ("100");
gfx->setCursor ((pivot_x+100),(pivot_y-10));
gfx->print ("40"); // scale starts with 40% and ends with 100%
j = 270; // start point of cirle segment
do {
angle_circle = (j* DEG2RAD); // angle expressed in radians - 1 degree = 0,01745331 radians
edge_x1 = (center_x1+4 + (radius_s*cos (angle_circle))); // scale - note the 4 pixels offset in x
edge_y1 = (center_y1 + (radius_s*sin (angle_circle))); // scale
edge_x1_out = (center_x1+4 + ((radius_s+edgemarkerLength)*cos (angle_circle))); // scale - note the 4 pixels offset in x
edge_y1_out = (center_y1 + ((radius_s+edgemarkerLength)*sin (angle_circle))); // scale
gfx->drawLine (edge_x1, edge_y1, edge_x1_out, edge_y1_out,MAGENTA);
j = j+6;
}
while (j<356);
//extra ivm extra weergave
j = 270; // start point of cirle segment
do {
angle_circle = (j* DEG2RAD); // angle expressed in radians - 1 degree = 0,01745331 radians
edge_x1 = (center_x1+4 + (radius_s*cos (angle_circle))); // scale - note the 4 pixels offset in x
edge_y1 = (center_y1 + (radius_s*sin (angle_circle))); // scale
edge_x1_out = (center_x1+5 + ((radius_s+edgemarkerLength)*cos (angle_circle))); // scale - note the 4 pixels offset in x
edge_y1_out = (center_y1+1 + ((radius_s+edgemarkerLength)*sin (angle_circle))); // scale
gfx->drawLine (edge_x1+1, edge_y1, edge_x1_out, edge_y1_out,CYAN); //MAGENTA
j = j+6;
}
while (j<356);
gfx->setFont(0);
//-----------------------------
// end of circle segment
}
// ######################################################################################
// # humidity needle meter - dynamic part = needle movement control #
// ######################################################################################
void needle_meter (){
gfx->drawLine (pivot_x, pivot_y, needle_x_old, needle_y_old, 0); // remove old needle by overwritig in BLACK
angle_needle = (420*DEG2RAD - 1.5*hum_02*DEG2RAD); // contains a 1.5 stretch factor to expand 60 percentage points over 90 degrees of scale
if (angle_needle > 6.28) angle_needle = 6.28; // prevents the needle from ducking below horizontal
needle_x = (pivot_x + ((needle_length)*cos (angle_needle))); // calculate x coordinate needle point
needle_y = (pivot_y + ((needle_length)*sin (angle_needle))); // calculate y coordinate needle point
needle_x_old = needle_x; // remember previous needle position
needle_y_old = needle_y;
// gfx->drawLine (pivot_x, pivot_y, needle_x, needle_y,MAGENTA);
gfx->drawLine (pivot_x, pivot_y, needle_x, needle_y,CYAN); //RED
// gfx->drawLine (pivot_x+3, pivot_y+1, needle_x+1, needle_y+1,CYAN); //RED
gfx->fillCircle (pivot_x, pivot_y, 2, MAGENTA); // restore needle pivot
}
// ######################################################################################
// # static data in the min-max temp panel #
// ######################################################################################
void static_minmax_panel (){
//kader afmeting gfx->drawRoundRect (minmax_panel_x+75, minmax_panel_y-154, 154, 156, 4, GREEN);
gfx->drawRoundRect (minmax_panel_x+90, minmax_panel_y-148, 14, 120, 4, WHITE); // 'thermometer'
gfx->fillCircle (minmax_panel_x+96, minmax_panel_y-20, 13, RED);
gfx->drawCircle (minmax_panel_x+96, minmax_panel_y-20, 14, WHITE);
gfx->setTextColor (YELLOW,BLACK);
gfx->setFont(&Dialog_plain_18);
gfx->setCursor (minmax_panel_x+120,minmax_panel_y-138); //110
gfx->print ("Max temp");
gfx->setFont(&Dialog_plain_24);
gfx->drawCircle (minmax_panel_x+195, minmax_panel_y-120, 3, WHITE);
gfx->drawCircle (minmax_panel_x+195, minmax_panel_y-120, 4, WHITE); // meer min => omhoog
gfx->setCursor (minmax_panel_x+197,minmax_panel_y-95);
gfx->setTextColor (WHITE,BLACK);
gfx->print ("C");
gfx->setFont(&Dialog_plain_18);
gfx->setCursor (minmax_panel_x+120,minmax_panel_y-60);
gfx->setTextColor (YELLOW,BLACK);
gfx->print ("Min temp");
gfx->setTextColor (WHITE,BLACK);
gfx->setFont(&Dialog_plain_24);
gfx->drawCircle (minmax_panel_x+195, minmax_panel_y-40, 3, WHITE);
gfx->drawCircle (minmax_panel_x+195, minmax_panel_y-40, 4, WHITE);
gfx->setCursor (minmax_panel_x+197,minmax_panel_y-15);
gfx->print ("C");
t_meter_increase = 92; //was 46 // absolute vertical pixel range of 'mercury' in thermometer simulation
gfx->setFont(0);
}
//https://stackoverflow.com/questions/75858382/openweathermap-weather-returns-null
// ######################################################################################
// # run the weather station - get json string and parse #
// ######################################################################################
void run_the_weatherstation (){
// for(;;){
String serverPath = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "," + countryCode + "&APPID=" + openWeatherMapApiKey;
jsonBuffer = httpGETRequest(serverPath.c_str());
Serial.println(jsonBuffer);
Serial.println("na jsonbuffer");
JSONVar myObject = JSON.parse(jsonBuffer);
double weather_01 = (myObject ["weather"]["id"]);
double temp_01 = (myObject ["main"]["temp"]);
double hum_01 = (myObject ["main"]["humidity"]);
double press_01 = (myObject ["main"]["pressure"]);
double w_speed_01 = (myObject ["wind"]["speed"]);
double wind_dir_01 = (myObject ["wind"]["deg"]);
JSONVar minmax_temp = JSON.parse(jsonBuffer);
double min_temp = (minmax_temp ["main"]["temp_min"]);
double max_temp = (minmax_temp ["main"]["temp_max"]);
if (JSON.typeof(myObject) == "undefined") // JSON.typeof(jsonVar) can be used to get the type of the var
{
Serial.println("Parsing input failed!");
return;
}
Serial.println ("*******************************************");
Serial.print ("JSON object = ");
Serial.println (myObject);
Serial.println ("*******************************************");
Serial.println ("extracted from JSON object:");
Serial.print (myObject["weather"]["id"]);
Serial.println (" =ID2");
Serial.print ("temperature: ");
Serial.print (myObject["main"]["temp"]);
Serial.println (" *K");
Serial.print ("pressure: ");
Serial.print (myObject["main"]["pressure"]);
Serial.println (" mB");
Serial.print ("humidity: ");
Serial.print(myObject["main"]["humidity"]);
Serial.println (" %");
Serial.print ("wind speed: ");
Serial.print (myObject["wind"]["speed"]);
Serial.println (" m/s");
Serial.print("wind direction: ");
Serial.print (myObject["wind"]["deg"]);
Serial.println (" degrees");
temp_rainbowgauge = temp_01-273; // convert temp from Kelvin to Celsius
hum_02 = hum_01; // place humidity value in a transferable variable
press_02 = press_01; // place air pressure value in a transferable variable
w_speed_02 = w_speed_01; // place wind speed value in a transferable variable
max_temp_today = max_temp-273;
min_temp_today = min_temp-273;
Serial.print("min temp today: ");
Serial.print (min_temp_today,1);
Serial.println (" *C");
Serial.print("max temp today: ");
Serial.print (max_temp_today,1);
Serial.println (" *C");
wind_dir_02 = wind_dir_01;
windSectorReporter ();
gfx->setFont(&Dialog_plain_9);
gfx->setCursor ((compassPivot_x+10), (compassPivot_y+170));
gfx->print (myObject["wind"]["deg"]);
gfx->setFont(0);
rainbowScaleMeter ();
print_dynamic_data_to_display ();
compassPointer ();
refresh_dynamic_baropanel();
build_dynamic_baropanel ();
needle_meter ();
dynamic_minmax_panel ();
//}//einde for
}//einde run
// ######################################################################################
// # dynamic data in the min-max temp panel #
// ######################################################################################
//nog aanpassen
void dynamic_minmax_panel (){
gfx->fillRect (minmax_panel_x+115,minmax_panel_y-115, 72,30,BLACK); //BLACK tbv wegvegen oude waarde /meer min => omhoog
gfx->setFont(&Dialog_bold_24);
if (max_temp_today >= 0.0) gfx->setCursor (minmax_panel_x+140,minmax_panel_y-95);
if (max_temp_today >= 10.0) gfx->setCursor (minmax_panel_x+124,minmax_panel_y-95);
if (max_temp_today < -0.0) gfx->setCursor (minmax_panel_x+124,minmax_panel_y-95);
if (max_temp_today < -9.9) gfx->setCursor (minmax_panel_x+128,minmax_panel_y-95);
gfx->print (max_temp_today,1);
gfx->fillRect (minmax_panel_x+115,minmax_panel_y-35, 72,30,BLACK); //BLACK
if (min_temp_today >= 0.0) gfx->setCursor (minmax_panel_x+140,minmax_panel_y-15);
if (min_temp_today >= 10.0) gfx->setCursor (minmax_panel_x+124,minmax_panel_y-15); //minder min => omlaag
if (min_temp_today < -0.0) gfx->setCursor (minmax_panel_x+124,minmax_panel_y-15);
if (min_temp_today < -9.9) gfx->setCursor (minmax_panel_x+128,minmax_panel_y-15);
gfx->print (min_temp_today,1);
t_meter_increase_old = t_meter_increase;
t_meter_increase = ((max_temp_today/33)*92); // empirically determined dynamic range of 'mercury' in the graphical thermometer
t_meter_increase = ((max_temp_today/33)*92);
//t_meter_increase = ((max_temp_today/33)*46); // empirically determined dynamic range of 'mercury' in the graphical thermometer
//t_meter_increase = ((max_temp_today/33)*46);
if (t_meter_increase <1) t_meter_increase = 1;
if (t_meter_increase >45) t_meter_increase = 45; // barrier against overflowing of graphical thermometer
//if (t_meter_increase <1) t_meter_increase = 1;
//if (t_meter_increase >45) t_meter_increase = 45;
//org gfx->fillRect (minmax_panel_x+9,minmax_panel_y+57, 5, -t_meter_increase_old, YELLOW); //black
//org gfx->fillRect (minmax_panel_x+9,minmax_panel_y+57, 5, -t_meter_increase, RED);
gfx->fillRect (minmax_panel_x+91,minmax_panel_y-26 -t_meter_increase_old, 12, t_meter_increase_old,BLACK);
gfx->fillRect (minmax_panel_x+91,minmax_panel_y-26 -t_meter_increase, 12, t_meter_increase,RED);
gfx->setFont(0);
}
// ######################################################################################
// # http GET request module #
// ######################################################################################
String httpGETRequest(const char* serverName) {
WiFiClient client;
HTTPClient http;
http.begin(client, serverName); // your IP address with path or Domain name with URL path
int httpResponseCode = http.GET(); // send HTTP POST request
String payload = "{}";
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
payload = http.getString();
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
http.end(); // free resources
return payload;
}
///=================================================================================================
// ######################################################################################
// # dynamic temperature rainbow scale meter #
// ######################################################################################
void rainbowScaleMeter (){
if (millis () - runTime >= 100) // originally 500 = delay
{
runTime = millis ();
if( tesmod==0)
{
reading = 99;
}
if( tesmod==1)
{
reading = temp_rainbowgauge*2; // important: here ring is seeded with value
}
// r_gauge_pos_x = 161; // these two variables govern the position
// r_gauge_pos_y = 5; // of the square + gauge on the display = upper left corner
ringMeter (reading,0,100, (r_gauge_pos_x+45),(r_gauge_pos_y+17),ringmeter_radius,ringlabel[0],GREEN2RED);
tesmod = 1;
}
}
// ######################################################################################
// # rainbow scale: draw the rainbox ring meter, returns x coord of righthand side #
// ######################################################################################
int ringMeter(int value,int vmin,int vmax,int x,int y,int r, char *units, byte scheme){
// Minimum value of r is about 52 before value text intrudes on ring
// drawing the text first is an option
x += r; y += r; // calculate coordinates of center of ring
int w = r / 3; // width of outer ring is 1/4 of radius
int angle = 150; // half the sweep angle of the meter (300 degrees)
int v = map (value, vmin, vmax, -angle, angle); // map the value to an angle v
byte seg = 3; // segments are 3 degrees wide = 100 segments for 300 degrees
byte inc = 6; // draw segments every 3 degrees, increase to 6 for segmented ring
int colour = BLUE; // variable to save "value" text color from scheme and set default
for (int i = -angle+inc/2; i < angle-inc/2; i += inc) // draw color blocks every increment degrees
{
float sx = cos((i - 90) * DEG2RAD); // calculate pair of coordinates for segment start
float sy = sin((i - 90) * DEG2RAD);
uint16_t x0 = sx * (r - w) + x;
uint16_t y0 = sy * (r - w) + y;
uint16_t x1 = sx * r + x;
uint16_t y1 = sy * r + y;
float sx2 = cos((i + seg - 90) * DEG2RAD); // calculate pair of coordinates for segment end
float sy2 = sin((i + seg - 90) * DEG2RAD);
int x2 = sx2 * (r - w) + x;
int y2 = sy2 * (r - w) + y;
int x3 = sx2 * r + x;
int y3 = sy2 * r + y;
if (i < v)
{ // fill in coloured segments with 2 triangles
switch (scheme)
{
case 0: colour = RED; break; // fixed color
case 1: colour = GREEN; break; // fixed color
case 2: colour = BLUE; break; // fixed colour
case 3: colour = RED; break; // full spectrum blue to red
case 4: colour = GREEN; break; // green to red (high temperature etc)
case 5: colour = BLUE; break; // red to green (low battery etc)
// case 3: colour = rainbow(map(i, -angle, angle, 0, 127)); break; // full spectrum blue to red
// case 4: colour = rainbow(map(i, -angle, angle, 70, 127)); break; // green to red (high temperature etc)
// case 5: colour = rainbow(map(i, -angle, angle, 127, 63)); break; // red to green (low battery etc)
default: colour = BLUE; break; // fixed color
}
gfx->fillTriangle(x0, y0, x1, y1, x2, y2, colour);
gfx->fillTriangle(x1, y1, x2, y2, x3, y3, colour);
}
else // fill in blank segments
{
gfx->fillTriangle(x0, y0, x1, y1, x2, y2, SCALE1); // color of the unoccupied ring scale
gfx->fillTriangle(x1, y1, x2, y2, x3, y3, SCALE0); // color of the unoccupied ring scale
}
}
t=530; //t=197 aanpassen tbv 7
if (temp_rainbowgauge<-9.9) t = 525; //positie na actuele temp
if (temp_rainbowgauge>-9.9) t = 530;
if (temp_rainbowgauge > 0 ) t = 532;
if (temp_rainbowgauge >9.9) t = 524;
gfx->fillRect (t+14,y-22,140,40,BLACK); //BLACK tbv wegvallen nadat temp is gelezen BLACK
gfx->setFont(&Dialog_bold_40);
//gfx->setTextSize(4);
gfx->setCursor (t+45,y+10); //positie temp => temp 0.0 heeft basis t,y positie
gfx->setTextColor (WHITE); //yellow
gfx->print (temp_rainbowgauge,1); // tft.print (temp_rainbowgauge,1); = basic temp 0.0.
return (temp_rainbowgauge);
gfx->setFont(0);
}
/*
// ######################################################################################
// # rainbow scale: 16-bit rainbow color mixer #
// ######################################################################################
unsigned int rainbow (byte value) { // value is expected to be in range 0-127
// value is converted to a spectrum color from 0 = BLUE through to 127 = RED
byte RED = 0; // RED is the top 5 bits of a 16 bit colour value
byte GREEN = 0; // GREEN is the middle 6 bits
byte BLUE = 0; // BLUE is the bottom 5 bits
byte quadrant = value / 32;
if (quadrant == 0)
{
BLUE = 31;
GREEN = 2 * (value % 32);
RED = 0;
}
if (quadrant == 1)
{
BLUE = 31 - (value % 32);
GREEN = 63;
RED = 0;
}
if (quadrant == 2)
{
BLUE = 0;
GREEN = 63;
RED = value % 32;
}
if (quadrant == 3)
{
BLUE = 0;
GREEN = 63 - 2 * (value % 32);
RED = 31;
}
return (RED << 11) + (GREEN << 5) + BLUE;
}
*/
// ######################################################################################
// # dynamic data in the numeric panel #
// ######################################################################################
void print_dynamic_data_to_display (){
//waarden presenteren
static_num_panel_x = 120; // all coordinates in this panel relative to these two
static_num_panel_y = 35; // all coordinates in this panel relative to these two
gfx->setTextColor (WHITE,BLACK);
gfx->setFont(&Dialog_bold_32);
gfx->fillRect (static_num_panel_x+10,static_num_panel_y+20,150,40,BLACK); //tbv wegvallen temp bij verandering ->org =BLACK
gfx->setCursor (static_num_panel_x+65,static_num_panel_y+46);
gfx->print (temp_rainbowgauge,1); //tbv temp in rainbow en totaal overzicht
//////////////////
gfx->fillRect (static_num_panel_x+45,static_num_panel_y+72,132,40,BLACK);
gfx->setCursor (static_num_panel_x+55,static_num_panel_y+98);
if (press_02 <1000) gfx->setCursor (static_num_panel_x+60,static_num_panel_y+98);
gfx->print (press_02,0);
gfx->fillRect (static_num_panel_x+45,static_num_panel_y+129,120,40,BLACK);
gfx->setCursor (static_num_panel_x+75,static_num_panel_y+155);
gfx->print (hum_02,0);
gfx->fillRect (static_num_panel_x+40,static_num_panel_y+184,130,40,BLACK);
gfx->setCursor (static_num_panel_x+70,static_num_panel_y+210);
gfx->print (w_speed_02,1);
gfx->fillRect (static_num_panel_x+45,static_num_panel_y+238,245,36,BLACK);
gfx->setCursor (static_num_panel_x+65,static_num_panel_y+265);
gfx->print (sector[h]);
gfx->setFont(0);
}
// ######################################################################################
// # dynamic barometer panel #
// ######################################################################################
void build_dynamic_baropanel (){ // fills two triangles to create 4-point polygon
barval = 1050-press_02;
// baro_panel_x = 162; //extra tbv positie
// baro_panel_y = 156; // based on baro pressure
// baro_panel_x = 476; //extra tbv positie
// baro_panel_y = 322;
//vierkant linker bovenhoek = 476,322
p1_x = ((baro_panel_x+6)+ ((100-barval)/100*144)); // p1-p2-p3 corner points for first triangle
p1_y = ((baro_panel_y+150)- ((100-barval)/100*146)); // p1-p4-p3 corner points for second triangle
p2_x = baro_panel_x+2;
p2_y = baro_panel_y+154; //was 148
p3_x = baro_panel_x+152; //was 150
p3_y = baro_panel_y+154; //was 148
p4_x = baro_panel_x+152;
p4_y = p1_y;
p1_x_old = p1_x; // remember previous positions of points
p1_y_old = p1_y;
p2_x_old = p2_x;
p2_y_old = p2_y;
p3_x_old = p3_x;
p3_y_old = p3_y;
p4_x_old = p4_x;
p4_y_old = p4_y;
gfx->fillTriangle (p1_x, p1_y, p2_x, p2_y, p3_x, p3_y, SCALE2); //SCALE2 // make new first triangle
gfx->fillTriangle (p1_x, p1_y, p4_x, p4_y, p3_x, p3_y, SCALE2); //SCALE2 // make new second triangle
gfx->drawLine (p1_x, p1_y, p4_x, p4_y, CYAN); // draw horizontal level line
gfx->drawLine (baro_panel_x+8, baro_panel_y+150, baro_panel_x+148, baro_panel_y+150, SCALE2); // correct triangles base SCALE2
gfx->drawLine (baro_panel_x+8, baro_panel_y+152, baro_panel_x+144, baro_panel_y+152, SCALE2); // correct triangles-base SCALE2
gfx->drawRoundRect (baro_panel_x, baro_panel_y, 154, 156, 4, GREEN); // correct right-of-middle lower panel frame
gfx->drawLine (baro_panel_x+4, baro_panel_y+150, (baro_panel_x+150), (baro_panel_y+4), CYAN); // redraw line
gfx->fillCircle (p1_x, p1_y,3,RED);
gfx->setFont(&Dialog_plain_18);
gfx->setTextColor (YELLOW,BLACK);
gfx->setCursor (baro_panel_x+10, baro_panel_y+20);
gfx->print ("baro ");
gfx->setTextColor (WHITE,BLACK);
gfx->setCursor (baro_panel_x+64, baro_panel_y+20);
if (press_02>999) gfx->print ("high"); else gfx->print ("low ");
gfx->setFont(0);
}
// ######################################################################################
// # refresh the dynamic barometer panel #
// ######################################################################################
void refresh_dynamic_baropanel (){
gfx->fillCircle (p1_x_old, p1_y_old, 3, BLACK); // erase previous position of red circle
gfx->fillTriangle (p1_x_old, p1_y_old, p2_x_old, p2_y_old, p3_x_old, p3_y_old, BLACK); // remove previous first triangle
gfx->fillTriangle (p1_x_old, p1_y_old, p4_x_old, p4_y_old, p3_x_old, p3_y_old, BLACK); // remove previous second triangle
gfx->drawLine (p1_x_old, p1_y_old, p4_x_old, p4_y_old, BLACK); // remove previous horizontal level line
gfx->drawLine (baro_panel_x+4, baro_panel_y+150, (baro_panel_x+150), (baro_panel_y+4), CYAN); // draw new diagonal line
gfx->drawLine (baro_panel_x+8, baro_panel_y+150, baro_panel_x+148, baro_panel_y+150, SCALE2); // correct triangles base
gfx->drawLine (baro_panel_x+8, baro_panel_y+152, baro_panel_x+144, baro_panel_y+152, SCALE2); // correct triangles-base
// gfx->drawRoundRect (minmax_panel_x, minmax_panel_y, 144, 156, 4, GREEN); // extreme right lower window
}


