diff --git a/src/Apps/ButtonTest.cpp b/src/Apps/ButtonTest.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Apps/Internal/LayoutObject.cpp b/src/Apps/Internal/LayoutObject.cpp new file mode 100644 index 0000000..6b7a935 --- /dev/null +++ b/src/Apps/Internal/LayoutObject.cpp @@ -0,0 +1,6 @@ +#include "Arduino.h" + +/// @brief Main content of the object +String Content; + +int RequestedWidth = 0; \ No newline at end of file diff --git a/src/Apps/Internal/RendererTool.cpp b/src/Apps/Internal/RendererTool.cpp new file mode 100644 index 0000000..041f626 --- /dev/null +++ b/src/Apps/Internal/RendererTool.cpp @@ -0,0 +1,7 @@ +#include "Arduino.h" + +/// @brief Takes a File, renders it. +/// @param FilePath +void RenderFromFile(String FilePath){ + return; +} \ No newline at end of file diff --git a/src/Apps/TimeSquare/WatchFace.cpp b/src/Apps/TimeSquare/WatchFace.cpp index 9397fdb..c33021e 100644 --- a/src/Apps/TimeSquare/WatchFace.cpp +++ b/src/Apps/TimeSquare/WatchFace.cpp @@ -5,7 +5,7 @@ #include "WatchFace.h" #include "WiFi.h" #include "Location/Geo.h" -#include "OSWBoot/Flags.h" +#include "System/Flags.h" #include "OSWBoot/APIKeys.h" #include #include "System/Input.h" @@ -99,9 +99,7 @@ void WaitForNextUpdate() { secondsToSleep -= 60; } - - - #ifdef UseDelayBasedSleep = true + #if UseDelayBasedSleep msToSleep = secondsToSleep * 1000; while (msToSleep != 0) { diff --git a/src/Display/Display.cpp b/src/Display/Display.cpp index 10bafd3..01d99f2 100644 --- a/src/Display/Display.cpp +++ b/src/Display/Display.cpp @@ -1,20 +1,19 @@ #include "Arduino.h" -#include "OSWBoot/Flags.h" +#include "System/Flags.h" #include "Logging/SysLog.h" #include -#include -#include "Location/Geo.h" +#include #include //Standard Adafruit Library #include // Hardware-specific library for ST7789 -/* ==Display IDs (i.e Who made your display and what type is it) +/* Display IDs (i.e Who made your display and what type is it) 0 - No Display (Just goes to serial) 1 - Adafruit ST7789 Displays. -*///We use the display ID system to save on compiled code space. +We use the display ID system to save on compiled code space.*/ #define DisplayID 1 //Change to value of the display you have. -#ifdef DisplayID == 1 +#if DisplayID == 1 // Adafruit Display Adafruit_ST7789 Display = Adafruit_ST7789(DisplayCSPin, DisplayDCPin, DisplayRSTPin); #endif @@ -25,7 +24,7 @@ /// Display in flags.cpp as OSW WILL NOT detect the display /// This probably won't be bad if you mess it but I wouldn't. void InitaliseDisplay(){ - #ifdef DisplayID == 1 //Adafruit ST7789 + #if DisplayID == 1 //Adafruit ST7789 Log("Display initalising as ST7789", LogLevel::Info); Display.init(240, 280); Display.fillScreen(ST77XX_BLACK); @@ -40,7 +39,7 @@ void InitaliseDisplay(){ /// @brief Prints a Welcome to OSW message showing ///the build name and number. void PrintBootScreen(){ - #ifdef DisplayID == 1 //Adafruit ST7789 + #if DisplayID == 1 //Adafruit ST7789 Display.setTextColor(ST77XX_WHITE, ST77XX_BLACK); Display.setCursor(80,10); Display.println("OpenSW - " + String(Branch) + "!"); @@ -58,7 +57,7 @@ void PrintBootScreen(){ /// @param X Xcoord where to place it (You should also specify X.) /// @param Y Ycoord where to place it (You should also specify Y.) void PrintToDisplay (String Message, int FontSize = 2, bool Newline = true, int X=-1,int Y=-1, int Color=0xFFFFFF){ - #ifdef DisplayID == 1 //Adafruit ST7789 + #if DisplayID == 1 //Adafruit ST7789 Display.setTextSize(FontSize); Display.setTextColor(Color); //Sets text to color (defaults to white.). //Sets cursor if X/Y vars are set. @@ -77,7 +76,7 @@ void PrintToDisplay (String Message, int FontSize = 2, bool Newline = true, int /// @brief Clears the display and resets cursor to 0,0. /// @param Color Color to fill display with (defaults to black.) void ClearDisplay(int Color = 0x00000){ - #ifdef DisplayID == 1 //Adafruit ST7789 + #if DisplayID == 1 //Adafruit ST7789 Display.fillScreen(Color); Display.setCursor(0,0); #else @@ -88,7 +87,7 @@ void ClearDisplay(int Color = 0x00000){ /// @brief This prints a syslog message to the display with coloring. /// @param Message Message to be shown void ShowLog (String Message, String Level, int Color){ - #ifdef DisplayID == 1; //Adafruit ST7789 + #if DisplayID == 1 //Adafruit ST7789 Display.print("["); Display.setTextColor(Color); Display.print(Level); @@ -100,8 +99,8 @@ void ShowLog (String Message, String Level, int Color){ } int GetTextWidth(String Text, int FontSize) -{ - #ifdef DisplayID == 1 //Adafruit ST7789 +{ + #if DisplayID == 1 //Adafruit ST7789 int16_t x1, y1; uint16_t w, h; diff --git a/src/Display/Display.h b/src/Display/Display.h index 2d11f5f..f27f7f5 100644 --- a/src/Display/Display.h +++ b/src/Display/Display.h @@ -4,7 +4,6 @@ #include "Arduino.h" void InitaliseDisplay(); -void PrintHomeScreen(); void PrintBootScreen(); void PrintToDisplay(String Message, int FontSize = 2, bool NewLine=true, int X=-1,int Y=-1, int Color=0xFFFFFF); void ShowLog(String Message, String Level, int Color); diff --git a/src/Location/Geo.cpp b/src/Location/Geo.cpp index b9913e4..0e83625 100644 --- a/src/Location/Geo.cpp +++ b/src/Location/Geo.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -27,13 +27,12 @@ struct WeatherData { unsigned long sunsetTime; }; -//Conver GoogleMapsAPIKey to key for some reason we can't just String(GoogleMapsAPIKey) -String Key = String(GoogleMapsAPIKey); +String Key = GoogleMapsAPIKey; WifiLocation location(Key); void GetLocation(){ if (AllowGeolocation) { - Log("Geoloc disabled.", LogLevel::Warn); + Log("loc disabled.", LogLevel::Warn); return; } diff --git a/src/Logging/SysLog.cpp b/src/Logging/SysLog.cpp index 7dc9d91..ae680a7 100644 --- a/src/Logging/SysLog.cpp +++ b/src/Logging/SysLog.cpp @@ -4,7 +4,7 @@ #include "LogLevel.h" #include "Display/Display.h" #include "System/TimeUtils.h" -#include "OSWBoot/Flags.h" +#include "System/Flags.h" bool SerialInitalised = false; //Will initalise serial and then set to true. bool LogToDisplay = false; //Shows log messages on display. @@ -17,6 +17,9 @@ void Log(String Message, LogLevel level) { int Color = 0xFFFFFF; //RGB in hex after the 0x part. switch (level) { case LogLevel::Debug: + #if !ShowDebugLogs // Supress debug logs if they aren't enabled. + return; + #endif Prefix += "DBG"; Color = 0x001F; // Blue break; @@ -37,8 +40,6 @@ void Log(String Message, LogLevel level) { break; } - //Supress debug logs if enabled. - if (SupressDebugLogs && level == LogLevel::Debug){ return; } if (LogToDisplay) { diff --git a/src/Networking/Networking.cpp b/src/Networking/Networking.cpp index 8317e5e..bc5a247 100644 --- a/src/Networking/Networking.cpp +++ b/src/Networking/Networking.cpp @@ -7,7 +7,7 @@ #include "time.h" #include "Logging/SysLog.h" #include "Arduino.h" -#include "OSWBoot/Flags.h" +#include "System/Flags.h" #include "Arduino.h" #include "rtc.h" #include //Fixes compilation failure relating to WifiLocation, platformIO bug. diff --git a/src/OSWBoot/APIKeys.h b/src/OSWBoot/APIKeys.h index 0d44e17..2e97752 100644 --- a/src/OSWBoot/APIKeys.h +++ b/src/OSWBoot/APIKeys.h @@ -2,5 +2,5 @@ #include -constexpr char* GoogleMapsAPIKey = "API KEY HERE"; -constexpr char* OpenWeatherMapAPIKey = "API KEY HERE"; \ No newline at end of file +const String GoogleMapsAPIKey = "API KEY HERE"; +const String OpenWeatherMapAPIKey = "API KEY HERE"; \ No newline at end of file diff --git a/src/OSWBoot/OSWBoot.cpp b/src/OSWBoot/OSWBoot.cpp index 77c468a..abf0fdd 100644 --- a/src/OSWBoot/OSWBoot.cpp +++ b/src/OSWBoot/OSWBoot.cpp @@ -1,9 +1,9 @@ #include #include "Logging/SysLog.h" -#include "System/SystemInfo.h" +#include "System/Flags.h" #include "Display/Display.h" #include "Networking/Networking.h" -#include "OSWBoot/Flags.h" +#include "System/Flags.h" #include "System/TimeUtils.h" #include "Apps/TimeSquare/WatchFace.h" #include @@ -16,20 +16,20 @@ void Initalise(){ InitaliseDisplay(); - //Log("Hold upper left for config", LogLevel::Info); + Log("Hold any button for config", LogLevel::Info); //ButtonManager.ReadButtons.Contains(UL) => ConfigManager - //delay(500); //Wait 0.5 seconds for any press. + delay(500); //Wait 0.5 seconds for any press. PrintBootScreen(); //Prints the welcome to OSW message to the disp. ShowPowerOnCause(); //Gets why we are here. HandleRTC(); if (DelayBoot) { - Log("BootDelay enabled, press anything to continue", LogLevel::Info); + Log("Press Button to continue", LogLevel::Info); AwaitInput(); } - Log("Init complete, Downclocking to 80MHz",LogLevel::Info); + Log("Boot complete! Downclocking to 80MHz",LogLevel::Info); setCpuFrequencyMhz(80); //esp_sleep_enable_light_sleep_after(100); // this will sleep the cpu after 100ms. diff --git a/src/SDStorage/FileSystem.cpp b/src/SDStorage/FileSystem.cpp index 2d2cc5f..183876a 100644 --- a/src/SDStorage/FileSystem.cpp +++ b/src/SDStorage/FileSystem.cpp @@ -1,10 +1,10 @@ #include "Arduino.h" #include "SD.h" -#include "OSWBoot/Flags.h" +#include "System/Flags.h" #include "Logging/SysLog.h" void InitaliseSDCard() { - if (!SD.begin(DisplaySDPin)) { + if (!SD.begin(SDCardPin)) { Log("SD init Failed.", LogLevel::Error); return; } diff --git a/src/OSWBoot/Flags.h b/src/System/Flags.h similarity index 73% rename from src/OSWBoot/Flags.h rename to src/System/Flags.h index c803a3d..cadda9e 100644 --- a/src/OSWBoot/Flags.h +++ b/src/System/Flags.h @@ -1,9 +1,25 @@ -// OSWConfig.h - Open Smart Watch Configuration Header +// Flags.h - Open Smart Watch Configuration File #ifndef FLAGS_H #define FLAGS_H - #include +// === OSW Version Information === +// Don't edit this UNLESS you know what you are doing! +constexpr int Version[] = {1, 2, 0}; +constexpr const char* ReleaseName = "Reckless Tongue"; +constexpr const char* Branch = "MINIMA"; + +/* Release Name History. + All releases are based on song names, generally music I like. + == Progenitor == + 0.0.C - Kick Back - Kenshi Yonezu + 0.0.F - Wannabe + + == MINIMA == + 1.0.0 - Exhibition Prototype Ultra (K-Rino) + 1.1.0 - Time Out (DJ Hoppa) + 1.2.0 - Reckless Tongue (Airways) */ + // === Feature availability === // Allow or disable OSW features like WiFi. This is NOT the same as turning it off. // If a feature is disabled, trying to use it will just skip the function call. @@ -27,11 +43,11 @@ inline String DefaultWiFiSSID = "DREAMLAND"; // SSID to connect to. inline String DefaultWiFiPass = "NIGHTMARE"; // Password to SSID. // Geolocation Settings -inline int GeolocationCooldown = 90; // How often to ping geo APIs in the background. +inline int GeolocationCooldown = 90; // How often to ping geo APIs in the background. (Seconds) // OSWBoot Settings inline bool DelayBoot = true; // Delays boot until button pressed. -inline bool SupressDebugLogs = true; // Debug logs will be ignored. +const inline bool ShowDebugLogs = false; // Debug logs will be ignored. (requires reflash) // Experimental Settings // Many of these aren't implemented and are more ideas/concepts currently inline bool EnableOTAMenu = true; // Allows OTAs. // Not implemented. @@ -42,15 +58,12 @@ inline bool Autoregion = false; //Unimplemented, Use Geoloc and Weather APIs to inline bool AllowBluetooth = true; //Unimplemented, Enables Bluetooth //=== HARDWARE INFO === -// These are considered read-only. -// To change these you will need to reflash OSW. -const bool UseDelayBasedSleep = true; //Set true to use Delays instead of ESP32 Light Sleep +// These are considered read-only, changing these requires a reflash. +const bool UseDelayBasedSleep = true; //Set to false if your ESP model supports wake from GPIO (ESP32-S3 ) const int DisplayWidth = 240; // Display Width in pixels const int DisplayHeight = 280; // Display Height in pixels //To set your display type please go to Display.cpp - -// SD Card Pins -const int DisplaySDPin = 5; +const int SDCardPin = 5; // ST7789 Pins const int DisplayCSPin = 21; @@ -61,4 +74,4 @@ const int DisplayDCPin = 20; const int ButtonAPin = 3; const int ButtonBPin = 4; -#endif // OSWCONFIG_H +#endif \ No newline at end of file diff --git a/src/System/Input.cpp b/src/System/Input.cpp index 4ea8754..698b5d2 100644 --- a/src/System/Input.cpp +++ b/src/System/Input.cpp @@ -1,5 +1,5 @@ #include -#include "OSWBoot/Flags.h" +#include "System/Flags.h" #include "Logging/SysLog.h" /// @brief This initalises buttons attached to OSW @@ -13,19 +13,28 @@ void InitaliseInput(){ } /// @brief Loops until ButtonA and/or ButtonB are pressed +/// @param Timeout The timeout duration in milliseconds (0 for no timeout). /// @return An array of booleans, corresponding to if button a or b are pressed. bool* AwaitInput(int Timeout = 0){ Log("Waiting for a button press..",LogLevel::Info); bool ButtonAVal = false; bool ButtonBVal = false; + unsigned long startTime = millis(); // Record the start time while (ButtonAVal == false && ButtonBVal == false) { + // Check for button states ButtonAVal = (analogRead(ButtonAPin) == 4095); ButtonBVal = (analogRead(ButtonBPin) == 4095); - Log("AVal:" + String(ButtonAVal) + " BVal: " + String(ButtonBVal),LogLevel::Debug); + + Log("AVal:" + String(ButtonAVal) + " BVal: " + String(ButtonBVal), LogLevel::Debug); + + // Check for timeout if Timeout is not 0 + if (Timeout > 0 && (millis() - startTime) >= Timeout) { + Log("Timeout reached!", LogLevel::Info); + break; // Exit the loop if timeout has been reached + } } - Log("Button pressed!",LogLevel::Info); return new bool[2] {ButtonAVal, ButtonBVal}; } \ No newline at end of file diff --git a/src/System/SystemInfo.h b/src/System/SystemInfo.h deleted file mode 100644 index a0cab33..0000000 --- a/src/System/SystemInfo.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef VERSION_H -#define VERSION_H - -constexpr int Version[] = {1, 1, 0}; -constexpr const char* ReleaseName = "Reckless Tongue"; -constexpr const char* Branch = "MINIMA"; - -/* ReleaseName Idea's History - All releases are based on song names, generally what I was listening to - at the time I had to name it. - List of every release name: - - ==Progenitor== - Kick Back - Kenshi Yonezu - Progenitor Revision C - Wannabe - Progenitor Final Revision - - ==MINIMA== - 1.0.0 - Exhibition Prototype Ultra (K-Rino) - 1.1.0 - Time Out (DJ Hoppa) - 1.2.0 - Reckless Tongue (Airways) */ -#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index fc3d73c..8382a7c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include /// @brief Calls OSWBoot.Initalise()