From 45069f84719a1df246973c7481732aa803a592c5 Mon Sep 17 00:00:00 2001 From: Daniel Eichhorn Date: Sat, 22 Jul 2017 16:02:14 +0200 Subject: [PATCH] Small fixes for candy merge --- TouchController.cpp => TouchControllerWS.cpp | 22 ++++++++++---------- TouchController.h => TouchControllerWS.h | 8 +++---- esp8266-weather-station-color.ino | 15 +++++++------ settings.h | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) rename TouchController.cpp => TouchControllerWS.cpp (79%) rename TouchController.h => TouchControllerWS.h (82%) diff --git a/TouchController.cpp b/TouchControllerWS.cpp similarity index 79% rename from TouchController.cpp rename to TouchControllerWS.cpp index c356287..9d3beea 100644 --- a/TouchController.cpp +++ b/TouchControllerWS.cpp @@ -1,10 +1,10 @@ -#include "TouchController.h" +#include "TouchControllerWS.h" -TouchController::TouchController(XPT2046_Touchscreen *touchScreen) { +TouchControllerWS::TouchControllerWS(XPT2046_Touchscreen *touchScreen) { this->touchScreen = touchScreen; } - -bool TouchController::loadCalibration() { + +bool TouchControllerWS::loadCalibration() { // always use this to "mount" the filesystem bool result = SPIFFS.begin(); Serial.println("SPIFFS opened: " + result); @@ -32,7 +32,7 @@ bool TouchController::loadCalibration() { } -bool TouchController::saveCalibration() { +bool TouchControllerWS::saveCalibration() { bool result = SPIFFS.begin(); // open the file in write mode @@ -49,12 +49,12 @@ bool TouchController::saveCalibration() { f.close(); } -void TouchController::startCalibration(CalibrationCallback *calibrationCallback) { +void TouchControllerWS::startCalibration(CalibrationCallback *calibrationCallback) { state = 0; this->calibrationCallback = calibrationCallback; } -void TouchController::continueCalibration() { +void TouchControllerWS::continueCalibration() { TS_Point p = touchScreen->getPoint(); if (state == 0) { @@ -80,22 +80,22 @@ void TouchController::continueCalibration() { } } -bool TouchController::isCalibrationFinished() { +bool TouchControllerWS::isCalibrationFinished() { return state == 2; } -bool TouchController::isTouched() { +bool TouchControllerWS::isTouched() { touchScreen->touched(); } -bool TouchController::isTouched(int16_t debounceMillis) { +bool TouchControllerWS::isTouched(int16_t debounceMillis) { if (touchScreen->touched() && millis() - lastTouched > debounceMillis) { lastTouched = millis(); return true; } return false; } -TS_Point TouchController::getPoint() { +TS_Point TouchControllerWS::getPoint() { TS_Point p = touchScreen->getPoint(); int x = (p.y - ax) * dx; int y = 320 - (p.x - ay) * dy; diff --git a/TouchController.h b/TouchControllerWS.h similarity index 82% rename from TouchController.h rename to TouchControllerWS.h index 155d2ac..37f3ead 100644 --- a/TouchController.h +++ b/TouchControllerWS.h @@ -1,14 +1,14 @@ #include #include -#ifndef _TOUCH_CONTROLLERH_ -#define _TOUCH_CONTROLLERH_ +#ifndef _TOUCH_CONTROLLERWSH_ +#define _TOUCH_CONTROLLERWSH_ typedef void (*CalibrationCallback)(int16_t x, int16_t y); -class TouchController { +class TouchControllerWS { public: - TouchController(XPT2046_Touchscreen *touchScreen); + TouchControllerWS(XPT2046_Touchscreen *touchScreen); bool loadCalibration(); bool saveCalibration(); void startCalibration(CalibrationCallback *callback); diff --git a/esp8266-weather-station-color.ino b/esp8266-weather-station-color.ino index 1b707c6..391a39a 100644 --- a/esp8266-weather-station-color.ino +++ b/esp8266-weather-station-color.ino @@ -18,13 +18,19 @@ SOFTWARE. See more at https://blog.squix.org */ + +/***************************** + * Important: see settings.h to configure your settings!!! + * ***************************/ +#include "settings.h" + #include #include #include #ifdef HAVE_TOUCHPAD #include - #include "TouchController.h" + #include "TouchControllerWS.h" #endif /*** @@ -49,10 +55,7 @@ See more at https://blog.squix.org #include "moonphases.h" #include "weathericons.h" -/***************************** - * Important: see settings.h to configure your settings!!! - * ***************************/ -#include "settings.h" + #define MINI_BLACK 0 @@ -85,7 +88,7 @@ Carousel carousel(&gfx, 0, 0, 240, 100); #ifdef HAVE_TOUCHPAD XPT2046_Touchscreen ts(TOUCH_CS, TOUCH_IRQ); - TouchController touchController(&ts); + TouchControllerWS touchController(&ts); void calibrationCallback(int16_t x, int16_t y); CalibrationCallback calibration = &calibrationCallback; diff --git a/settings.h b/settings.h index 41eacbf..ed44275 100644 --- a/settings.h +++ b/settings.h @@ -68,7 +68,7 @@ const int SLEEP_INTERVAL_SECS = 0; // Going to Sleep after idle times, set 0 f // e.g. http://api.wunderground.com/api/808ba87ed77c4511/conditions/q/CA/SAN_FRANCISCO.json <- note that in the US you use the state instead of country code const String DISPLAYED_CITY_NAME = "Zürich"; -const String WUNDERGRROUND_API_KEY = "WUNDERGROUND_API_KEY"; +const String WUNDERGRROUND_API_KEY = "WUNDERGROUND_KEY"; const String WUNDERGRROUND_LANGUAGE = "EN"; const String WUNDERGROUND_COUNTRY = "CH"; const String WUNDERGROUND_CITY = "Zurich";