add arduino_pins.h

- switch to ArduinoJSON
- include arduino_pins.h from config.h
pull/150/head
Torgny Bjers 2022-03-23 02:58:14 -04:00
parent cd17d2046d
commit b358aed0d1
No known key found for this signature in database
GPG Key ID: 65918840686A0D2A
5 changed files with 40 additions and 7 deletions

View File

@ -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",

View File

@ -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<int>();
currentWeather.weatherConditionCode = doc["weather"][0]["id"].as<int>();
currentWeather.weatherDescription = doc["weather"][0]["main"].as<const char *>();
} else {
Serial.println(error.c_str());
}
}else{
//http error
}

View File

@ -6,7 +6,7 @@
#include <HTTPClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <Arduino_JSON.h>
#include <ArduinoJson.h>
#include <GxEPD2_BW.h>
#include <Wire.h>
#include <Fonts/FreeMonoBold9pt7b.h>

25
src/arduino_pins.h Normal file
View File

@ -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

View File

@ -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