Compare commits
8 Commits
wb/fuzzy-n
...
wb/fuzzy-e
Author | SHA1 | Date | |
---|---|---|---|
2dc10ffd41 | |||
7b3c48a0e5 | |||
d8c3624f6f | |||
|
20a5fef84c | ||
|
77667c6391 | ||
|
6c20c2992b | ||
|
5535fa6af7 | ||
|
796e8f1ada |
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
|
@ -3,7 +3,7 @@ name: CI
|
|||
# Run this workflow whenever the build may be affected
|
||||
on:
|
||||
push:
|
||||
branches: [ main, wb/fuzzy, wb/fuzzy-norm ]
|
||||
branches: [ main, wb/fuzzy, wb/fuzzy-norm, wb/fuzzy-analog, wb/fuzzy-everything-wolf ]
|
||||
paths-ignore:
|
||||
- 'doc/**'
|
||||
- '**.md'
|
||||
|
@ -88,6 +88,9 @@ jobs:
|
|||
git clone https://github.com/InfiniTimeOrg/InfiniSim.git --depth 1 --branch main
|
||||
git -C InfiniSim submodule update --init lv_drivers
|
||||
|
||||
- name: Add sunset lib to InfiniSim
|
||||
run: patch -i docker/infinisim-cmake.patch InfiniSim/CMakeLists.txt
|
||||
|
||||
- name: CMake
|
||||
# disable BUILD_RESOURCES as this is already done when building the firmware
|
||||
run: |
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -10,3 +10,6 @@
|
|||
[submodule "src/libs/arduinoFFT"]
|
||||
path = src/libs/arduinoFFT
|
||||
url = https://github.com/kosme/arduinoFFT.git
|
||||
[submodule "src/libs/sunset"]
|
||||
path = src/libs/sunset
|
||||
url = https://github.com/buelowp/sunset.git
|
||||
|
|
19
docker/infinisim-cmake.patch
Normal file
19
docker/infinisim-cmake.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index edd6748..641b74a 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -243,6 +243,14 @@ add_library(littlefs STATIC
|
||||
target_include_directories(littlefs PUBLIC "${InfiniTime_DIR}/src/libs/littlefs")
|
||||
target_link_libraries(infinisim PRIVATE littlefs)
|
||||
|
||||
+# sunset
|
||||
+add_library(sunset STATIC
|
||||
+ ${InfiniTime_DIR}/src/libs/sunset/src/sunset.h
|
||||
+ ${InfiniTime_DIR}/src/libs/sunset/src/sunset.cpp
|
||||
+)
|
||||
+target_include_directories(sunset PUBLIC "${InfiniTime_DIR}/src/libs/sunset")
|
||||
+target_link_libraries(infinisim PRIVATE sunset)
|
||||
+
|
||||
# QCBOR
|
||||
add_library(QCBOR STATIC
|
||||
${InfiniTime_DIR}/src/libs/QCBOR/src/ieee754.c
|
|
@ -174,6 +174,11 @@ set(LITTLEFS_SRC
|
|||
libs/littlefs/lfs.c
|
||||
)
|
||||
|
||||
set(SUNSET_SRC
|
||||
libs/sunset/src/sunset.h
|
||||
libs/sunset/src/sunset.cpp
|
||||
)
|
||||
|
||||
set(LVGL_SRC
|
||||
libs/lv_conf.h
|
||||
libs/lvgl/lvgl.h
|
||||
|
@ -412,6 +417,7 @@ list(APPEND SOURCE_FILES
|
|||
displayapp/screens/settings/SettingSetDateTime.cpp
|
||||
displayapp/screens/settings/SettingSetDate.cpp
|
||||
displayapp/screens/settings/SettingSetTime.cpp
|
||||
displayapp/screens/settings/SettingLocation.cpp
|
||||
displayapp/screens/settings/SettingChimes.cpp
|
||||
displayapp/screens/settings/SettingShakeThreshold.cpp
|
||||
displayapp/screens/settings/SettingBluetooth.cpp
|
||||
|
@ -419,10 +425,10 @@ list(APPEND SOURCE_FILES
|
|||
## Watch faces
|
||||
displayapp/screens/WatchFaceAnalog.cpp
|
||||
displayapp/screens/WatchFaceDigital.cpp
|
||||
displayapp/screens/WatchFaceInfineat.cpp
|
||||
displayapp/screens/WatchFaceTerminal.cpp
|
||||
#displayapp/screens/WatchFaceInfineat.cpp
|
||||
#displayapp/screens/WatchFaceTerminal.cpp
|
||||
displayapp/screens/WatchFacePineTimeStyle.cpp
|
||||
displayapp/screens/WatchFaceCasioStyleG7710.cpp
|
||||
#displayapp/screens/WatchFaceCasioStyleG7710.cpp
|
||||
|
||||
##
|
||||
|
||||
|
@ -897,13 +903,25 @@ target_compile_options(littlefs PRIVATE
|
|||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
|
||||
# SUNSET_SRC
|
||||
add_library(sunset STATIC ${SUNSET_SRC})
|
||||
target_include_directories(sunset SYSTEM PUBLIC . ../)
|
||||
target_include_directories(sunset SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
|
||||
target_compile_options(sunset PRIVATE
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
|
||||
# Build autonomous binary (without support for bootloader)
|
||||
set(EXECUTABLE_NAME "pinetime-app")
|
||||
set(EXECUTABLE_FILE_NAME ${EXECUTABLE_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
|
||||
set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld")
|
||||
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
|
||||
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME})
|
||||
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs sunset infinitime_fonts infinitime_apps)
|
||||
target_compile_options(${EXECUTABLE_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
${WARNING_FLAGS}
|
||||
|
@ -937,7 +955,7 @@ set(IMAGE_MCUBOOT_FILE_NAME_BIN ${EXECUTABLE_MCUBOOT_NAME}-image-${pinetime_VERS
|
|||
set(DFU_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip)
|
||||
set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld")
|
||||
add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES})
|
||||
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs sunset infinitime_fonts infinitime_apps)
|
||||
set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME})
|
||||
target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
|
@ -979,7 +997,7 @@ endif()
|
|||
set(EXECUTABLE_RECOVERY_NAME "pinetime-recovery")
|
||||
set(EXECUTABLE_RECOVERY_FILE_NAME ${EXECUTABLE_RECOVERY_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
|
||||
add_executable(${EXECUTABLE_RECOVERY_NAME} ${RECOVERY_SOURCE_FILES})
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs sunset infinitime_fonts infinitime_apps)
|
||||
set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME})
|
||||
target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY")
|
||||
target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC
|
||||
|
@ -1011,7 +1029,7 @@ set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-image-$
|
|||
set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME_HEX ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME}.hex)
|
||||
set(DFU_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip)
|
||||
add_executable(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} ${RECOVERY_SOURCE_FILES})
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs sunset infinitime_fonts infinitime_apps)
|
||||
set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME})
|
||||
target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY")
|
||||
target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC
|
||||
|
|
|
@ -50,6 +50,12 @@ namespace Pinetime {
|
|||
int colorIndex = 0;
|
||||
};
|
||||
|
||||
struct Location {
|
||||
int16_t latitude;
|
||||
int16_t longitude;
|
||||
int8_t tzOffset;
|
||||
};
|
||||
|
||||
Settings(Pinetime::Controllers::FS& fs);
|
||||
|
||||
Settings(const Settings&) = delete;
|
||||
|
@ -275,6 +281,21 @@ namespace Pinetime {
|
|||
return settings.stepsGoal;
|
||||
};
|
||||
|
||||
void SetLocation(Location loc) {
|
||||
if (
|
||||
loc.latitude != settings.location.latitude ||
|
||||
loc.longitude != settings.location.longitude ||
|
||||
loc.tzOffset != settings.location.tzOffset
|
||||
) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.location = loc;
|
||||
};
|
||||
|
||||
Location GetLocation() const {
|
||||
return settings.location;
|
||||
};
|
||||
|
||||
void SetBleRadioEnabled(bool enabled) {
|
||||
bleRadioEnabled = enabled;
|
||||
};
|
||||
|
@ -308,6 +329,7 @@ namespace Pinetime {
|
|||
uint16_t shakeWakeThreshold = 150;
|
||||
|
||||
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
||||
Location location = {(int16_t)0,(int16_t)0,(int8_t)0};
|
||||
};
|
||||
|
||||
SettingsData settings;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "displayapp/screens/settings/SettingDisplay.h"
|
||||
#include "displayapp/screens/settings/SettingSteps.h"
|
||||
#include "displayapp/screens/settings/SettingSetDateTime.h"
|
||||
#include "displayapp/screens/settings/SettingLocation.h"
|
||||
#include "displayapp/screens/settings/SettingChimes.h"
|
||||
#include "displayapp/screens/settings/SettingShakeThreshold.h"
|
||||
#include "displayapp/screens/settings/SettingBluetooth.h"
|
||||
|
@ -514,6 +515,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||
case Apps::SettingSetDateTime:
|
||||
currentScreen = std::make_unique<Screens::SettingSetDateTime>(this, dateTimeController, settingsController);
|
||||
break;
|
||||
case Apps::SettingLocation:
|
||||
currentScreen = std::make_unique<Screens::SettingLocation>(settingsController);
|
||||
break;
|
||||
case Apps::SettingChimes:
|
||||
currentScreen = std::make_unique<Screens::SettingChimes>(settingsController);
|
||||
break;
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
#include "displayapp/screens/ApplicationList.h"
|
||||
#include "displayapp/screens/WatchFaceDigital.h"
|
||||
#include "displayapp/screens/WatchFaceAnalog.h"
|
||||
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||
// #include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
// #include "displayapp/screens/WatchFaceInfineat.h"
|
||||
#include "displayapp/screens/WatchFacePineTimeStyle.h"
|
||||
#include "displayapp/screens/WatchFaceTerminal.h"
|
||||
// #include "displayapp/screens/WatchFaceTerminal.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace Pinetime {
|
|||
SettingWakeUp,
|
||||
SettingSteps,
|
||||
SettingSetDateTime,
|
||||
SettingLocation,
|
||||
SettingChimes,
|
||||
SettingShakeThreshold,
|
||||
SettingBluetooth,
|
||||
|
@ -48,9 +49,6 @@ namespace Pinetime {
|
|||
Digital,
|
||||
Analog,
|
||||
PineTimeStyle,
|
||||
Terminal,
|
||||
Infineat,
|
||||
CasioStyleG7710,
|
||||
};
|
||||
|
||||
template <Apps>
|
||||
|
@ -73,10 +71,7 @@ namespace Pinetime {
|
|||
|
||||
using UserWatchFaceTypes = WatchFaceTypeList<WatchFace::Digital,
|
||||
WatchFace::Analog,
|
||||
WatchFace::PineTimeStyle,
|
||||
WatchFace::Terminal,
|
||||
WatchFace::Infineat,
|
||||
WatchFace::CasioStyleG7710>;
|
||||
WatchFace::PineTimeStyle>;
|
||||
|
||||
static_assert(UserWatchFaceTypes::Count >= 1);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
if(DEFINED ENABLE_USERAPPS)
|
||||
set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware")
|
||||
else ()
|
||||
set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Twos" CACHE STRING "List of user apps to build into the firmware")
|
||||
#Apps::Paint,
|
||||
#Apps::Metronome,
|
||||
#Apps::Paddle,
|
||||
set(USERAPP_TYPES "Apps::Navigation, Apps::Alarm, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Twos" CACHE STRING "List of user apps to build into the firmware")
|
||||
#Apps::Paint, Apps::Metronome, Apps::Paddle, Apps::StopWatch, Apps::Timer,
|
||||
endif ()
|
||||
|
||||
add_library(infinitime_apps INTERFACE)
|
||||
|
|
|
@ -18,11 +18,12 @@
|
|||
"sources": [
|
||||
{
|
||||
"file": "JetBrainsMono-Regular.ttf",
|
||||
"disabledfile": "Vulf Mono Light Italic.ttf",
|
||||
"range": "0x20, 0x25, 0x27, 0x2b, 0x2d, 0x30-0x3a, 0x4b-0x4d, 0x61-0x7a"
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 42
|
||||
"size": 30
|
||||
},
|
||||
"jetbrains_mono_76": {
|
||||
"sources": [
|
||||
|
|
|
@ -1,22 +1,27 @@
|
|||
#include "displayapp/screens/WatchFaceAnalog.h"
|
||||
#include <cmath>
|
||||
#include <lvgl/lvgl.h>
|
||||
// #include <nrf_log.h>
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#include "displayapp/screens/BleIcon.h"
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "displayapp/screens/NotificationIcon.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "displayapp/InfiniTimeTheme.h"
|
||||
#include "sunset/src/sunset.h"
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
constexpr int16_t HourLength = 70;
|
||||
int16_t HourLength = 70;
|
||||
constexpr int16_t MinuteLength = 90;
|
||||
constexpr int16_t SecondLength = 110;
|
||||
constexpr int16_t SunDialVerticalOffset = 40;
|
||||
|
||||
// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
|
||||
const auto LV_TRIG_SCALE = _lv_trigo_sin(90);
|
||||
const lv_color_t DARK_GRAY = lv_color_make(48, 48, 48);
|
||||
const lv_color_t DARK_ORANGE = lv_color_make(48, 26, 0);
|
||||
|
||||
int16_t Cosine(int16_t angle) {
|
||||
return _lv_trigo_sin(angle + 90);
|
||||
|
@ -39,6 +44,15 @@ namespace {
|
|||
.y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)};
|
||||
}
|
||||
|
||||
int16_t CoordinateYRelocateSundial(int16_t y) {
|
||||
return std::abs(y - SunDialVerticalOffset);
|
||||
}
|
||||
|
||||
lv_point_t CoordinateRelocateSundial(int16_t radius, int16_t angle) {
|
||||
return lv_point_t {.x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE),
|
||||
.y = CoordinateYRelocateSundial(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||
|
@ -58,41 +72,68 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
|||
sMinute = 99;
|
||||
sSecond = 99;
|
||||
|
||||
minor_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(minor_scales, 300, 51);
|
||||
lv_linemeter_set_angle_offset(minor_scales, 180);
|
||||
lv_obj_set_size(minor_scales, 240, 240);
|
||||
lv_obj_align(minor_scales, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_scale_end_line_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1);
|
||||
lv_obj_set_style_local_scale_end_color(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
location = settingsController.GetLocation();
|
||||
|
||||
major_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(major_scales, 300, 11);
|
||||
lv_linemeter_set_angle_offset(major_scales, 180);
|
||||
lv_obj_set_size(major_scales, 240, 240);
|
||||
lv_obj_align(major_scales, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 6);
|
||||
lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
// begin sundial watch face
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||
major_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(major_scales, 165, 11);
|
||||
lv_linemeter_set_angle_offset(major_scales, 180);
|
||||
lv_obj_set_size(major_scales, 240, 240);
|
||||
lv_obj_align(major_scales, nullptr, LV_ALIGN_IN_TOP_MID, 0, -LV_HOR_RES/2+SunDialVerticalOffset);
|
||||
lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 40);
|
||||
lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1);
|
||||
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
||||
large_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(large_scales, 180, 3);
|
||||
lv_linemeter_set_angle_offset(large_scales, 180);
|
||||
lv_obj_set_size(large_scales, 240, 240);
|
||||
lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 20);
|
||||
lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_scale_end_color(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
|
||||
one = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_align(one, LV_LABEL_ALIGN_LEFT);
|
||||
lv_label_set_text(one, "I");
|
||||
lv_obj_align(one, NULL, LV_ALIGN_IN_TOP_LEFT, 20, SunDialVerticalOffset-20);
|
||||
lv_obj_set_style_local_text_color(one, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
||||
twelve = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_text_static(twelve, "12");
|
||||
lv_obj_set_pos(twelve, 110, 10);
|
||||
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
|
||||
twelve = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_align(twelve, LV_LABEL_ALIGN_RIGHT);
|
||||
lv_label_set_text(twelve, "XII");
|
||||
lv_obj_align(twelve, NULL, LV_ALIGN_IN_TOP_RIGHT, -20, SunDialVerticalOffset-20);
|
||||
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
} else {
|
||||
minor_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(minor_scales, 300, 51);
|
||||
lv_linemeter_set_angle_offset(minor_scales, 180);
|
||||
lv_obj_set_size(minor_scales, 240, 240);
|
||||
lv_obj_align(minor_scales, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_scale_end_line_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1);
|
||||
lv_obj_set_style_local_scale_end_color(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
|
||||
major_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(major_scales, 300, 11);
|
||||
lv_linemeter_set_angle_offset(major_scales, 180);
|
||||
lv_obj_set_size(major_scales, 240, 240);
|
||||
lv_obj_align(major_scales, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 6);
|
||||
lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
||||
large_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(large_scales, 180, 3);
|
||||
lv_linemeter_set_angle_offset(large_scales, 180);
|
||||
lv_obj_set_size(large_scales, 240, 240);
|
||||
lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 20);
|
||||
lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_scale_end_color(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
|
||||
|
||||
twelve = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_text_static(twelve, "12");
|
||||
lv_obj_set_pos(twelve, 110, 10);
|
||||
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
|
||||
}
|
||||
|
||||
batteryIcon.Create(lv_scr_act());
|
||||
lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
|
@ -111,7 +152,6 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
|||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
|
||||
// Date - Day / Week day
|
||||
|
||||
label_date_day = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
|
||||
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
||||
|
@ -171,12 +211,78 @@ WatchFaceAnalog::~WatchFaceAnalog() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
|
||||
void WatchFaceAnalog::drawWatchFaceModeNight(){
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
if (sHour != hour || sMinute != minute) {
|
||||
// sun.setPosition(settings.lat.toFloat(), settings.lon.toFloat(), settings.gmtOffset / 3600);
|
||||
sun.setPosition((float)location.latitude, (float)location.longitude, location.tzOffset);
|
||||
|
||||
//from minutes past midnight
|
||||
sun.setCurrentDate(dateTimeController.Year(), static_cast<uint8_t>(dateTimeController.Month())+1, dateTimeController.Day());
|
||||
sun.setTZOffset(location.tzOffset);
|
||||
|
||||
minutesSunrise = sun.calcSunrise(); //360;
|
||||
minutesSunset = sun.calcSunset(); //1080;
|
||||
minutesDaytime = (minutesSunset - minutesSunrise);
|
||||
minutesNighttime = (1440 - minutesDaytime);
|
||||
|
||||
minutesBeforeSunset = minutesSunset - (hour * 60 + minute); // i.e.zero degrees
|
||||
HourLength = 90; // sundial hand length
|
||||
|
||||
int16_t hourAngle;
|
||||
|
||||
if(minutesBeforeSunset > 0 && minutesBeforeSunset < minutesDaytime) { // day (after sunrise)
|
||||
hourAngle = 180.0 * minutesBeforeSunset / minutesDaytime + 90;
|
||||
} else { // night (before sunrise or after sunset)
|
||||
lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, DARK_GRAY);
|
||||
lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, DARK_GRAY);
|
||||
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY);
|
||||
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_ORANGE);
|
||||
lv_obj_set_style_local_text_color(one, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY);
|
||||
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY);
|
||||
|
||||
if(minutesBeforeSunset > minutesDaytime) { // before sunrise
|
||||
hourAngle = 180.0 * (minutesBeforeSunset - minutesDaytime) / minutesNighttime + 90;
|
||||
} else { // after sunset
|
||||
hourAngle = 180 + 180.0 * minutesBeforeSunset / minutesNighttime + 90;
|
||||
}
|
||||
}
|
||||
/*NRF_LOG_INFO("a: %d, la: %f, lo: %f, ri: %d, se: %d, be: %d",
|
||||
hourAngle,
|
||||
(float)location.latitude,
|
||||
(float)location.longitude,
|
||||
minutesSunrise,
|
||||
minutesSunset,
|
||||
minutesBeforeSunset);*/
|
||||
|
||||
sHour = hour;
|
||||
sMinute = minute;
|
||||
|
||||
hour_point_trace[0] = CoordinateRelocateSundial(HourLength*.75, hourAngle);
|
||||
hour_point_trace[1] = CoordinateRelocateSundial(HourLength, hourAngle);
|
||||
|
||||
hour_point[0] = CoordinateRelocateSundial(0, hourAngle);
|
||||
hour_point[1] = CoordinateRelocateSundial(HourLength*.75, hourAngle);
|
||||
|
||||
lv_line_set_points(hour_body, hour_point, 2);
|
||||
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFaceAnalog::UpdateClock() {
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||
drawWatchFaceModeNight();
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
uint8_t second = dateTimeController.Seconds();
|
||||
|
||||
if (sMinute != minute) {
|
||||
if (minute>99 && sMinute != minute) { // disable
|
||||
auto const angle = minute * 6;
|
||||
minute_point[0] = CoordinateRelocate(30, angle);
|
||||
minute_point[1] = CoordinateRelocate(MinuteLength, angle);
|
||||
|
@ -203,7 +309,8 @@ void WatchFaceAnalog::UpdateClock() {
|
|||
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
|
||||
}
|
||||
|
||||
if (sSecond != second) {
|
||||
|
||||
if (second>99 && sSecond != second) { // disable
|
||||
sSecond = second;
|
||||
auto const angle = second * 6;
|
||||
|
||||
|
@ -258,7 +365,18 @@ void WatchFaceAnalog::Refresh() {
|
|||
|
||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||
char const* MonthsString[] = {"--", "IANUARIUS","FEBRUARIUS","MARTIUS","APRILIS","MARTIUSIUNIUS","QUINTILIS","SEXTILIS","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"};
|
||||
char const* DaysString[] = {"--", "LUNAE", "MARTIS", "MERCURII", "IOVIS", "VENERIS", "SATURNI", "SOLIS"};
|
||||
char const* RomanNumeralsString[] = {"--", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"};
|
||||
lv_label_set_text_fmt(label_date_day, "%s\n%s %s",
|
||||
DaysString[static_cast<uint8_t>(dateTimeController.DayOfWeek())],
|
||||
RomanNumeralsString[static_cast<uint8_t>(dateTimeController.Day())],
|
||||
MonthsString[static_cast<uint8_t>(dateTimeController.Month())]);
|
||||
lv_obj_align(label_date_day, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -20);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
#include "components/ble/NotificationManager.h"
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
#include "sunset/src/sunset.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
|
@ -49,6 +50,7 @@ namespace Pinetime {
|
|||
lv_obj_t* minor_scales;
|
||||
lv_obj_t* major_scales;
|
||||
lv_obj_t* large_scales;
|
||||
lv_obj_t* one;
|
||||
lv_obj_t* twelve;
|
||||
|
||||
lv_obj_t* hour_body;
|
||||
|
@ -76,12 +78,21 @@ namespace Pinetime {
|
|||
|
||||
BatteryIcon batteryIcon;
|
||||
|
||||
Controllers::Settings::Location location;
|
||||
SunSet sun;
|
||||
int16_t minutesSunrise;
|
||||
int16_t minutesSunset;
|
||||
int16_t minutesDaytime;
|
||||
int16_t minutesNighttime;
|
||||
int16_t minutesBeforeSunset;
|
||||
|
||||
const Controllers::DateTime& dateTimeController;
|
||||
const Controllers::Battery& batteryController;
|
||||
const Controllers::Ble& bleController;
|
||||
Controllers::NotificationManager& notificationManager;
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
void drawWatchFaceModeNight();
|
||||
void UpdateClock();
|
||||
void SetBatteryIcon();
|
||||
|
||||
|
|
|
@ -1,334 +0,0 @@
|
|||
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#include "displayapp/screens/BleIcon.h"
|
||||
#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;
|
||||
|
||||
WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificatioManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem)
|
||||
: currentDateTime {{}},
|
||||
batteryIcon(false),
|
||||
dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
bleController {bleController},
|
||||
notificatioManager {notificatioManager},
|
||||
settingsController {settingsController},
|
||||
heartRateController {heartRateController},
|
||||
motionController {motionController} {
|
||||
|
||||
lfs_file f = {};
|
||||
if (filesystem.FileOpen(&f, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_dot40 = lv_font_load("F:/fonts/lv_font_dots_40.bin");
|
||||
}
|
||||
|
||||
if (filesystem.FileOpen(&f, "/fonts/7segments_40.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_segment40 = lv_font_load("F:/fonts/7segments_40.bin");
|
||||
}
|
||||
|
||||
if (filesystem.FileOpen(&f, "/fonts/7segments_115.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_segment115 = lv_font_load("F:/fonts/7segments_115.bin");
|
||||
}
|
||||
|
||||
label_battery_value = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_battery_value, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
lv_obj_set_style_local_text_color(label_battery_value, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(label_battery_value, "00%");
|
||||
|
||||
batteryIcon.Create(lv_scr_act());
|
||||
batteryIcon.SetColor(color_text);
|
||||
lv_obj_align(batteryIcon.GetObject(), label_battery_value, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(batteryPlug, Symbols::plug);
|
||||
lv_obj_align(batteryPlug, batteryIcon.GetObject(), LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
||||
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
|
||||
lv_obj_align(notificationIcon, bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
label_day_of_week = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_day_of_week, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 10, 64);
|
||||
lv_obj_set_style_local_text_color(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_dot40);
|
||||
lv_label_set_text_static(label_day_of_week, "SUN");
|
||||
|
||||
label_week_number = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_week_number, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 22);
|
||||
lv_obj_set_style_local_text_color(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_dot40);
|
||||
lv_label_set_text_static(label_week_number, "WK26");
|
||||
|
||||
label_day_of_year = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_day_of_year, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 30);
|
||||
lv_obj_set_style_local_text_color(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment40);
|
||||
lv_label_set_text_static(label_day_of_year, "181-184");
|
||||
|
||||
lv_style_init(&style_line);
|
||||
lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 2);
|
||||
lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, color_text);
|
||||
lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true);
|
||||
|
||||
lv_style_init(&style_border);
|
||||
lv_style_set_line_width(&style_border, LV_STATE_DEFAULT, 6);
|
||||
lv_style_set_line_color(&style_border, LV_STATE_DEFAULT, color_text);
|
||||
lv_style_set_line_rounded(&style_border, LV_STATE_DEFAULT, true);
|
||||
|
||||
line_icons = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_icons, line_icons_points, 3);
|
||||
lv_obj_add_style(line_icons, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_icons, nullptr, LV_ALIGN_IN_TOP_RIGHT, -10, 18);
|
||||
|
||||
line_day_of_week_number = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_day_of_week_number, line_day_of_week_number_points, 4);
|
||||
lv_obj_add_style(line_day_of_week_number, LV_LINE_PART_MAIN, &style_border);
|
||||
lv_obj_align(line_day_of_week_number, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 8);
|
||||
|
||||
line_day_of_year = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_day_of_year, line_day_of_year_points, 3);
|
||||
lv_obj_add_style(line_day_of_year, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_day_of_year, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 60);
|
||||
|
||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 70);
|
||||
lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment40);
|
||||
lv_label_set_text_static(label_date, "6-30");
|
||||
|
||||
line_date = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_date, line_date_points, 3);
|
||||
lv_obj_add_style(line_date, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_date, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 100);
|
||||
|
||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment115);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 40);
|
||||
|
||||
line_time = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_time, line_time_points, 3);
|
||||
lv_obj_add_style(line_time, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_time, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -25);
|
||||
|
||||
label_time_ampm = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_time_ampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(label_time_ampm, "");
|
||||
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 5, -5);
|
||||
|
||||
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_click(backgroundLabel, true);
|
||||
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
||||
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||
lv_label_set_text_static(backgroundLabel, "");
|
||||
|
||||
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, color_text);
|
||||
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
|
||||
|
||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
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, color_text);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
|
||||
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
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();
|
||||
}
|
||||
|
||||
WatchFaceCasioStyleG7710::~WatchFaceCasioStyleG7710() {
|
||||
lv_task_del(taskRefresh);
|
||||
|
||||
lv_style_reset(&style_line);
|
||||
lv_style_reset(&style_border);
|
||||
|
||||
if (font_dot40 != nullptr) {
|
||||
lv_font_free(font_dot40);
|
||||
}
|
||||
|
||||
if (font_segment40 != nullptr) {
|
||||
lv_font_free(font_segment40);
|
||||
}
|
||||
|
||||
if (font_segment115 != nullptr) {
|
||||
lv_font_free(font_segment115);
|
||||
}
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
void WatchFaceCasioStyleG7710::Refresh() {
|
||||
powerPresent = batteryController.IsPowerPresent();
|
||||
if (powerPresent.IsUpdated()) {
|
||||
lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
|
||||
}
|
||||
|
||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||
if (batteryPercentRemaining.IsUpdated()) {
|
||||
auto batteryPercent = batteryPercentRemaining.Get();
|
||||
batteryIcon.SetBatteryPercentage(batteryPercent);
|
||||
lv_label_set_text_fmt(label_battery_value, "%d%%", batteryPercent);
|
||||
}
|
||||
|
||||
bleState = bleController.IsConnected();
|
||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||
}
|
||||
lv_obj_realign(label_battery_value);
|
||||
lv_obj_realign(batteryIcon.GetObject());
|
||||
lv_obj_realign(batteryPlug);
|
||||
lv_obj_realign(bleIcon);
|
||||
lv_obj_realign(notificationIcon);
|
||||
|
||||
notificationState = notificatioManager.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();
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[2] = "A";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
lv_label_set_text(label_time_ampm, ampmChar);
|
||||
lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
|
||||
}
|
||||
lv_obj_realign(label_time);
|
||||
|
||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
const char* weekNumberFormat = "%V";
|
||||
|
||||
uint16_t year = dateTimeController.Year();
|
||||
Controllers::DateTime::Months month = dateTimeController.Month();
|
||||
uint8_t day = dateTimeController.Day();
|
||||
int dayOfYear = dateTimeController.DayOfYear();
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
|
||||
// 24h mode: ddmmyyyy, first DOW=Monday;
|
||||
lv_label_set_text_fmt(label_date, "%3d-%2d", day, month);
|
||||
weekNumberFormat = "%V"; // Replaced by the week number of the year (Monday as the first day of the week) as a decimal number
|
||||
// [01,53]. If the week containing 1 January has four or more days in the new year, then it is considered
|
||||
// week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. Both January
|
||||
// 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday]
|
||||
} else {
|
||||
// 12h mode: mmddyyyy, first DOW=Sunday;
|
||||
lv_label_set_text_fmt(label_date, "%3d-%2d", month, day);
|
||||
weekNumberFormat = "%U"; // Replaced by the week number of the year as a decimal number [00,53]. The first Sunday of January is the
|
||||
// first day of week 1; days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
|
||||
}
|
||||
|
||||
time_t ttTime =
|
||||
std::chrono::system_clock::to_time_t(std::chrono::time_point_cast<std::chrono::system_clock::duration>(currentDateTime.Get()));
|
||||
tm* tmTime = std::localtime(&ttTime);
|
||||
|
||||
// TODO: When we start using C++20, use std::chrono::year::is_leap
|
||||
int daysInCurrentYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ? 366 : 365;
|
||||
uint16_t daysTillEndOfYearNumber = daysInCurrentYear - dayOfYear;
|
||||
|
||||
char buffer[8];
|
||||
strftime(buffer, 8, weekNumberFormat, tmTime);
|
||||
uint8_t weekNumber = atoi(buffer);
|
||||
|
||||
lv_label_set_text_fmt(label_day_of_week, "%s", dateTimeController.DayOfWeekShortToString());
|
||||
lv_label_set_text_fmt(label_day_of_year, "%3d-%3d", dayOfYear, daysTillEndOfYearNumber);
|
||||
lv_label_set_text_fmt(label_week_number, "WK%02d", weekNumber);
|
||||
|
||||
lv_obj_realign(label_day_of_week);
|
||||
lv_obj_realign(label_day_of_year);
|
||||
lv_obj_realign(label_week_number);
|
||||
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, color_text);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
lfs_file file = {};
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/fonts/7segments_40.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/fonts/7segments_115.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
return true;
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <displayapp/screens/BatteryIcon.h>
|
||||
#include <lvgl/src/lv_core/lv_obj.h>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <displayapp/Controllers.h>
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "components/ble/BleController.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 WatchFaceCasioStyleG7710 : public Screen {
|
||||
public:
|
||||
WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificatioManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem);
|
||||
~WatchFaceCasioStyleG7710() override;
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
||||
|
||||
private:
|
||||
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_point_t line_icons_points[3] {{0, 5}, {117, 5}, {122, 0}};
|
||||
lv_point_t line_day_of_week_number_points[4] {{0, 0}, {100, 0}, {95, 95}, {0, 95}};
|
||||
lv_point_t line_day_of_year_points[3] {{0, 5}, {130, 5}, {135, 0}};
|
||||
lv_point_t line_date_points[3] {{0, 5}, {135, 5}, {140, 0}};
|
||||
lv_point_t line_time_points[3] {{0, 0}, {230, 0}, {235, 5}};
|
||||
|
||||
lv_color_t color_text = lv_color_hex(0x98B69A);
|
||||
|
||||
lv_style_t style_line;
|
||||
lv_style_t style_border;
|
||||
|
||||
lv_obj_t* label_time;
|
||||
lv_obj_t* line_time;
|
||||
lv_obj_t* label_time_ampm;
|
||||
lv_obj_t* label_date;
|
||||
lv_obj_t* line_date;
|
||||
lv_obj_t* label_day_of_week;
|
||||
lv_obj_t* label_week_number;
|
||||
lv_obj_t* line_day_of_week_number;
|
||||
lv_obj_t* label_day_of_year;
|
||||
lv_obj_t* line_day_of_year;
|
||||
lv_obj_t* backgroundLabel;
|
||||
lv_obj_t* bleIcon;
|
||||
lv_obj_t* batteryPlug;
|
||||
lv_obj_t* label_battery_value;
|
||||
lv_obj_t* heartbeatIcon;
|
||||
lv_obj_t* heartbeatValue;
|
||||
lv_obj_t* stepIcon;
|
||||
lv_obj_t* stepValue;
|
||||
lv_obj_t* notificationIcon;
|
||||
lv_obj_t* line_icons;
|
||||
|
||||
BatteryIcon batteryIcon;
|
||||
|
||||
Controllers::DateTime& dateTimeController;
|
||||
const Controllers::Battery& batteryController;
|
||||
const Controllers::Ble& bleController;
|
||||
Controllers::NotificationManager& notificatioManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
lv_font_t* font_dot40 = nullptr;
|
||||
lv_font_t* font_segment40 = nullptr;
|
||||
lv_font_t* font_segment115 = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct WatchFaceTraits<WatchFace::CasioStyleG7710> {
|
||||
static constexpr WatchFace watchFace = WatchFace::CasioStyleG7710;
|
||||
static constexpr const char* name = "Casio G7710";
|
||||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::WatchFaceCasioStyleG7710(controllers.dateTimeController,
|
||||
controllers.batteryController,
|
||||
controllers.bleController,
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController,
|
||||
controllers.heartRateController,
|
||||
controllers.motionController,
|
||||
controllers.filesystem);
|
||||
};
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
return Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -28,25 +28,30 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
|||
motionController {motionController},
|
||||
statusIcons(batteryController, bleController) {
|
||||
|
||||
sHour = 99;
|
||||
sMinute = 99;
|
||||
statusIcons.Create();
|
||||
|
||||
lv_obj_t* bg = lv_img_create(lv_scr_act(), nullptr);
|
||||
lv_img_set_src(bg, "F:/images/aor.bin");
|
||||
lv_img_set_auto_size(bg, false);
|
||||
lv_obj_set_size(bg, 240, 240);
|
||||
// lv_img_set_src(bg, image.fileName);
|
||||
lv_img_set_offset_x(bg, 0);
|
||||
lv_img_set_offset_y(bg, 0);
|
||||
// lv_obj_set_style_local_image_recolor_opa(bg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
// lv_obj_set_style_local_image_recolor(bg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
|
||||
lv_obj_align(bg, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
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);
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
||||
} else {
|
||||
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, "");
|
||||
|
@ -89,51 +94,48 @@ void WatchFaceDigital::Refresh() {
|
|||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
||||
}
|
||||
|
||||
currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime());
|
||||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
/* Begin difference from WatchFaceDigital*/
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||
std::string hourStr, timeStr;
|
||||
hour = hour % 12; // 12 becomes 0, 13 becomes 1
|
||||
auto sector = minute / 15 + (minute % 15 > 7);
|
||||
// advance the hour modulo 12 and reset the minutes if we're close to the top
|
||||
// so we get "quarter to $hour+1" instead of needing "three quarters past $hour"
|
||||
if (sector > 3) {
|
||||
hour = (hour + 1) % 12;
|
||||
sector = 0;
|
||||
}
|
||||
if (sHour != hour || sMinute != minute || forceRefresh == true) {
|
||||
forceRefresh = false;
|
||||
sHour = hour;
|
||||
sMinute = minute;
|
||||
|
||||
timeStr = timeSectors[sector];
|
||||
if (timeStr.find("%1") != std::string::npos) {
|
||||
hour = (hour + 1) % 12;
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||
printTimeWords(static_cast<int>(hour), static_cast<int>(minute));
|
||||
lv_label_set_text(label_time_ampm, "");
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -10);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
||||
lv_label_set_recolor(label_time, true);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
|
||||
} else if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
lv_label_set_text(label_time_ampm, ampmChar);
|
||||
lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
|
||||
}
|
||||
//hourStr = std::string("#") + timeAccent + " " + hourNames[hour] + "#";
|
||||
hourStr = 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";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
lv_label_set_text(label_time_ampm, ampmChar);
|
||||
lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_realign(label_time);
|
||||
lv_obj_realign(label_date);
|
||||
}
|
||||
|
||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||
|
@ -182,30 +184,56 @@ void WatchFaceDigital::Refresh() {
|
|||
}
|
||||
}
|
||||
|
||||
/* 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",
|
||||
"quarter\npast\n%0",
|
||||
"half past\n%0",
|
||||
"quarter\nto %1",
|
||||
};
|
||||
const char* WatchFaceDigital::hourNames[] = {
|
||||
"twelve",
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
"four",
|
||||
"five",
|
||||
"six",
|
||||
"seven",
|
||||
"eight",
|
||||
"nine",
|
||||
"ten",
|
||||
"eleven",
|
||||
};
|
||||
bool WatchFaceDigital::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
if ((event == Pinetime::Applications::TouchEvents::LongTap)) {
|
||||
Pinetime::Controllers::Settings::ClockType clockType = settingsController.GetClockType();
|
||||
if (clockType == Pinetime::Controllers::Settings::ClockType::Fuzzy) {
|
||||
settingsController.SetClockType(Pinetime::Controllers::Settings::ClockType::H12);
|
||||
} else {
|
||||
settingsController.SetClockType(Pinetime::Controllers::Settings::ClockType::Fuzzy);
|
||||
}
|
||||
settingsController.SaveSettings();
|
||||
forceRefresh=true;
|
||||
WatchFaceDigital::Refresh();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
char const* twelve = "twelve";
|
||||
|
||||
void WatchFaceDigital::printTimeWords(int h, int m) {
|
||||
const char* mod;
|
||||
char const* accent = "#808080";
|
||||
char const* color = "#ffffff";
|
||||
char const* oclock = "o' clock";
|
||||
char const* past = "past";
|
||||
char const* to = "to";
|
||||
char const* hash = "#";
|
||||
char const* nearly = "nearly";
|
||||
char const* fmt = "%s %s%s\n%s %s%s %s %s%s";
|
||||
|
||||
if (m <= 30) {
|
||||
mod = mods[m / 5];
|
||||
} else {
|
||||
mod = mods[(60-m) / 5];
|
||||
}
|
||||
h = (h % 12);
|
||||
|
||||
if (m >= 56) {
|
||||
lv_label_set_text_fmt(label_time, "%s %s %s%s\n%s %s%s", color, nearly, nums[(h+1) % 12], hash, accent, oclock, hash);
|
||||
}
|
||||
else if (m == 0 || m <= 4) {
|
||||
lv_label_set_text_fmt(label_time, "%s %s%s\n%s %s%s", color, nums[h], hash, accent, oclock, hash);
|
||||
}
|
||||
|
||||
else if (m <= 32) {
|
||||
lv_label_set_text_fmt(label_time, fmt, color, mod, hash, accent, past, hash, color, nums[h], hash);
|
||||
}
|
||||
|
||||
else if (m > 32) {
|
||||
lv_label_set_text_fmt(label_time, fmt, color, mod, hash, accent, to, hash, color, nums[(h+1) % 12], hash);
|
||||
}
|
||||
|
||||
}
|
|
@ -35,19 +35,22 @@ namespace Pinetime {
|
|||
Controllers::MotionController& motionController);
|
||||
~WatchFaceDigital() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
uint8_t sHour, sMinute;
|
||||
uint8_t displayedHour = -1;
|
||||
uint8_t displayedMinute = -1;
|
||||
static const char* timeSectors[4];
|
||||
static const char* hourNames[12];
|
||||
|
||||
char const* mods[7] = {"", "five", "ten", "quarter", "twenty", "twenty five", "half"};
|
||||
char const* nums[13] = {"twelve", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"};
|
||||
|
||||
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<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
|
||||
Utility::DirtyValue<uint32_t> stepCount {};
|
||||
Utility::DirtyValue<uint8_t> heartbeat {};
|
||||
Utility::DirtyValue<bool> heartbeatRunning {};
|
||||
|
@ -71,7 +74,10 @@ namespace Pinetime {
|
|||
Controllers::MotionController& motionController;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
bool forceRefresh=false;
|
||||
Widgets::StatusIcons statusIcons;
|
||||
|
||||
void printTimeWords(int h, int m);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,508 +0,0 @@
|
|||
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "displayapp/screens/BleIcon.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "components/battery/BatteryController.h"
|
||||
#include "components/ble/BleController.h"
|
||||
#include "components/ble/NotificationManager.h"
|
||||
#include "components/motion/MotionController.h"
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||
auto* screen = static_cast<WatchFaceInfineat*>(obj->user_data);
|
||||
screen->UpdateSelected(obj, event);
|
||||
}
|
||||
|
||||
enum class colors {
|
||||
orange,
|
||||
blue,
|
||||
green,
|
||||
rainbow,
|
||||
gray,
|
||||
nordBlue,
|
||||
nordGreen,
|
||||
};
|
||||
|
||||
constexpr int nColors = 7; // must match number of colors in InfineatColors
|
||||
|
||||
constexpr int nLines = WatchFaceInfineat::nLines;
|
||||
|
||||
constexpr std::array<lv_color_t, nLines> orangeColors = {LV_COLOR_MAKE(0xfd, 0x87, 0x2b),
|
||||
LV_COLOR_MAKE(0xdb, 0x33, 0x16),
|
||||
LV_COLOR_MAKE(0x6f, 0x10, 0x00),
|
||||
LV_COLOR_MAKE(0xfd, 0x7a, 0x0a),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xe8, 0x51, 0x02),
|
||||
LV_COLOR_MAKE(0xea, 0x1c, 0x00)};
|
||||
constexpr std::array<lv_color_t, nLines> blueColors = {LV_COLOR_MAKE(0xe7, 0xf8, 0xff),
|
||||
LV_COLOR_MAKE(0x22, 0x32, 0xd0),
|
||||
LV_COLOR_MAKE(0x18, 0x2a, 0x8b),
|
||||
LV_COLOR_MAKE(0xe7, 0xf8, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x59, 0x91, 0xff),
|
||||
LV_COLOR_MAKE(0x16, 0x36, 0xff)};
|
||||
constexpr std::array<lv_color_t, nLines> greenColors = {LV_COLOR_MAKE(0xb8, 0xff, 0x9b),
|
||||
LV_COLOR_MAKE(0x08, 0x86, 0x08),
|
||||
LV_COLOR_MAKE(0x00, 0x4a, 0x00),
|
||||
LV_COLOR_MAKE(0xb8, 0xff, 0x9b),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x62, 0xd5, 0x15),
|
||||
LV_COLOR_MAKE(0x00, 0x74, 0x00)};
|
||||
constexpr std::array<lv_color_t, nLines> rainbowColors = {LV_COLOR_MAKE(0x2d, 0xa4, 0x00),
|
||||
LV_COLOR_MAKE(0xac, 0x09, 0xc4),
|
||||
LV_COLOR_MAKE(0xfe, 0x03, 0x03),
|
||||
LV_COLOR_MAKE(0x0d, 0x57, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xe0, 0xb9, 0x00),
|
||||
LV_COLOR_MAKE(0xe8, 0x51, 0x02)};
|
||||
constexpr std::array<lv_color_t, nLines> grayColors = {LV_COLOR_MAKE(0xee, 0xee, 0xee),
|
||||
LV_COLOR_MAKE(0x98, 0x95, 0x9b),
|
||||
LV_COLOR_MAKE(0x19, 0x19, 0x19),
|
||||
LV_COLOR_MAKE(0xee, 0xee, 0xee),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x91, 0x91, 0x91),
|
||||
LV_COLOR_MAKE(0x3a, 0x3a, 0x3a)};
|
||||
constexpr std::array<lv_color_t, nLines> nordBlueColors = {LV_COLOR_MAKE(0xc3, 0xda, 0xf2),
|
||||
LV_COLOR_MAKE(0x4d, 0x78, 0xce),
|
||||
LV_COLOR_MAKE(0x15, 0x34, 0x51),
|
||||
LV_COLOR_MAKE(0xc3, 0xda, 0xf2),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x5d, 0x8a, 0xd2),
|
||||
LV_COLOR_MAKE(0x21, 0x51, 0x8a)};
|
||||
constexpr std::array<lv_color_t, nLines> nordGreenColors = {LV_COLOR_MAKE(0xd5, 0xf0, 0xe9),
|
||||
LV_COLOR_MAKE(0x23, 0x83, 0x73),
|
||||
LV_COLOR_MAKE(0x1d, 0x41, 0x3f),
|
||||
LV_COLOR_MAKE(0xd5, 0xf0, 0xe9),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x2f, 0xb8, 0xa2),
|
||||
LV_COLOR_MAKE(0x11, 0x70, 0x5a)};
|
||||
|
||||
constexpr const std::array<lv_color_t, nLines>* returnColor(colors color) {
|
||||
if (color == colors::orange) {
|
||||
return &orangeColors;
|
||||
}
|
||||
if (color == colors::blue) {
|
||||
return &blueColors;
|
||||
}
|
||||
if (color == colors::green) {
|
||||
return &greenColors;
|
||||
}
|
||||
if (color == colors::rainbow) {
|
||||
return &rainbowColors;
|
||||
}
|
||||
if (color == colors::gray) {
|
||||
return &grayColors;
|
||||
}
|
||||
if (color == colors::nordBlue) {
|
||||
return &nordBlueColors;
|
||||
}
|
||||
return &nordGreenColors;
|
||||
}
|
||||
}
|
||||
|
||||
WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem)
|
||||
: currentDateTime {{}},
|
||||
dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
bleController {bleController},
|
||||
notificationManager {notificationManager},
|
||||
settingsController {settingsController},
|
||||
motionController {motionController} {
|
||||
lfs_file f = {};
|
||||
if (filesystem.FileOpen(&f, "/fonts/teko.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_teko = lv_font_load("F:/fonts/teko.bin");
|
||||
}
|
||||
|
||||
if (filesystem.FileOpen(&f, "/fonts/bebas.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_bebas = lv_font_load("F:/fonts/bebas.bin");
|
||||
}
|
||||
|
||||
// Side Cover
|
||||
static constexpr lv_point_t linePoints[nLines][2] = {{{30, 25}, {68, -8}},
|
||||
{{26, 167}, {43, 216}},
|
||||
{{27, 40}, {27, 196}},
|
||||
{{12, 182}, {65, 249}},
|
||||
{{17, 99}, {17, 144}},
|
||||
{{14, 81}, {40, 127}},
|
||||
{{14, 163}, {40, 118}},
|
||||
{{-20, 124}, {25, -11}},
|
||||
{{-29, 89}, {27, 254}}};
|
||||
|
||||
static constexpr lv_style_int_t lineWidths[nLines] = {18, 15, 14, 22, 20, 18, 18, 52, 48};
|
||||
|
||||
const std::array<lv_color_t, nLines>* colors = returnColor(static_cast<enum colors>(settingsController.GetInfineatColorIndex()));
|
||||
for (int i = 0; i < nLines; i++) {
|
||||
lines[i] = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_line_width(lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lineWidths[i]);
|
||||
lv_color_t color = (*colors)[i];
|
||||
lv_obj_set_style_local_line_color(lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, color);
|
||||
lv_line_set_points(lines[i], linePoints[i], 2);
|
||||
}
|
||||
|
||||
logoPine = lv_img_create(lv_scr_act(), nullptr);
|
||||
lv_img_set_src(logoPine, "F:/images/pine_small.bin");
|
||||
lv_obj_set_pos(logoPine, 15, 106);
|
||||
|
||||
lineBattery = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_line_width(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 24);
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
|
||||
lv_obj_set_style_local_line_opa(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 190);
|
||||
lineBatteryPoints[0] = {27, 105};
|
||||
lineBatteryPoints[1] = {27, 106};
|
||||
lv_line_set_points(lineBattery, lineBatteryPoints, 2);
|
||||
lv_obj_move_foreground(lineBattery);
|
||||
|
||||
notificationIcon = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7]);
|
||||
lv_obj_set_style_local_radius(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
lv_obj_set_size(notificationIcon, 13, 13);
|
||||
lv_obj_set_hidden(notificationIcon, true);
|
||||
|
||||
if (!settingsController.GetInfineatShowSideCover()) {
|
||||
ToggleBatteryIndicatorColor(false);
|
||||
for (auto& line : lines) {
|
||||
lv_obj_set_hidden(line, true);
|
||||
}
|
||||
}
|
||||
|
||||
timeContainer = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_bg_opa(timeContainer, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_size(timeContainer, 185, 185);
|
||||
lv_obj_align(timeContainer, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
|
||||
|
||||
labelHour = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(labelHour, "01");
|
||||
lv_obj_set_style_local_text_font(labelHour, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_bebas);
|
||||
lv_obj_align(labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
|
||||
labelMinutes = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(labelMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_bebas);
|
||||
lv_label_set_text_static(labelMinutes, "00");
|
||||
lv_obj_align(labelMinutes, timeContainer, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
|
||||
labelTimeAmPm = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(labelTimeAmPm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
|
||||
lv_label_set_text_static(labelTimeAmPm, "");
|
||||
lv_obj_align(labelTimeAmPm, timeContainer, LV_ALIGN_OUT_RIGHT_TOP, 0, 15);
|
||||
|
||||
dateContainer = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_bg_opa(dateContainer, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_size(dateContainer, 60, 30);
|
||||
lv_obj_align(dateContainer, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 5);
|
||||
|
||||
static constexpr lv_color_t grayColor = LV_COLOR_MAKE(0x99, 0x99, 0x99);
|
||||
labelDate = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_obj_set_style_local_text_font(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(labelDate, dateContainer, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
lv_label_set_text_static(labelDate, "Mon 01");
|
||||
|
||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
||||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||
|
||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 10, 0);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_label_set_text_static(stepIcon, Symbols::shoe);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
// Setting buttons
|
||||
btnClose = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnClose->user_data = this;
|
||||
lv_obj_set_size(btnClose, 60, 60);
|
||||
lv_obj_align(btnClose, lv_scr_act(), LV_ALIGN_CENTER, 0, -80);
|
||||
lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
lv_obj_t* lblClose = lv_label_create(btnClose, nullptr);
|
||||
lv_label_set_text_static(lblClose, "X");
|
||||
lv_obj_set_event_cb(btnClose, event_handler);
|
||||
lv_obj_set_hidden(btnClose, true);
|
||||
|
||||
btnNextColor = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnNextColor->user_data = this;
|
||||
lv_obj_set_size(btnNextColor, 60, 60);
|
||||
lv_obj_align(btnNextColor, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
|
||||
lv_obj_set_style_local_bg_opa(btnNextColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
lv_obj_t* lblNextColor = lv_label_create(btnNextColor, nullptr);
|
||||
lv_label_set_text_static(lblNextColor, ">");
|
||||
lv_obj_set_event_cb(btnNextColor, event_handler);
|
||||
lv_obj_set_hidden(btnNextColor, true);
|
||||
|
||||
btnPrevColor = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnPrevColor->user_data = this;
|
||||
lv_obj_set_size(btnPrevColor, 60, 60);
|
||||
lv_obj_align(btnPrevColor, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
|
||||
lv_obj_set_style_local_bg_opa(btnPrevColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
lv_obj_t* lblPrevColor = lv_label_create(btnPrevColor, nullptr);
|
||||
lv_label_set_text_static(lblPrevColor, "<");
|
||||
lv_obj_set_event_cb(btnPrevColor, event_handler);
|
||||
lv_obj_set_hidden(btnPrevColor, true);
|
||||
|
||||
btnToggleCover = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnToggleCover->user_data = this;
|
||||
lv_obj_set_size(btnToggleCover, 60, 60);
|
||||
lv_obj_align(btnToggleCover, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
||||
lv_obj_set_style_local_bg_opa(btnToggleCover, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
const char* labelToggle = settingsController.GetInfineatShowSideCover() ? "ON" : "OFF";
|
||||
lblToggle = lv_label_create(btnToggleCover, nullptr);
|
||||
lv_label_set_text_static(lblToggle, labelToggle);
|
||||
lv_obj_set_event_cb(btnToggleCover, event_handler);
|
||||
lv_obj_set_hidden(btnToggleCover, true);
|
||||
|
||||
// Button to access the settings
|
||||
btnSettings = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSettings->user_data = this;
|
||||
lv_obj_set_size(btnSettings, 150, 150);
|
||||
lv_obj_align(btnSettings, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_radius(btnSettings, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
|
||||
lv_obj_set_style_local_bg_opa(btnSettings, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
lv_obj_set_event_cb(btnSettings, event_handler);
|
||||
labelBtnSettings = lv_label_create(btnSettings, nullptr);
|
||||
lv_obj_set_style_local_text_font(labelBtnSettings, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||
lv_label_set_text_static(labelBtnSettings, Symbols::settings);
|
||||
lv_obj_set_hidden(btnSettings, true);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
WatchFaceInfineat::~WatchFaceInfineat() {
|
||||
lv_task_del(taskRefresh);
|
||||
|
||||
if (font_bebas != nullptr) {
|
||||
lv_font_free(font_bebas);
|
||||
}
|
||||
if (font_teko != nullptr) {
|
||||
lv_font_free(font_teko);
|
||||
}
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool WatchFaceInfineat::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnSettings)) {
|
||||
lv_obj_set_hidden(btnSettings, false);
|
||||
savedTick = lv_tick_get();
|
||||
return true;
|
||||
}
|
||||
// Prevent screen from sleeping when double tapping with settings on
|
||||
if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && !lv_obj_get_hidden(btnClose)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::CloseMenu() {
|
||||
settingsController.SaveSettings();
|
||||
lv_obj_set_hidden(btnClose, true);
|
||||
lv_obj_set_hidden(btnNextColor, true);
|
||||
lv_obj_set_hidden(btnPrevColor, true);
|
||||
lv_obj_set_hidden(btnToggleCover, true);
|
||||
}
|
||||
|
||||
bool WatchFaceInfineat::OnButtonPushed() {
|
||||
if (!lv_obj_get_hidden(btnClose)) {
|
||||
CloseMenu();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_CLICKED) {
|
||||
bool showSideCover = settingsController.GetInfineatShowSideCover();
|
||||
int colorIndex = settingsController.GetInfineatColorIndex();
|
||||
|
||||
if (object == btnSettings) {
|
||||
lv_obj_set_hidden(btnSettings, true);
|
||||
lv_obj_set_hidden(btnClose, false);
|
||||
lv_obj_set_hidden(btnNextColor, !showSideCover);
|
||||
lv_obj_set_hidden(btnPrevColor, !showSideCover);
|
||||
lv_obj_set_hidden(btnToggleCover, false);
|
||||
}
|
||||
if (object == btnClose) {
|
||||
CloseMenu();
|
||||
}
|
||||
if (object == btnToggleCover) {
|
||||
settingsController.SetInfineatShowSideCover(!showSideCover);
|
||||
ToggleBatteryIndicatorColor(!showSideCover);
|
||||
for (auto& line : lines) {
|
||||
lv_obj_set_hidden(line, showSideCover);
|
||||
}
|
||||
lv_obj_set_hidden(btnNextColor, showSideCover);
|
||||
lv_obj_set_hidden(btnPrevColor, showSideCover);
|
||||
const char* labelToggle = showSideCover ? "OFF" : "ON";
|
||||
lv_label_set_text_static(lblToggle, labelToggle);
|
||||
}
|
||||
if (object == btnNextColor) {
|
||||
colorIndex = (colorIndex + 1) % nColors;
|
||||
settingsController.SetInfineatColorIndex(colorIndex);
|
||||
}
|
||||
if (object == btnPrevColor) {
|
||||
colorIndex -= 1;
|
||||
if (colorIndex < 0)
|
||||
colorIndex = nColors - 1;
|
||||
settingsController.SetInfineatColorIndex(colorIndex);
|
||||
}
|
||||
if (object == btnNextColor || object == btnPrevColor) {
|
||||
const std::array<lv_color_t, nLines>* colors = returnColor(static_cast<enum colors>(settingsController.GetInfineatColorIndex()));
|
||||
for (int i = 0; i < nLines; i++) {
|
||||
lv_color_t color = (*colors)[i];
|
||||
lv_obj_set_style_local_line_color(lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, color);
|
||||
}
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::Refresh() {
|
||||
notificationState = notificationManager.AreNewNotificationsAvailable();
|
||||
if (notificationState.IsUpdated()) {
|
||||
lv_obj_set_hidden(notificationIcon, !notificationState.Get());
|
||||
lv_obj_align(notificationIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
}
|
||||
|
||||
currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime());
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
lv_label_set_text(labelTimeAmPm, ampmChar);
|
||||
}
|
||||
lv_label_set_text_fmt(labelHour, "%02d", hour);
|
||||
lv_label_set_text_fmt(labelMinutes, "%02d", minute);
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
lv_obj_align(labelTimeAmPm, timeContainer, LV_ALIGN_OUT_RIGHT_TOP, 0, 10);
|
||||
lv_obj_align(labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0, 5);
|
||||
lv_obj_align(labelMinutes, timeContainer, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
}
|
||||
|
||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
uint8_t day = dateTimeController.Day();
|
||||
lv_label_set_text_fmt(labelDate, "%s %02d", dateTimeController.DayOfWeekShortToStringLow(), day);
|
||||
lv_obj_realign(labelDate);
|
||||
}
|
||||
}
|
||||
|
||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||
isCharging = batteryController.IsCharging();
|
||||
if (batteryController.IsCharging()) { // Charging battery animation
|
||||
chargingBatteryPercent += 1;
|
||||
if (chargingBatteryPercent > 100) {
|
||||
chargingBatteryPercent = batteryPercentRemaining.Get();
|
||||
}
|
||||
SetBatteryLevel(chargingBatteryPercent);
|
||||
} else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) {
|
||||
chargingBatteryPercent = batteryPercentRemaining.Get();
|
||||
SetBatteryLevel(chargingBatteryPercent);
|
||||
}
|
||||
|
||||
bleState = bleController.IsConnected();
|
||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated()) {
|
||||
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 10, 0);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
}
|
||||
|
||||
if (!lv_obj_get_hidden(btnSettings)) {
|
||||
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
|
||||
lv_obj_set_hidden(btnSettings, true);
|
||||
savedTick = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::SetBatteryLevel(uint8_t batteryPercent) {
|
||||
// starting point (y) + Pine64 logo height * (100 - batteryPercent) / 100
|
||||
lineBatteryPoints[1] = {27, static_cast<lv_coord_t>(105 + 32 * (100 - batteryPercent) / 100)};
|
||||
lv_line_set_points(lineBattery, lineBatteryPoints, 2);
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::ToggleBatteryIndicatorColor(bool showSideCover) {
|
||||
if (!showSideCover) { // make indicator and notification icon color white
|
||||
lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);
|
||||
lv_obj_set_style_local_image_recolor(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
} else {
|
||||
lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||
const std::array<lv_color_t, nLines>* colors = returnColor(static_cast<enum colors>(settingsController.GetInfineatColorIndex()));
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7]);
|
||||
}
|
||||
}
|
||||
|
||||
bool WatchFaceInfineat::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
lfs_file file = {};
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/teko.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/fonts/bebas.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/images/pine_small.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
return true;
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <displayapp/Controllers.h>
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
#include "displayapp/apps/Apps.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class Settings;
|
||||
class Battery;
|
||||
class Ble;
|
||||
class NotificationManager;
|
||||
class MotionController;
|
||||
}
|
||||
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class WatchFaceInfineat : public Screen {
|
||||
public:
|
||||
static constexpr int nLines = 9;
|
||||
WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& fs);
|
||||
|
||||
~WatchFaceInfineat() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
bool OnButtonPushed() override;
|
||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||
void CloseMenu();
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
||||
|
||||
private:
|
||||
uint32_t savedTick = 0;
|
||||
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
|
||||
|
||||
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
|
||||
Utility::DirtyValue<bool> isCharging {};
|
||||
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<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;
|
||||
|
||||
// Lines making up the side cover
|
||||
lv_obj_t* lineBattery;
|
||||
|
||||
lv_point_t lineBatteryPoints[2];
|
||||
|
||||
lv_obj_t* logoPine;
|
||||
|
||||
lv_obj_t* timeContainer;
|
||||
lv_obj_t* labelHour;
|
||||
lv_obj_t* labelMinutes;
|
||||
lv_obj_t* labelTimeAmPm;
|
||||
lv_obj_t* dateContainer;
|
||||
lv_obj_t* labelDate;
|
||||
lv_obj_t* bleIcon;
|
||||
lv_obj_t* stepIcon;
|
||||
lv_obj_t* stepValue;
|
||||
lv_obj_t* notificationIcon;
|
||||
lv_obj_t* btnClose;
|
||||
lv_obj_t* btnNextColor;
|
||||
lv_obj_t* btnToggleCover;
|
||||
lv_obj_t* btnPrevColor;
|
||||
lv_obj_t* btnSettings;
|
||||
lv_obj_t* labelBtnSettings;
|
||||
lv_obj_t* lblToggle;
|
||||
|
||||
lv_obj_t* lines[nLines];
|
||||
|
||||
Controllers::DateTime& dateTimeController;
|
||||
const Controllers::Battery& batteryController;
|
||||
const Controllers::Ble& bleController;
|
||||
Controllers::NotificationManager& notificationManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
||||
void SetBatteryLevel(uint8_t batteryPercent);
|
||||
void ToggleBatteryIndicatorColor(bool showSideCover);
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
lv_font_t* font_teko = nullptr;
|
||||
lv_font_t* font_bebas = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct WatchFaceTraits<WatchFace::Infineat> {
|
||||
static constexpr WatchFace watchFace = WatchFace::Infineat;
|
||||
static constexpr const char* name = "Infineat face";
|
||||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::WatchFaceInfineat(controllers.dateTimeController,
|
||||
controllers.batteryController,
|
||||
controllers.bleController,
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController,
|
||||
controllers.motionController,
|
||||
controllers.filesystem);
|
||||
};
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
return Screens::WatchFaceInfineat::IsAvailable(filesystem);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
#include <lvgl/lvgl.h>
|
||||
#include "displayapp/screens/WatchFaceTerminal.h"
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#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;
|
||||
|
||||
WatchFaceTerminal::WatchFaceTerminal(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},
|
||||
batteryController {batteryController},
|
||||
bleController {bleController},
|
||||
notificationManager {notificationManager},
|
||||
settingsController {settingsController},
|
||||
heartRateController {heartRateController},
|
||||
motionController {motionController} {
|
||||
batteryValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(batteryValue, true);
|
||||
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
|
||||
|
||||
connectState = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(connectState, true);
|
||||
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
|
||||
|
||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
|
||||
|
||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(label_date, true);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
|
||||
|
||||
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
|
||||
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
|
||||
|
||||
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
|
||||
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
|
||||
|
||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(label_time, true);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
|
||||
|
||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(heartbeatValue, true);
|
||||
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
|
||||
|
||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(stepValue, true);
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
WatchFaceTerminal::~WatchFaceTerminal() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
void WatchFaceTerminal::Refresh() {
|
||||
powerPresent = batteryController.IsPowerPresent();
|
||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
|
||||
lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
|
||||
if (batteryController.IsPowerPresent()) {
|
||||
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
|
||||
}
|
||||
}
|
||||
|
||||
bleState = bleController.IsConnected();
|
||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||
if (!bleRadioEnabled.Get()) {
|
||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
|
||||
} else {
|
||||
if (bleState.Get()) {
|
||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
|
||||
} else {
|
||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notificationState = notificationManager.AreNewNotificationsAvailable();
|
||||
if (notificationState.IsUpdated()) {
|
||||
if (notificationState.Get()) {
|
||||
lv_label_set_text_static(notificationIcon, "You have mail.");
|
||||
} else {
|
||||
lv_label_set_text_static(notificationIcon, "");
|
||||
}
|
||||
}
|
||||
|
||||
currentDateTime = std::chrono::time_point_cast<std::chrono::seconds>(dateTimeController.CurrentDateTime());
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
uint8_t second = dateTimeController.Seconds();
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
|
||||
}
|
||||
|
||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
uint16_t year = dateTimeController.Year();
|
||||
Controllers::DateTime::Months month = dateTimeController.Month();
|
||||
uint8_t day = dateTimeController.Day();
|
||||
lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day));
|
||||
}
|
||||
}
|
||||
|
||||
heartbeat = heartRateController.HeartRate();
|
||||
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
||||
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
||||
if (heartbeatRunning.Get()) {
|
||||
lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
|
||||
} else {
|
||||
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
|
||||
}
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <lvgl/src/lv_core/lv_obj.h>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <displayapp/Controllers.h>
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class Settings;
|
||||
class Battery;
|
||||
class Ble;
|
||||
class NotificationManager;
|
||||
class HeartRateController;
|
||||
class MotionController;
|
||||
}
|
||||
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class WatchFaceTerminal : public Screen {
|
||||
public:
|
||||
WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController);
|
||||
~WatchFaceTerminal() override;
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
Utility::DirtyValue<int> 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::seconds>> 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_date;
|
||||
lv_obj_t* label_prompt_1;
|
||||
lv_obj_t* label_prompt_2;
|
||||
lv_obj_t* batteryValue;
|
||||
lv_obj_t* heartbeatValue;
|
||||
lv_obj_t* stepValue;
|
||||
lv_obj_t* notificationIcon;
|
||||
lv_obj_t* connectState;
|
||||
|
||||
Controllers::DateTime& dateTimeController;
|
||||
const Controllers::Battery& batteryController;
|
||||
const Controllers::Ble& bleController;
|
||||
Controllers::NotificationManager& notificationManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct WatchFaceTraits<WatchFace::Terminal> {
|
||||
static constexpr WatchFace watchFace = WatchFace::Terminal;
|
||||
static constexpr const char* name = "Terminal";
|
||||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::WatchFaceTerminal(controllers.dateTimeController,
|
||||
controllers.batteryController,
|
||||
controllers.bleController,
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController,
|
||||
controllers.heartRateController,
|
||||
controllers.motionController);
|
||||
};
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
69
src/displayapp/screens/settings/SettingLocation.cpp
Normal file
69
src/displayapp/screens/settings/SettingLocation.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include "displayapp/screens/settings/SettingLocation.h"
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <nrf_log.h>
|
||||
#include "displayapp/DisplayApp.h"
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "displayapp/InfiniTimeTheme.h"
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
constexpr int16_t POS_Y_TEXT = 25;
|
||||
|
||||
void ValueChangedHandler(void* userData) {
|
||||
auto* screen = static_cast<SettingLocation*>(userData);
|
||||
screen->UpdateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
SettingLocation::SettingLocation(Pinetime::Controllers::Settings& settingsController)
|
||||
: settingsController {settingsController} {
|
||||
|
||||
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(title, "Set location\n(lat/long/tz)");
|
||||
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
|
||||
|
||||
lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||
lv_label_set_text_static(icon, Symbols::map);
|
||||
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||
|
||||
Controllers::Settings::Location loc = settingsController.GetLocation();
|
||||
|
||||
latCounter.Create();
|
||||
latCounter.SetWidth(80);
|
||||
latCounter.SetValue(loc.latitude);
|
||||
lv_obj_align(latCounter.GetObject(), nullptr, LV_ALIGN_CENTER, -90, POS_Y_TEXT);
|
||||
latCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
|
||||
|
||||
longCounter.Create();
|
||||
longCounter.SetWidth(110);
|
||||
longCounter.SetValue(loc.longitude);
|
||||
lv_obj_align(longCounter.GetObject(), nullptr, LV_ALIGN_CENTER, -5, POS_Y_TEXT);
|
||||
longCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
|
||||
|
||||
tzCounter.Create();
|
||||
tzCounter.SetWidth(60);
|
||||
tzCounter.SetValue(loc.tzOffset);
|
||||
lv_obj_align(tzCounter.GetObject(), nullptr, LV_ALIGN_CENTER, 75, POS_Y_TEXT);
|
||||
tzCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
|
||||
|
||||
UpdateScreen();
|
||||
}
|
||||
|
||||
SettingLocation::~SettingLocation() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
settingsController.SaveSettings();
|
||||
}
|
||||
|
||||
void SettingLocation::UpdateScreen() {
|
||||
Controllers::Settings::Location loc = {
|
||||
latitude: (int16_t)latCounter.GetValue(),
|
||||
longitude: (int16_t)longCounter.GetValue(),
|
||||
tzOffset: (int8_t)tzCounter.GetValue(),
|
||||
};
|
||||
settingsController.SetLocation(loc);
|
||||
}
|
31
src/displayapp/screens/settings/SettingLocation.h
Normal file
31
src/displayapp/screens/settings/SettingLocation.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "displayapp/widgets/Counter.h"
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "displayapp/widgets/DotIndicator.h"
|
||||
#include "displayapp/screens/settings/SettingSetDateTime.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
class SettingLocation : public Screen {
|
||||
public:
|
||||
SettingLocation(Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingLocation() override;
|
||||
|
||||
void UpdateScreen();
|
||||
|
||||
private:
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
Widgets::Counter latCounter = Widgets::Counter(-90, 90, jetbrains_mono_42);
|
||||
Widgets::Counter longCounter = Widgets::Counter(-180, 180, jetbrains_mono_42);
|
||||
Widgets::Counter tzCounter = Widgets::Counter(-12, 12, jetbrains_mono_42);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,8 +9,8 @@
|
|||
#include "displayapp/screens/Screen.h"
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "displayapp/screens/CheckboxList.h"
|
||||
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
// #include "displayapp/screens/WatchFaceInfineat.h"
|
||||
// #include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
|
||||
namespace Pinetime {
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Pinetime {
|
|||
|
||||
{Symbols::shoe, "Steps", Apps::SettingSteps},
|
||||
{Symbols::clock, "Date&Time", Apps::SettingSetDateTime},
|
||||
{Symbols::map, "Location", Apps::SettingLocation},
|
||||
{Symbols::cloudSunRain, "Weather", Apps::SettingWeatherFormat},
|
||||
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
|
||||
|
||||
|
|
|
@ -136,8 +136,7 @@ void Counter::Create() {
|
|||
|
||||
static constexpr uint8_t padding = 5;
|
||||
const uint8_t width = std::max(lv_obj_get_width(number) + padding * 2, 58);
|
||||
static constexpr uint8_t btnHeight = 50;
|
||||
const uint8_t containerHeight = btnHeight * 2 + lv_obj_get_height(number) + padding * 2;
|
||||
containerHeight = btnHeight * 2 + lv_obj_get_height(number) + padding * 2;
|
||||
|
||||
lv_obj_set_size(counterContainer, width, containerHeight);
|
||||
|
||||
|
|
|
@ -18,6 +18,15 @@ namespace Pinetime {
|
|||
void EnableMonthMode();
|
||||
void SetMax(int newMax);
|
||||
void SetValueChangedEventCallback(void* userData, void (*handler)(void* userData));
|
||||
void SetWidth(uint8_t width) {
|
||||
lv_obj_set_size(counterContainer, width, containerHeight);
|
||||
lv_obj_set_size(upBtn, width, btnHeight);
|
||||
lv_obj_set_size(downBtn, width, btnHeight);
|
||||
linePoints[0] = {0, 0};
|
||||
linePoints[1] = {width, 0};
|
||||
lv_line_set_points(upperLine, linePoints, 2);
|
||||
lv_line_set_points(lowerLine, linePoints, 2);
|
||||
}
|
||||
|
||||
int GetValue() const {
|
||||
return value;
|
||||
|
@ -42,6 +51,8 @@ namespace Pinetime {
|
|||
int max;
|
||||
int value;
|
||||
const int leadingZeroCount;
|
||||
uint8_t containerHeight;
|
||||
static constexpr uint8_t btnHeight = 50;
|
||||
bool twelveHourMode = false;
|
||||
bool monthMode = false;
|
||||
lv_font_t& font;
|
||||
|
|
1
src/libs/sunset
Submodule
1
src/libs/sunset
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 4b08734eb8856154d7226bfdced91a571fb6a64b
|
|
@ -5,7 +5,7 @@ message(STATUS "Using ${LV_FONT_CONV} to generate font files")
|
|||
|
||||
find_program(LV_IMG_CONV "lv_img_conv.py" NO_CACHE REQUIRED
|
||||
HINTS "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
message(STATUS "Using ${LV_IMG_CONV} to generate font files")
|
||||
message(STATUS "Using ${LV_IMG_CONV} to generate image files")
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
|
||||
# FindPython3 module introduces with CMake 3.12
|
||||
|
|
|
@ -6,6 +6,13 @@
|
|||
"binary_format": "ARGB8565_RBSWAP",
|
||||
"target_path": "/images/"
|
||||
},
|
||||
"aor" : {
|
||||
"sources": "images/aor.png",
|
||||
"color_format": "CF_TRUE_COLOR_ALPHA",
|
||||
"output_format": "bin",
|
||||
"binary_format": "ARGB8565_RBSWAP",
|
||||
"target_path": "/images/"
|
||||
},
|
||||
"navigation0" : {
|
||||
"sources": "images/navigation0.png",
|
||||
"color_format": "CF_INDEXED_1_BIT",
|
||||
|
|
BIN
src/resources/images/aor.png
Executable file
BIN
src/resources/images/aor.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 161 KiB |
Loading…
Reference in New Issue
Block a user