diff --git a/library.json b/library.json index be4de92..9a47a2a 100644 --- a/library.json +++ b/library.json @@ -17,7 +17,7 @@ "platforms": ["espressif32"], "dependencies": [ { "name": "Adafruit GFX Library" }, - { "name": "Arduino_JSON" }, + { "name": "ArduinoJSON" }, { "name": "DS3232RTC" }, { "name": "NTPClient" }, { @@ -26,7 +26,7 @@ }, { "name": "GxEPD2", - "version": "https://github.com/ZinggJM/GxEPD2.git#master" + "version": "https://github.com/DarkZeros/GxEPD2.git#watchy" }, { "name": "WiFiManager", diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 1dc0679..3f63529 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -584,10 +584,15 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang, Str int httpResponseCode = http.GET(); if(httpResponseCode == 200) { String payload = http.getString(); - JSONVar responseObject = JSON.parse(payload); - currentWeather.temperature = int(responseObject["main"]["temp"]); - currentWeather.weatherConditionCode = int(responseObject["weather"][0]["id"]); - currentWeather.weatherDescription = responseObject["weather"][0]["main"]; + DynamicJsonDocument doc(1024); + auto error = deserializeJson(doc, payload); + if (!error) { + currentWeather.temperature = doc["main"]["temp"].as(); + currentWeather.weatherConditionCode = doc["weather"][0]["id"].as(); + currentWeather.weatherDescription = doc["weather"][0]["main"].as(); + } else { + Serial.println(error.c_str()); + } }else{ //http error } diff --git a/src/Watchy.h b/src/Watchy.h index aeccc68..dd43ce0 100644 --- a/src/Watchy.h +++ b/src/Watchy.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/arduino_pins.h b/src/arduino_pins.h new file mode 100644 index 0000000..454330a --- /dev/null +++ b/src/arduino_pins.h @@ -0,0 +1,25 @@ +#ifndef ARDUINO_PINS_H +#define ARDUINO_PINS_H + +//pins +#define SDA 21 +#define SCL 22 +#define BATT_ADC_PIN 35 //v1.5 Watchy with PCF8563 RTC +#define RTC_INT_PIN GPIO_NUM_27 +#define DISPLAY_CS 5 +#define DISPLAY_DC 10 +#define DISPLAY_RES 9 +#define DISPLAY_BUSY 19 +#define VIB_MOTOR_PIN 13 +#define MENU_BTN_PIN 26 +#define BACK_BTN_PIN 25 +#define UP_BTN_PIN 32 +#define DOWN_BTN_PIN 4 +#define MENU_BTN_MASK GPIO_SEL_26 +#define BACK_BTN_MASK GPIO_SEL_25 +#define UP_BTN_MASK GPIO_SEL_32 +#define DOWN_BTN_MASK GPIO_SEL_4 +#define ACC_INT_MASK GPIO_SEL_14 +#define BTN_PIN_MASK MENU_BTN_MASK|BACK_BTN_MASK|UP_BTN_MASK|DOWN_BTN_MASK + +#endif diff --git a/src/config.h b/src/config.h index 6529486..64defdf 100644 --- a/src/config.h +++ b/src/config.h @@ -1,6 +1,8 @@ #ifndef CONFIG_H #define CONFIG_H +#include "arduino_pins.h" + //display #define DISPLAY_WIDTH 200 #define DISPLAY_HEIGHT 200 @@ -31,4 +33,5 @@ #define HARDWARE_VERSION_MINOR 0 //Versioning #define WATCHY_LIB_VER "1.4.0" + #endif