Move Fuzzy into Digital, restore Paint
This commit is contained in:
		
							parent
							
								
									66f6c34b50
								
							
						
					
					
						commit
						d2989ae23a
					
				@ -366,7 +366,7 @@ list(APPEND SOURCE_FILES
 | 
				
			|||||||
        displayapp/DisplayApp.cpp
 | 
					        displayapp/DisplayApp.cpp
 | 
				
			||||||
        displayapp/screens/Screen.cpp
 | 
					        displayapp/screens/Screen.cpp
 | 
				
			||||||
        displayapp/screens/Tile.cpp
 | 
					        displayapp/screens/Tile.cpp
 | 
				
			||||||
        #displayapp/screens/InfiniPaint.cpp
 | 
					        displayapp/screens/InfiniPaint.cpp
 | 
				
			||||||
        displayapp/screens/Paddle.cpp
 | 
					        displayapp/screens/Paddle.cpp
 | 
				
			||||||
        displayapp/screens/StopWatch.cpp
 | 
					        displayapp/screens/StopWatch.cpp
 | 
				
			||||||
        displayapp/screens/BatteryIcon.cpp
 | 
					        displayapp/screens/BatteryIcon.cpp
 | 
				
			||||||
@ -423,7 +423,6 @@ list(APPEND SOURCE_FILES
 | 
				
			|||||||
        #displayapp/screens/WatchFaceTerminal.cpp
 | 
					        #displayapp/screens/WatchFaceTerminal.cpp
 | 
				
			||||||
        displayapp/screens/WatchFacePineTimeStyle.cpp
 | 
					        displayapp/screens/WatchFacePineTimeStyle.cpp
 | 
				
			||||||
        #displayapp/screens/WatchFaceCasioStyleG7710.cpp
 | 
					        #displayapp/screens/WatchFaceCasioStyleG7710.cpp
 | 
				
			||||||
        displayapp/screens/WatchFaceFuzzy.cpp
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ##
 | 
					        ##
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -590,7 +589,7 @@ set(INCLUDE_FILES
 | 
				
			|||||||
        displayapp/TouchEvents.h
 | 
					        displayapp/TouchEvents.h
 | 
				
			||||||
        displayapp/screens/Screen.h
 | 
					        displayapp/screens/Screen.h
 | 
				
			||||||
        displayapp/screens/Tile.h
 | 
					        displayapp/screens/Tile.h
 | 
				
			||||||
        #displayapp/screens/InfiniPaint.h
 | 
					        displayapp/screens/InfiniPaint.h
 | 
				
			||||||
        displayapp/screens/StopWatch.h
 | 
					        displayapp/screens/StopWatch.h
 | 
				
			||||||
        displayapp/screens/Paddle.h
 | 
					        displayapp/screens/Paddle.h
 | 
				
			||||||
        displayapp/screens/BatteryIcon.h
 | 
					        displayapp/screens/BatteryIcon.h
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ namespace Pinetime {
 | 
				
			|||||||
  namespace Controllers {
 | 
					  namespace Controllers {
 | 
				
			||||||
    class Settings {
 | 
					    class Settings {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
      enum class ClockType : uint8_t { H24, H12 };
 | 
					      enum class ClockType : uint8_t { H24, H12, Fuzzy };
 | 
				
			||||||
      enum class WeatherFormat : uint8_t { Metric, Imperial };
 | 
					      enum class WeatherFormat : uint8_t { Metric, Imperial };
 | 
				
			||||||
      enum class Notification : uint8_t { On, Off, Sleep };
 | 
					      enum class Notification : uint8_t { On, Off, Sleep };
 | 
				
			||||||
      enum class ChimesOption : uint8_t { None, Hours, HalfHours };
 | 
					      enum class ChimesOption : uint8_t { None, Hours, HalfHours };
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@
 | 
				
			|||||||
#include "displayapp/screens/ApplicationList.h"
 | 
					#include "displayapp/screens/ApplicationList.h"
 | 
				
			||||||
#include "displayapp/screens/FirmwareUpdate.h"
 | 
					#include "displayapp/screens/FirmwareUpdate.h"
 | 
				
			||||||
#include "displayapp/screens/FirmwareValidation.h"
 | 
					#include "displayapp/screens/FirmwareValidation.h"
 | 
				
			||||||
//#include "displayapp/screens/InfiniPaint.h"
 | 
					#include "displayapp/screens/InfiniPaint.h"
 | 
				
			||||||
#include "displayapp/screens/Paddle.h"
 | 
					#include "displayapp/screens/Paddle.h"
 | 
				
			||||||
#include "displayapp/screens/StopWatch.h"
 | 
					#include "displayapp/screens/StopWatch.h"
 | 
				
			||||||
#include "displayapp/screens/Metronome.h"
 | 
					#include "displayapp/screens/Metronome.h"
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,6 @@
 | 
				
			|||||||
#include "displayapp/screens/WatchFaceInfineat.h"
 | 
					#include "displayapp/screens/WatchFaceInfineat.h"
 | 
				
			||||||
#include "displayapp/screens/WatchFacePineTimeStyle.h"
 | 
					#include "displayapp/screens/WatchFacePineTimeStyle.h"
 | 
				
			||||||
//#include "displayapp/screens/WatchFaceTerminal.h"
 | 
					//#include "displayapp/screens/WatchFaceTerminal.h"
 | 
				
			||||||
#include "displayapp/screens/WatchFaceFuzzy.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pinetime {
 | 
					namespace Pinetime {
 | 
				
			||||||
  namespace Applications {
 | 
					  namespace Applications {
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@ namespace Pinetime {
 | 
				
			|||||||
      FlashLight,
 | 
					      FlashLight,
 | 
				
			||||||
      BatteryInfo,
 | 
					      BatteryInfo,
 | 
				
			||||||
      Music,
 | 
					      Music,
 | 
				
			||||||
      //Paint,
 | 
					      Paint,
 | 
				
			||||||
      Paddle,
 | 
					      Paddle,
 | 
				
			||||||
      Twos,
 | 
					      Twos,
 | 
				
			||||||
      HeartRate,
 | 
					      HeartRate,
 | 
				
			||||||
@ -51,7 +51,6 @@ namespace Pinetime {
 | 
				
			|||||||
      Terminal,
 | 
					      Terminal,
 | 
				
			||||||
      Infineat,
 | 
					      Infineat,
 | 
				
			||||||
      CasioStyleG7710,
 | 
					      CasioStyleG7710,
 | 
				
			||||||
      Fuzzy,
 | 
					 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    template <Apps>
 | 
					    template <Apps>
 | 
				
			||||||
@ -76,9 +75,8 @@ namespace Pinetime {
 | 
				
			|||||||
                                                 WatchFace::Analog,
 | 
					                                                 WatchFace::Analog,
 | 
				
			||||||
                                                 WatchFace::PineTimeStyle,
 | 
					                                                 WatchFace::PineTimeStyle,
 | 
				
			||||||
                                                 //WatchFace::Terminal,
 | 
					                                                 //WatchFace::Terminal,
 | 
				
			||||||
                                                 WatchFace::Infineat,
 | 
					 | 
				
			||||||
                                                 //WatchFace::CasioStyleG7710,
 | 
					                                                 //WatchFace::CasioStyleG7710,
 | 
				
			||||||
                                                 WatchFace::Fuzzy>;
 | 
					                                                 WatchFace::Infineat>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static_assert(UserWatchFaceTypes::Count >= 1);
 | 
					    static_assert(UserWatchFaceTypes::Count >= 1);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										72
									
								
								src/displayapp/screens/InfiniPaint.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								src/displayapp/screens/InfiniPaint.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,72 @@
 | 
				
			|||||||
 | 
					#include "displayapp/screens/InfiniPaint.h"
 | 
				
			||||||
 | 
					#include "displayapp/DisplayApp.h"
 | 
				
			||||||
 | 
					#include "displayapp/LittleVgl.h"
 | 
				
			||||||
 | 
					#include "displayapp/InfiniTimeTheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <algorithm> // std::fill
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace Pinetime::Applications::Screens;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					InfiniPaint::InfiniPaint(Pinetime::Components::LittleVgl& lvgl, Pinetime::Controllers::MotorController& motor)
 | 
				
			||||||
 | 
					  : lvgl {lvgl}, motor {motor} {
 | 
				
			||||||
 | 
					  std::fill(b, b + bufferSize, selectColor);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					InfiniPaint::~InfiniPaint() {
 | 
				
			||||||
 | 
					  lv_obj_clean(lv_scr_act());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
 | 
				
			||||||
 | 
					  switch (event) {
 | 
				
			||||||
 | 
					    case Pinetime::Applications::TouchEvents::LongTap:
 | 
				
			||||||
 | 
					      color = (color + 1) % 8;
 | 
				
			||||||
 | 
					      switch (color) {
 | 
				
			||||||
 | 
					        case 0:
 | 
				
			||||||
 | 
					          selectColor = LV_COLOR_MAGENTA;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 1:
 | 
				
			||||||
 | 
					          selectColor = Colors::green;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 2:
 | 
				
			||||||
 | 
					          selectColor = LV_COLOR_WHITE;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 3:
 | 
				
			||||||
 | 
					          selectColor = LV_COLOR_RED;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 4:
 | 
				
			||||||
 | 
					          selectColor = LV_COLOR_CYAN;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 5:
 | 
				
			||||||
 | 
					          selectColor = LV_COLOR_YELLOW;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 6:
 | 
				
			||||||
 | 
					          selectColor = LV_COLOR_BLUE;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 7:
 | 
				
			||||||
 | 
					          selectColor = LV_COLOR_BLACK;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					          color = 0;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      std::fill(b, b + bufferSize, selectColor);
 | 
				
			||||||
 | 
					      motor.RunForDuration(35);
 | 
				
			||||||
 | 
					      return true;
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					      return true;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) {
 | 
				
			||||||
 | 
					  lv_area_t area;
 | 
				
			||||||
 | 
					  area.x1 = x - (width / 2);
 | 
				
			||||||
 | 
					  area.y1 = y - (height / 2);
 | 
				
			||||||
 | 
					  area.x2 = x + (width / 2) - 1;
 | 
				
			||||||
 | 
					  area.y2 = y + (height / 2) - 1;
 | 
				
			||||||
 | 
					  lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None);
 | 
				
			||||||
 | 
					  lvgl.FlushDisplay(&area, b);
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										52
									
								
								src/displayapp/screens/InfiniPaint.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								src/displayapp/screens/InfiniPaint.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <lvgl/lvgl.h>
 | 
				
			||||||
 | 
					#include <cstdint>
 | 
				
			||||||
 | 
					#include <algorithm> // std::fill
 | 
				
			||||||
 | 
					#include "displayapp/screens/Screen.h"
 | 
				
			||||||
 | 
					#include "components/motor/MotorController.h"
 | 
				
			||||||
 | 
					#include "Symbols.h"
 | 
				
			||||||
 | 
					#include "displayapp/apps/Apps.h"
 | 
				
			||||||
 | 
					#include <displayapp/Controllers.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Pinetime {
 | 
				
			||||||
 | 
					  namespace Components {
 | 
				
			||||||
 | 
					    class LittleVgl;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  namespace Applications {
 | 
				
			||||||
 | 
					    namespace Screens {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      class InfiniPaint : public Screen {
 | 
				
			||||||
 | 
					      public:
 | 
				
			||||||
 | 
					        InfiniPaint(Pinetime::Components::LittleVgl& lvgl, Controllers::MotorController& motor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ~InfiniPaint() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool OnTouchEvent(TouchEvents event) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool OnTouchEvent(uint16_t x, uint16_t y) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      private:
 | 
				
			||||||
 | 
					        Pinetime::Components::LittleVgl& lvgl;
 | 
				
			||||||
 | 
					        Controllers::MotorController& motor;
 | 
				
			||||||
 | 
					        static constexpr uint16_t width = 10;
 | 
				
			||||||
 | 
					        static constexpr uint16_t height = 10;
 | 
				
			||||||
 | 
					        static constexpr uint16_t bufferSize = width * height;
 | 
				
			||||||
 | 
					        lv_color_t b[bufferSize];
 | 
				
			||||||
 | 
					        lv_color_t selectColor = LV_COLOR_WHITE;
 | 
				
			||||||
 | 
					        uint8_t color = 2;
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    template <>
 | 
				
			||||||
 | 
					    struct AppTraits<Apps::Paint> {
 | 
				
			||||||
 | 
					      static constexpr Apps app = Apps::Paint;
 | 
				
			||||||
 | 
					      static constexpr const char* icon = Screens::Symbols::paintbrush;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      static Screens::Screen* Create(AppControllers& controllers) {
 | 
				
			||||||
 | 
					        return new Screens::InfiniPaint(controllers.lvgl, controllers.motorController);
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -91,7 +91,26 @@ void WatchFaceDigital::Refresh() {
 | 
				
			|||||||
    uint8_t hour = dateTimeController.Hours();
 | 
					    uint8_t hour = dateTimeController.Hours();
 | 
				
			||||||
    uint8_t minute = dateTimeController.Minutes();
 | 
					    uint8_t minute = dateTimeController.Minutes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
 | 
					    /* Begin difference from WatchFaceDigital*/
 | 
				
			||||||
 | 
					    if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
 | 
				
			||||||
 | 
					      std::string hourStr, timeStr;
 | 
				
			||||||
 | 
					      auto sector = minute / 5 + (minute % 5 > 2);
 | 
				
			||||||
 | 
					      if (sector == 12) {
 | 
				
			||||||
 | 
					        hour = (hour + 1) % 12;
 | 
				
			||||||
 | 
					        sector = 0;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      timeStr = timeSectors[sector];
 | 
				
			||||||
 | 
					      if (timeStr.find("%1") != std::string::npos) {
 | 
				
			||||||
 | 
					        hour = (hour + 1) % 12;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      hourStr = std::string("#") + timeAccent + " " + hourNames[hour] + "#";
 | 
				
			||||||
 | 
					      timeStr.replace(timeStr.find("%"), 2, hourStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      lv_label_set_text(label_time, timeStr.c_str());
 | 
				
			||||||
 | 
					      lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
 | 
				
			||||||
 | 
					    /* End difference from WatchFaceDigital*/
 | 
				
			||||||
 | 
					    } else if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
 | 
				
			||||||
      char ampmChar[3] = "AM";
 | 
					      char ampmChar[3] = "AM";
 | 
				
			||||||
      if (hour == 0) {
 | 
					      if (hour == 0) {
 | 
				
			||||||
        hour = 12;
 | 
					        hour = 12;
 | 
				
			||||||
@ -154,3 +173,39 @@ void WatchFaceDigital::Refresh() {
 | 
				
			|||||||
    lv_obj_realign(stepIcon);
 | 
					    lv_obj_realign(stepIcon);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Inspired by XFCE4-panel's fuzzy clock.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *      https://salsa.debian.org/xfce-team/desktop/xfce4-panel/-/blob/debian/master/plugins/clock/clock-fuzzy.c
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Strings contain either a `%0` or a `%1`, indicating the position of
 | 
				
			||||||
 | 
					 * the `hour` or `hour+1`, respectively.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					const char* WatchFaceDigital::timeSectors[] = {
 | 
				
			||||||
 | 
					  "%0\no'clock",
 | 
				
			||||||
 | 
					  "five past\n%0",
 | 
				
			||||||
 | 
					  "ten past\n%0",
 | 
				
			||||||
 | 
					  "quarter\npast\n%0",
 | 
				
			||||||
 | 
					  "twenty\npast\n%0",
 | 
				
			||||||
 | 
					  "twenty\nfive past\n%0",
 | 
				
			||||||
 | 
					  "half past\n%0",
 | 
				
			||||||
 | 
					  "twenty\nfive to\n%1",
 | 
				
			||||||
 | 
					  "twenty\nto %1",
 | 
				
			||||||
 | 
					  "quarter\nto %1",
 | 
				
			||||||
 | 
					  "ten to\n%1",
 | 
				
			||||||
 | 
					  "five to\n%1",
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					const char* WatchFaceDigital::hourNames[] = {
 | 
				
			||||||
 | 
					  "twelve",
 | 
				
			||||||
 | 
					  "one",
 | 
				
			||||||
 | 
					  "two",
 | 
				
			||||||
 | 
					  "three",
 | 
				
			||||||
 | 
					  "four",
 | 
				
			||||||
 | 
					  "five",
 | 
				
			||||||
 | 
					  "six",
 | 
				
			||||||
 | 
					  "seven",
 | 
				
			||||||
 | 
					  "eight",
 | 
				
			||||||
 | 
					  "nine",
 | 
				
			||||||
 | 
					  "ten",
 | 
				
			||||||
 | 
					  "eleven",
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -38,8 +38,11 @@ namespace Pinetime {
 | 
				
			|||||||
        void Refresh() override;
 | 
					        void Refresh() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      private:
 | 
					      private:
 | 
				
			||||||
 | 
					        const char* timeAccent = "ffffff";
 | 
				
			||||||
        uint8_t displayedHour = -1;
 | 
					        uint8_t displayedHour = -1;
 | 
				
			||||||
        uint8_t displayedMinute = -1;
 | 
					        uint8_t displayedMinute = -1;
 | 
				
			||||||
 | 
					        static const char* timeSectors[12];
 | 
				
			||||||
 | 
					        static const char* hourNames[12];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
 | 
					        Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
 | 
				
			||||||
        Utility::DirtyValue<bool> powerPresent {};
 | 
					        Utility::DirtyValue<bool> powerPresent {};
 | 
				
			||||||
 | 
				
			|||||||
@ -1,312 +0,0 @@
 | 
				
			|||||||
#include "displayapp/screens/WatchFaceFuzzy.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <lvgl/lvgl.h>
 | 
					 | 
				
			||||||
#include <cstdio>
 | 
					 | 
				
			||||||
#include "displayapp/screens/NotificationIcon.h"
 | 
					 | 
				
			||||||
#include "displayapp/screens/Symbols.h"
 | 
					 | 
				
			||||||
#include "components/battery/BatteryController.h"
 | 
					 | 
				
			||||||
#include "components/ble/BleController.h"
 | 
					 | 
				
			||||||
#include "components/ble/NotificationManager.h"
 | 
					 | 
				
			||||||
#include "components/heartrate/HeartRateController.h"
 | 
					 | 
				
			||||||
#include "components/motion/MotionController.h"
 | 
					 | 
				
			||||||
#include "components/settings/Settings.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace Pinetime::Applications::Screens;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
 | 
					 | 
				
			||||||
                                   const Controllers::Battery& batteryController,
 | 
					 | 
				
			||||||
                                   const Controllers::Ble& bleController,
 | 
					 | 
				
			||||||
                                   Controllers::NotificationManager& notificationManager,
 | 
					 | 
				
			||||||
                                   Controllers::Settings& settingsController,
 | 
					 | 
				
			||||||
                                   Controllers::HeartRateController& heartRateController,
 | 
					 | 
				
			||||||
                                   Controllers::MotionController& motionController)
 | 
					 | 
				
			||||||
  : currentDateTime {{}},
 | 
					 | 
				
			||||||
    dateTimeController {dateTimeController},
 | 
					 | 
				
			||||||
    notificationManager {notificationManager},
 | 
					 | 
				
			||||||
    settingsController {settingsController},
 | 
					 | 
				
			||||||
    heartRateController {heartRateController},
 | 
					 | 
				
			||||||
    motionController {motionController},
 | 
					 | 
				
			||||||
    statusIcons(batteryController, bleController) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  statusIcons.Create();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  notificationIcon = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME);
 | 
					 | 
				
			||||||
  lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
 | 
					 | 
				
			||||||
  lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  label_date = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
 | 
					 | 
				
			||||||
  lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  label_time = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  label_time_ampm = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_label_set_text_static(label_time_ampm, "");
 | 
					 | 
				
			||||||
  lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
 | 
					 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
  heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
 | 
					 | 
				
			||||||
  lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
 | 
					 | 
				
			||||||
  lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
 | 
					 | 
				
			||||||
  lv_label_set_text_static(heartbeatValue, "");
 | 
					 | 
				
			||||||
  lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  stepValue = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
 | 
					 | 
				
			||||||
  lv_label_set_text_static(stepValue, "0");
 | 
					 | 
				
			||||||
  lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  stepIcon = lv_label_create(lv_scr_act(), nullptr);
 | 
					 | 
				
			||||||
  lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
 | 
					 | 
				
			||||||
  lv_label_set_text_static(stepIcon, Symbols::shoe);
 | 
					 | 
				
			||||||
  lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
  taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
 | 
					 | 
				
			||||||
  Refresh();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
WatchFaceFuzzy::~WatchFaceFuzzy() {
 | 
					 | 
				
			||||||
  lv_task_del(taskRefresh);
 | 
					 | 
				
			||||||
  lv_obj_clean(lv_scr_act());
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void WatchFaceFuzzy::Refresh() {
 | 
					 | 
				
			||||||
  statusIcons.Update();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  notificationState = notificationManager.AreNewNotificationsAvailable();
 | 
					 | 
				
			||||||
  if (notificationState.IsUpdated()) {
 | 
					 | 
				
			||||||
    lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (currentDateTime.IsUpdated()) {
 | 
					 | 
				
			||||||
    uint8_t hour = dateTimeController.Hours();
 | 
					 | 
				
			||||||
    uint8_t minute = dateTimeController.Minutes();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /* Begin difference from WatchFaceDigital*/
 | 
					 | 
				
			||||||
    std::string hourStr, timeStr;
 | 
					 | 
				
			||||||
    auto sector = minute / 5 + (minute % 5 > 2);
 | 
					 | 
				
			||||||
    if (sector == 12) {
 | 
					 | 
				
			||||||
      hour = (hour + 1) % 12;
 | 
					 | 
				
			||||||
      sector = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    timeStr = timeSectors[sector];
 | 
					 | 
				
			||||||
    if (timeStr.find("%1") != std::string::npos) {
 | 
					 | 
				
			||||||
      hour = (hour + 1) % 12;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    hourStr = std::string("#") + timeAccent + " " + hourNames[hour] + "#";
 | 
					 | 
				
			||||||
    timeStr.replace(timeStr.find("%"), 2, hourStr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    lv_label_set_text(label_time, timeStr.c_str());
 | 
					 | 
				
			||||||
    lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
 | 
					 | 
				
			||||||
    /* End difference from WatchFaceDigital*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
 | 
					 | 
				
			||||||
    if (currentDate.IsUpdated()) {
 | 
					 | 
				
			||||||
      uint16_t year = dateTimeController.Year();
 | 
					 | 
				
			||||||
      uint8_t day = dateTimeController.Day();
 | 
					 | 
				
			||||||
      if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
 | 
					 | 
				
			||||||
        lv_label_set_text_fmt(label_date,
 | 
					 | 
				
			||||||
                              "%s %d %s %d",
 | 
					 | 
				
			||||||
                              dateTimeController.DayOfWeekShortToString(),
 | 
					 | 
				
			||||||
                              day,
 | 
					 | 
				
			||||||
                              dateTimeController.MonthShortToString(),
 | 
					 | 
				
			||||||
                              year);
 | 
					 | 
				
			||||||
      } else {
 | 
					 | 
				
			||||||
        lv_label_set_text_fmt(label_date,
 | 
					 | 
				
			||||||
                              "%s %s %d %d",
 | 
					 | 
				
			||||||
                              dateTimeController.DayOfWeekShortToString(),
 | 
					 | 
				
			||||||
                              dateTimeController.MonthShortToString(),
 | 
					 | 
				
			||||||
                              day,
 | 
					 | 
				
			||||||
                              year);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      lv_obj_realign(label_date);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
  heartbeat = heartRateController.HeartRate();
 | 
					 | 
				
			||||||
  heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
 | 
					 | 
				
			||||||
  if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
 | 
					 | 
				
			||||||
    if (heartbeatRunning.Get()) {
 | 
					 | 
				
			||||||
      lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
 | 
					 | 
				
			||||||
      lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
 | 
					 | 
				
			||||||
      lv_label_set_text_static(heartbeatValue, "");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    lv_obj_realign(heartbeatIcon);
 | 
					 | 
				
			||||||
    lv_obj_realign(heartbeatValue);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  stepCount = motionController.NbSteps();
 | 
					 | 
				
			||||||
  if (stepCount.IsUpdated()) {
 | 
					 | 
				
			||||||
    lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
 | 
					 | 
				
			||||||
    lv_obj_realign(stepValue);
 | 
					 | 
				
			||||||
    lv_obj_realign(stepIcon);
 | 
					 | 
				
			||||||
  }*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Inspired by XFCE4-panel's fuzzy clock.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *      https://salsa.debian.org/xfce-team/desktop/xfce4-panel/-/blob/debian/master/plugins/clock/clock-fuzzy.c
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Strings contain either a `%0` or a `%1`, indicating the position of
 | 
					 | 
				
			||||||
 * the `hour` or `hour+1`, respectively.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const char* WatchFaceFuzzy::timeSectors[] = {
 | 
					 | 
				
			||||||
  "%0\no'clock",
 | 
					 | 
				
			||||||
  "five past\n%0",
 | 
					 | 
				
			||||||
  "ten past\n%0",
 | 
					 | 
				
			||||||
  "quarter\npast\n%0",
 | 
					 | 
				
			||||||
  "twenty\npast\n%0",
 | 
					 | 
				
			||||||
  "twenty\nfive past\n%0",
 | 
					 | 
				
			||||||
  "half past\n%0",
 | 
					 | 
				
			||||||
  "twenty\nfive to\n%1",
 | 
					 | 
				
			||||||
  "twenty\nto %1",
 | 
					 | 
				
			||||||
  "quarter\nto %1",
 | 
					 | 
				
			||||||
  "ten to\n%1",
 | 
					 | 
				
			||||||
  "five to\n%1",
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
const char* WatchFaceFuzzy::hourNames[] = {
 | 
					 | 
				
			||||||
  "twelve",
 | 
					 | 
				
			||||||
  "one",
 | 
					 | 
				
			||||||
  "two",
 | 
					 | 
				
			||||||
  "three",
 | 
					 | 
				
			||||||
  "four",
 | 
					 | 
				
			||||||
  "five",
 | 
					 | 
				
			||||||
  "six",
 | 
					 | 
				
			||||||
  "seven",
 | 
					 | 
				
			||||||
  "eight",
 | 
					 | 
				
			||||||
  "nine",
 | 
					 | 
				
			||||||
  "ten",
 | 
					 | 
				
			||||||
  "eleven",
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Once i18n is implemented, new languages can be introduced like this:
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * const char* ca-ES_sectors[] = {
 | 
					 | 
				
			||||||
 *   "%0\nen punt",
 | 
					 | 
				
			||||||
 *   "%0\ni cinc",
 | 
					 | 
				
			||||||
 *   "%0\ni deu",
 | 
					 | 
				
			||||||
 *   "%0\ni quart",
 | 
					 | 
				
			||||||
 *   "%0\ni vint",
 | 
					 | 
				
			||||||
 *   "%0\ni vint-\ni-cinc",
 | 
					 | 
				
			||||||
 *   "%0\ni mitja",
 | 
					 | 
				
			||||||
 *   "%1\nmenys\nvint-\ni-cinc",
 | 
					 | 
				
			||||||
 *   "%1\nmenys\nvint",
 | 
					 | 
				
			||||||
 *   "%1\nmenys\nquart",
 | 
					 | 
				
			||||||
 *   "%1\nmenys deu",
 | 
					 | 
				
			||||||
 *   "%1\nmenys\ncinc",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 * const char* ca-ES_hourNames[] = {
 | 
					 | 
				
			||||||
 *   "les dotze",
 | 
					 | 
				
			||||||
 *   "la una",
 | 
					 | 
				
			||||||
 *   "les dues",
 | 
					 | 
				
			||||||
 *   "les tres",
 | 
					 | 
				
			||||||
 *   "les\nquatre",
 | 
					 | 
				
			||||||
 *   "les cinc",
 | 
					 | 
				
			||||||
 *   "les sis",
 | 
					 | 
				
			||||||
 *   "les set",
 | 
					 | 
				
			||||||
 *   "les vuit",
 | 
					 | 
				
			||||||
 *   "les nou",
 | 
					 | 
				
			||||||
 *   "les deu",
 | 
					 | 
				
			||||||
 *   "les onze",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * const char* es-ES_sectors[] = {
 | 
					 | 
				
			||||||
 *   "%0\nen punto",
 | 
					 | 
				
			||||||
 *   "%0\ny cinco",
 | 
					 | 
				
			||||||
 *   "%0\ny diez",
 | 
					 | 
				
			||||||
 *   "%0\ny cuarto",
 | 
					 | 
				
			||||||
 *   "%0\ny veinte",
 | 
					 | 
				
			||||||
 *   "%0\ny veinti\ncinco",
 | 
					 | 
				
			||||||
 *   "%0\ny media",
 | 
					 | 
				
			||||||
 *   "%1\nmenos\nveinti\ncinco",
 | 
					 | 
				
			||||||
 *   "%1\nmenos\nveinte",
 | 
					 | 
				
			||||||
 *   "%1\nmenos\ncuarto",
 | 
					 | 
				
			||||||
 *   "%1\nmenos\ndiez",
 | 
					 | 
				
			||||||
 *   "%1\nmenos\ncinco",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 * const char* es-ES_hourNames[] = {
 | 
					 | 
				
			||||||
 *   "las doce",
 | 
					 | 
				
			||||||
 *   "la una",
 | 
					 | 
				
			||||||
 *   "las dos",
 | 
					 | 
				
			||||||
 *   "las tres",
 | 
					 | 
				
			||||||
 *   "las\ncuatro",
 | 
					 | 
				
			||||||
 *   "las cinco",
 | 
					 | 
				
			||||||
 *   "las seis",
 | 
					 | 
				
			||||||
 *   "las siete",
 | 
					 | 
				
			||||||
 *   "las ocho",
 | 
					 | 
				
			||||||
 *   "las nueve",
 | 
					 | 
				
			||||||
 *   "las diez",
 | 
					 | 
				
			||||||
 *   "las once",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * char* it-IT_sectors[] = {
 | 
					 | 
				
			||||||
 *   "%0\nin punto",
 | 
					 | 
				
			||||||
 *   "%0 e cinque",
 | 
					 | 
				
			||||||
 *   "%0 e dieci",
 | 
					 | 
				
			||||||
 *   "%0 e un quarto",
 | 
					 | 
				
			||||||
 *   "%0 e venti",
 | 
					 | 
				
			||||||
 *   "%0 e venti cinque",
 | 
					 | 
				
			||||||
 *   "%0 e mezza",
 | 
					 | 
				
			||||||
 *   "%0 e trenta cinque",
 | 
					 | 
				
			||||||
 *   "%1 meno venti",
 | 
					 | 
				
			||||||
 *   "%1 meno un quarto",
 | 
					 | 
				
			||||||
 *   "%1 meno dieci",
 | 
					 | 
				
			||||||
 *   "%1 meno cinque",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 * const char* it-IT_hourNames[] = {
 | 
					 | 
				
			||||||
 *   "dodici",
 | 
					 | 
				
			||||||
 *   "una",
 | 
					 | 
				
			||||||
 *   "due",
 | 
					 | 
				
			||||||
 *   "tre",
 | 
					 | 
				
			||||||
 *   "quattro",
 | 
					 | 
				
			||||||
 *   "cinque",
 | 
					 | 
				
			||||||
 *   "sei",
 | 
					 | 
				
			||||||
 *   "sette",
 | 
					 | 
				
			||||||
 *   "otto",
 | 
					 | 
				
			||||||
 *   "nove",
 | 
					 | 
				
			||||||
 *   "dieci",
 | 
					 | 
				
			||||||
 *   "undici",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * const char* de_DE_sectors[] = {
 | 
					 | 
				
			||||||
 *   "%0 Uhr",
 | 
					 | 
				
			||||||
 *   "Fünf nach %0",
 | 
					 | 
				
			||||||
 *   "Zehn nach %0",
 | 
					 | 
				
			||||||
 *   "Viertel nach %0",
 | 
					 | 
				
			||||||
 *   "Zwanzig nach %0",
 | 
					 | 
				
			||||||
 *   "Fünf vor halb %1",
 | 
					 | 
				
			||||||
 *   "Halb %1",
 | 
					 | 
				
			||||||
 *   "Fünf nach halb %1",
 | 
					 | 
				
			||||||
 *   "Zwanzig vor %1",
 | 
					 | 
				
			||||||
 *   "Viertel vor %1",
 | 
					 | 
				
			||||||
 *   "Zehn vor %1",
 | 
					 | 
				
			||||||
 *   "Fünf vor %1",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 * const char* de_DE_hourNames[] = {
 | 
					 | 
				
			||||||
 *   "Zwölf",
 | 
					 | 
				
			||||||
 *   "Eins", // TODO: "Ein" in "Ein Uhr"
 | 
					 | 
				
			||||||
 *   "Zwei",
 | 
					 | 
				
			||||||
 *   "Drei",
 | 
					 | 
				
			||||||
 *   "Vier",
 | 
					 | 
				
			||||||
 *   "Fünf",
 | 
					 | 
				
			||||||
 *   "Sechs",
 | 
					 | 
				
			||||||
 *   "Sieben",
 | 
					 | 
				
			||||||
 *   "Acht",
 | 
					 | 
				
			||||||
 *   "Neun",
 | 
					 | 
				
			||||||
 *   "Zehn",
 | 
					 | 
				
			||||||
 *   "Elf",
 | 
					 | 
				
			||||||
 * };
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
@ -1,99 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <lvgl/src/lv_core/lv_obj.h>
 | 
					 | 
				
			||||||
#include <chrono>
 | 
					 | 
				
			||||||
#include <cstdint>
 | 
					 | 
				
			||||||
#include <memory>
 | 
					 | 
				
			||||||
#include "displayapp/screens/Screen.h"
 | 
					 | 
				
			||||||
#include "components/datetime/DateTimeController.h"
 | 
					 | 
				
			||||||
#include "components/ble/BleController.h"
 | 
					 | 
				
			||||||
#include "displayapp/widgets/StatusIcons.h"
 | 
					 | 
				
			||||||
#include "utility/DirtyValue.h"
 | 
					 | 
				
			||||||
#include "displayapp/apps/Apps.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Pinetime {
 | 
					 | 
				
			||||||
  namespace Controllers {
 | 
					 | 
				
			||||||
    class Settings;
 | 
					 | 
				
			||||||
    class Battery;
 | 
					 | 
				
			||||||
    class Ble;
 | 
					 | 
				
			||||||
    class NotificationManager;
 | 
					 | 
				
			||||||
    class HeartRateController;
 | 
					 | 
				
			||||||
    class MotionController;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  namespace Applications {
 | 
					 | 
				
			||||||
    namespace Screens {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      class WatchFaceFuzzy : public Screen {
 | 
					 | 
				
			||||||
      public:
 | 
					 | 
				
			||||||
        WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
 | 
					 | 
				
			||||||
                         const Controllers::Battery& batteryController,
 | 
					 | 
				
			||||||
                         const Controllers::Ble& bleController,
 | 
					 | 
				
			||||||
                         Controllers::NotificationManager& notificationManager,
 | 
					 | 
				
			||||||
                         Controllers::Settings& settingsController,
 | 
					 | 
				
			||||||
                         Controllers::HeartRateController& heartRateController,
 | 
					 | 
				
			||||||
                         Controllers::MotionController& motionController);
 | 
					 | 
				
			||||||
        ~WatchFaceFuzzy() override;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void Refresh() override;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      private:
 | 
					 | 
				
			||||||
        const char* timeAccent = "ffffff";
 | 
					 | 
				
			||||||
        uint8_t displayedHour = -1;
 | 
					 | 
				
			||||||
        uint8_t displayedMinute = -1;
 | 
					 | 
				
			||||||
        static const char* timeSectors[12];
 | 
					 | 
				
			||||||
        static const char* hourNames[12];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
 | 
					 | 
				
			||||||
        // Utility::DirtyValue<bool> powerPresent {};
 | 
					 | 
				
			||||||
        // Utility::DirtyValue<bool> bleState {};
 | 
					 | 
				
			||||||
        // Utility::DirtyValue<bool> bleRadioEnabled {};
 | 
					 | 
				
			||||||
        Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
 | 
					 | 
				
			||||||
        // Utility::DirtyValue<uint32_t> stepCount {};
 | 
					 | 
				
			||||||
        // Utility::DirtyValue<uint8_t> heartbeat {};
 | 
					 | 
				
			||||||
        // Utility::DirtyValue<bool> heartbeatRunning {};
 | 
					 | 
				
			||||||
        Utility::DirtyValue<bool> notificationState {};
 | 
					 | 
				
			||||||
        using days = std::chrono::duration<int32_t, std::ratio<86400>>; // TODO: days is standard in c++20
 | 
					 | 
				
			||||||
        Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        lv_obj_t* label_time;
 | 
					 | 
				
			||||||
        lv_obj_t* label_time_ampm;
 | 
					 | 
				
			||||||
        lv_obj_t* label_date;
 | 
					 | 
				
			||||||
        // lv_obj_t* heartbeatIcon;
 | 
					 | 
				
			||||||
        // lv_obj_t* heartbeatValue;
 | 
					 | 
				
			||||||
        // lv_obj_t* stepIcon;
 | 
					 | 
				
			||||||
        // lv_obj_t* stepValue;
 | 
					 | 
				
			||||||
        lv_obj_t* notificationIcon;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Controllers::DateTime& dateTimeController;
 | 
					 | 
				
			||||||
        Controllers::NotificationManager& notificationManager;
 | 
					 | 
				
			||||||
        Controllers::Settings& settingsController;
 | 
					 | 
				
			||||||
        Controllers::HeartRateController& heartRateController;
 | 
					 | 
				
			||||||
        Controllers::MotionController& motionController;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        lv_task_t* taskRefresh;
 | 
					 | 
				
			||||||
        Widgets::StatusIcons statusIcons;
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    template <>
 | 
					 | 
				
			||||||
    struct WatchFaceTraits<WatchFace::Fuzzy> {
 | 
					 | 
				
			||||||
      static constexpr WatchFace watchFace = WatchFace::Fuzzy;
 | 
					 | 
				
			||||||
      static constexpr const char* name = "Fuzzy face";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      static Screens::Screen* Create(AppControllers& controllers) {
 | 
					 | 
				
			||||||
        return new Screens::WatchFaceFuzzy(controllers.dateTimeController,
 | 
					 | 
				
			||||||
                                             controllers.batteryController,
 | 
					 | 
				
			||||||
                                             controllers.bleController,
 | 
					 | 
				
			||||||
                                             controllers.notificationManager,
 | 
					 | 
				
			||||||
                                             controllers.settingsController,
 | 
					 | 
				
			||||||
                                             controllers.heartRateController,
 | 
					 | 
				
			||||||
                                             controllers.motionController);
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
 | 
					 | 
				
			||||||
        return true;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -13,9 +13,10 @@ namespace {
 | 
				
			|||||||
    const char* name;
 | 
					    const char* name;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constexpr std::array<Option, 2> options = {{
 | 
					  constexpr std::array<Option, 3> options = {{
 | 
				
			||||||
    {Pinetime::Controllers::Settings::ClockType::H12, "12-hour"},
 | 
					    {Pinetime::Controllers::Settings::ClockType::H12, "12-hour"},
 | 
				
			||||||
    {Pinetime::Controllers::Settings::ClockType::H24, "24-hour"},
 | 
					    {Pinetime::Controllers::Settings::ClockType::H24, "24-hour"},
 | 
				
			||||||
 | 
					    {Pinetime::Controllers::Settings::ClockType::Fuzzy, "Fuzzy"},
 | 
				
			||||||
  }};
 | 
					  }};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::array<CheckboxList::Item, CheckboxList::MaxItems> CreateOptionArray() {
 | 
					  std::array<CheckboxList::Item, CheckboxList::MaxItems> CreateOptionArray() {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user