[m] Fixed & Cleanup & env.h
This commit is contained in:
parent
97b0351761
commit
65e6d883d4
24
env.h.default
Normal file
24
env.h.default
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef TG_ENV_H
|
||||||
|
#define TG_ENV_H
|
||||||
|
|
||||||
|
#define INFLUXDB_URL "https://influx.net"
|
||||||
|
#define INFLUXDB_TOKEN "LONG_TOKEN=="
|
||||||
|
#define INFLUXDB_ORG "ORG"
|
||||||
|
#define INFLUXDB_BUCKET "BUCKET"
|
||||||
|
|
||||||
|
|
||||||
|
#define NTP_URL "ch.pool.ntp.org"
|
||||||
|
|
||||||
|
#define LOCATION_0 "Zurich,ch"
|
||||||
|
#define LOCATION_1 "Oslo,no"
|
||||||
|
#define LOCATION_2 "Tokyo,jp"
|
||||||
|
#define LOCATION_3 "Moscow,ru"
|
||||||
|
#define OPENWEATHER_API "API_KEY"
|
||||||
|
|
||||||
|
#define WIFI_REGISTER_AP(wm) \
|
||||||
|
do { \
|
||||||
|
wifiMulti.addAP("SSID1", "PASS1"); \
|
||||||
|
wifiMulti.addAP("SSID2", "PASS2"); \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#endif
|
23
metesp.ino
23
metesp.ino
@ -150,11 +150,12 @@ void setup_TIMEDFUN() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup_POWER() {
|
void setup_POWER() {
|
||||||
esp_sleep_enable_gpio_wakeup();
|
|
||||||
gpio_wakeup_enable(GPIO_NUM_15,GPIO_INTR_HIGH_LEVEL);
|
gpio_wakeup_enable(GPIO_NUM_15,GPIO_INTR_HIGH_LEVEL);
|
||||||
// esp_sleep_enable_ext0_wakeup(GPIO_NUM_15, 1);
|
esp_sleep_enable_gpio_wakeup();
|
||||||
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
|
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_VDDSDIO,ESP_PD_OPTION_ON);
|
|
||||||
|
// esp_sleep_enable_ext0_wakeup(GPIO_NUM_15, 1);
|
||||||
|
// esp_sleep_pd_config(ESP_PD_DOMAIN_VDDSDIO,ESP_PD_OPTION_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,11 +163,11 @@ void setup_POWER() {
|
|||||||
void setup(){
|
void setup(){
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
I2C.begin(PIN_SDA, PIN_SCL);
|
I2C.begin(PIN_SDA, PIN_SCL);
|
||||||
I2C.setPins(PIN_SDA,PIN_SCL);
|
|
||||||
setup_POWER();
|
setup_POWER();
|
||||||
|
|
||||||
Display::setup();
|
Display::setup();
|
||||||
setup_WIFI();
|
setup_WIFI();
|
||||||
|
ntp->updateNTPtime();
|
||||||
setup_TOUCH();
|
setup_TOUCH();
|
||||||
setup_TIMER();
|
setup_TIMER();
|
||||||
setup_TIMEDFUN();
|
setup_TIMEDFUN();
|
||||||
@ -208,14 +209,18 @@ void loop(){
|
|||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
if(shutdownc >= 3){
|
if(shutdownc >= 3){
|
||||||
|
Display::clearTime();
|
||||||
EPD_2IN13_V2_Sleep();
|
EPD_2IN13_V2_Sleep();
|
||||||
Serial.println("Shuting down");
|
Serial.println("Shuting down");
|
||||||
strDateTime odt = (ntp->dt);
|
while(touch->dev.holding || touch->dev.pressing){
|
||||||
vTaskDelay(2000);
|
touch->update();
|
||||||
// touch->Reset();
|
delay(100);
|
||||||
|
}
|
||||||
|
delay(500);
|
||||||
touch->update();
|
touch->update();
|
||||||
vTaskDelay(500);
|
strDateTime odt = (ntp->dt);
|
||||||
esp_light_sleep_start();
|
delay(2000);
|
||||||
|
esp_light_sleep_start();//IRQ Raised for some reason
|
||||||
Serial.println("Wakey Wakey");
|
Serial.println("Wakey Wakey");
|
||||||
wakeup();
|
wakeup();
|
||||||
tf->minuteTick(ntp->dt.minute - odt.minute);
|
tf->minuteTick(ntp->dt.minute - odt.minute);
|
||||||
|
@ -13,7 +13,7 @@ void DrawMain(bool v){
|
|||||||
Paint_DrawIcon(89,36, ICON_LOGO, &FontIcon, BLACK, WHITE);
|
Paint_DrawIcon(89,36, ICON_LOGO, &FontIcon, BLACK, WHITE);
|
||||||
Paint_DrawString_EN(29, 0, "Helcel", &Font45, WHITE, BLACK);
|
Paint_DrawString_EN(29, 0, "Helcel", &Font45, WHITE, BLACK);
|
||||||
if(v)
|
if(v)
|
||||||
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - 2 - Font16.Height,"WESP-v0.1", &Font16, WHITE, BLACK);
|
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - Font16.Height,"WESP-v0.1", &Font16, WHITE, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::setup(){
|
void Display::setup(){
|
||||||
@ -31,10 +31,14 @@ void Display::setup(){
|
|||||||
EPD_2IN13_V2_DisplayPart(BlackImage);
|
EPD_2IN13_V2_DisplayPart(BlackImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Display::clearTime(){
|
||||||
|
Paint_ClearWindows(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, 170 + Font24.Width * 4.5, EPD_2IN13_V2_WIDTH, WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
void Display::drawTime(strDateTime* dt){
|
void Display::drawTime(strDateTime* dt){
|
||||||
Paint_ClearWindows(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, 170 + Font24.Width * 4.5, EPD_2IN13_V2_WIDTH, WHITE);
|
clearTime();
|
||||||
if (!dt->valid) return;
|
if (!dt->valid) return;
|
||||||
Paint_DrawTime(170, 98, dt, &Font24, WHITE, BLACK);
|
Paint_DrawTime(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, dt, &Font24, WHITE, BLACK);
|
||||||
EPD_2IN13_V2_DisplayPart(BlackImage);
|
EPD_2IN13_V2_DisplayPart(BlackImage);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -92,7 +96,7 @@ void WeatherDisplay::drawDisplay() {
|
|||||||
JsonObject weather_sys = cowm->weather["sys"];
|
JsonObject weather_sys = cowm->weather["sys"];
|
||||||
if(!weather_0 || !weather_main || !weather_sys || !weather_wind) return;
|
if(!weather_0 || !weather_main || !weather_sys || !weather_wind) return;
|
||||||
Paint_DrawIcon(0,8, getWeatherIcon(weather_0["id"]), &FontIcon, BLACK, WHITE);
|
Paint_DrawIcon(0,8, getWeatherIcon(weather_0["id"]), &FontIcon, BLACK, WHITE);
|
||||||
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - 2 - Font16.Height,weather_0["main"], &Font16, WHITE, BLACK);
|
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - Font16.Height,weather_0["main"], &Font16, WHITE, BLACK);
|
||||||
Paint_DrawFltUnit(76,0,weather_main["temp"], "C", &Font24, BLACK, WHITE);
|
Paint_DrawFltUnit(76,0,weather_main["temp"], "C", &Font24, BLACK, WHITE);
|
||||||
Paint_DrawFltUnit(186,6,weather_main["feels_like"], "C", &Font12, BLACK, WHITE);
|
Paint_DrawFltUnit(186,6,weather_main["feels_like"], "C", &Font12, BLACK, WHITE);
|
||||||
Paint_DrawIntUnit(76,24,weather_main["pressure"], "hPa", &Font24, BLACK, WHITE);
|
Paint_DrawIntUnit(76,24,weather_main["pressure"], "hPa", &Font24, BLACK, WHITE);
|
||||||
@ -111,7 +115,7 @@ void TempDisplay::drawDisplay() {
|
|||||||
Paint_DrawFltUnit(76,24,sensor->pres, "hPa", &Font24, BLACK, WHITE);
|
Paint_DrawFltUnit(76,24,sensor->pres, "hPa", &Font24, BLACK, WHITE);
|
||||||
Paint_DrawFltUnit(76,48,sensor->hum, "%", &Font24, BLACK, WHITE);
|
Paint_DrawFltUnit(76,48,sensor->hum, "%", &Font24, BLACK, WHITE);
|
||||||
|
|
||||||
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - 2 - Font16.Height,"Nominal", &Font16, WHITE, BLACK);
|
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - Font16.Height,"Nominal", &Font16, WHITE, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirDisplay::drawDisplay() {
|
void AirDisplay::drawDisplay() {
|
||||||
@ -134,7 +138,7 @@ void AirDisplay::drawDisplay() {
|
|||||||
// particles_50um, ///< 5.0um Particle Count
|
// particles_50um, ///< 5.0um Particle Count
|
||||||
// particles_100um; ///< 10.0um Particle Count
|
// particles_100um; ///< 10.0um Particle Count
|
||||||
|
|
||||||
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - 2 - Font16.Height,"Nominal", &Font16, WHITE, BLACK);
|
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - Font16.Height,"Nominal", &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +151,7 @@ void LightDisplay::drawDisplay() {
|
|||||||
Paint_DrawFltUnit(76,24*2,sensor->light, "l", &Font24, BLACK, WHITE);
|
Paint_DrawFltUnit(76,24*2,sensor->light, "l", &Font24, BLACK, WHITE);
|
||||||
Paint_DrawIntUnit(76,24*3,sensor->light_vis, "vl", &Font24, BLACK, WHITE);
|
Paint_DrawIntUnit(76,24*3,sensor->light_vis, "vl", &Font24, BLACK, WHITE);
|
||||||
|
|
||||||
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - 2 - Font16.Height,"Nominal", &Font16, WHITE, BLACK);
|
Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - Font16.Height,"Nominal", &Font16, WHITE, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ class DisplayWrapper {
|
|||||||
class Display {
|
class Display {
|
||||||
public:
|
public:
|
||||||
static void setup();
|
static void setup();
|
||||||
|
static void clearTime();
|
||||||
static void drawTime(strDateTime* dt);
|
static void drawTime(strDateTime* dt);
|
||||||
static void refresh();
|
static void refresh();
|
||||||
static void update();
|
static void update();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define LEAP_YEAR(Y) ( ((1970+Y)>0) && !((1970+Y)%4) && ( ((1970+Y)%100) || !((1970+Y)%400) ) )
|
#define LEAP_YEAR(Y) ( ((1970+Y)>0) && !((1970+Y)%4) && ( ((1970+Y)%100) || !((1970+Y)%400) ) )
|
||||||
|
|
||||||
#define SEC_TO_MS 1000
|
#define SEC_TO_MS 1000
|
||||||
@ -167,6 +169,8 @@ unsigned long NTPtime::adjustTimeZone(unsigned long _timeStamp, float _timeZone,
|
|||||||
|
|
||||||
|
|
||||||
strDateTime NTPtime::getNTPtime(float _timeZone, boolean _DayLightSaving) {
|
strDateTime NTPtime::getNTPtime(float _timeZone, boolean _DayLightSaving) {
|
||||||
|
|
||||||
|
Serial.println("NTP: Updating Time");
|
||||||
int cb;
|
int cb;
|
||||||
strDateTime _dateTime;
|
strDateTime _dateTime;
|
||||||
unsigned long _unixTime = 0;
|
unsigned long _unixTime = 0;
|
||||||
@ -175,6 +179,8 @@ strDateTime NTPtime::getNTPtime(float _timeZone, boolean _DayLightSaving) {
|
|||||||
|
|
||||||
if (_sendPhase) {
|
if (_sendPhase) {
|
||||||
if (_sentTime && ((millis() - _sentTime) < _sendInterval)) {
|
if (_sentTime && ((millis() - _sentTime) < _sendInterval)) {
|
||||||
|
|
||||||
|
Serial.println("NTP: Too Fast");
|
||||||
return _dateTime;
|
return _dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +227,8 @@ strDateTime NTPtime::getNTPtime(float _timeZone, boolean _DayLightSaving) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Serial.println("NTP: OK");
|
||||||
|
|
||||||
return _dateTime;
|
return _dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ void GT1151::update() {
|
|||||||
uint8_t irq = gtIRQ;
|
uint8_t irq = gtIRQ;
|
||||||
gtIRQ = 0;
|
gtIRQ = 0;
|
||||||
interrupts();
|
interrupts();
|
||||||
|
// Serial.printf("IRQ: %d\n",irq);
|
||||||
if (irq) onIRQ();
|
if (irq) onIRQ();
|
||||||
else dev.pressing = false;
|
else dev.pressing = false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user