/** The MIT License (MIT) Copyright (c) 2018 David Payne Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Additional Contributions: /* 15 Jan 2019 : Owen Carter : Add psucontrol option and processing */ /********************************************** * Edit Settings.h for personalization ***********************************************/ #include "Settings.h" #define VERSION "3.0" #define HOSTNAME "PrintMon-" #define CONFIG "/conf.txt" /* Useful Constants */ #define SECS_PER_MIN (60UL) #define SECS_PER_HOUR (3600UL) /* Useful Macros for getting elapsed time */ #define numberOfSeconds(_time_) (_time_ % SECS_PER_MIN) #define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN) #define numberOfHours(_time_) (_time_ / SECS_PER_HOUR) // Initialize the oled display for I2C_DISPLAY_ADDRESS // SDA_PIN and SCL_PIN #if defined(DISPLAY_SH1106) SH1106Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); #else SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); // this is the default #endif OLEDDisplayUi ui( &display ); void drawProgress(OLEDDisplay *display, int percentage, String label); void drawOtaProgress(unsigned int, unsigned int); void drawScreen1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawScreen2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state); void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state); // Set the number of Frames supported const int numberOfFrames = 3; FrameCallback frames[numberOfFrames]; FrameCallback clockFrame[2]; boolean isClockOn = false; OverlayCallback overlays[] = { drawHeaderOverlay }; OverlayCallback clockOverlay[] = { drawClockHeaderOverlay }; int numberOfOverlays = 1; // Time TimeClient timeClient(UtcOffset); long lastEpoch = 0; long firstEpoch = 0; long displayOffEpoch = 0; String lastMinute = "xx"; String lastSecond = "xx"; String lastReportStatus = ""; boolean displayOn = true; // Printer Client #if defined(USE_REPETIER_CLIENT) RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU); #else OctoPrintClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU); #endif int printerCount = 0; // Weather Client OpenWeatherMapClient weatherClient(WeatherApiKey, CityIDs, 1, IS_METRIC, WeatherLanguage); //declairing prototypes void configModeCallback (WiFiManager *myWiFiManager); int8_t getWifiQuality(); ESP8266WebServer server(WEBSERVER_PORT); ESP8266HTTPUpdateServer serverUpdater; String WEB_ACTIONS = " Home" " Configure" " Weather" " Reset Settings" " Forget WiFi" " Firmware Update" " About"; String CHANGE_FORM = ""; // moved to setup to make it dynamic String THEME_FORM = "
Theme Color
" "Use Security Credentials for Configuration Changes
" "" "" ""; String WEATHER_FORM = "" ""; String LANG_OPTIONS = "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; String COLOR_THEMES = "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; void setup() { CHANGE_FORM = "