Skip to content

Commit 4eac31b

Browse files
committed
Merged the Calendar app PR into the most recent upstream code: 'ecf2f56'. Commented out the swipe up/down to increase/decrease the current calendar's year as this interferes with the built in swipe down to exit ability.
2 parents ecf2f56 + 72c8b14 commit 4eac31b

9 files changed

+157
-1
lines changed

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ list(APPEND SOURCE_FILES
376376
displayapp/screens/Label.cpp
377377
displayapp/screens/FirmwareUpdate.cpp
378378
displayapp/screens/Music.cpp
379+
displayapp/screens/Calendar.cpp
379380
displayapp/screens/Navigation.cpp
380381
displayapp/screens/Metronome.cpp
381382
displayapp/screens/Motion.cpp

src/displayapp/DisplayApp.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "displayapp/screens/StopWatch.h"
1919
#include "displayapp/screens/Metronome.h"
2020
#include "displayapp/screens/Music.h"
21+
#include "displayapp/screens/Calendar.h"
2122
#include "displayapp/screens/Navigation.h"
2223
#include "displayapp/screens/Notifications.h"
2324
#include "displayapp/screens/SystemInfo.h"
@@ -540,6 +541,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
540541
case Apps::FlashLight:
541542
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);
542543
break;
544+
case Apps::Calendar:
545+
currentScreen = std::make_unique<Screens::Calendar>(dateTimeController);
546+
break;
543547
default: {
544548
const auto* d = std::find_if(userApps.begin(), userApps.end(), [app](const AppDescription& appDescription) {
545549
return appDescription.app == app;

src/displayapp/apps/Apps.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace Pinetime {
2323
Twos,
2424
HeartRate,
2525
Navigation,
26+
Calendar,
2627
StopWatch,
2728
Metronome,
2829
Motion,

src/displayapp/apps/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ else ()
1212
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Twos")
1313
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Metronome")
1414
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Navigation")
15+
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Calendar")
1516
#set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Weather")
1617
#set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Motion")
1718
set(USERAPP_TYPES "${DEFAULT_USER_APP_TYPES}" CACHE STRING "List of user apps to build into the firmware")

src/displayapp/fonts/fonts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
{
99
"file": "FontAwesome5-Solid+Brands+Regular.woff",
10-
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf743"
10+
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf743, 0xf073"
1111
}
1212
],
1313
"bpp": 1,

src/displayapp/screens/ApplicationList.h

+19
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ namespace Pinetime {
4040

4141
static constexpr int nScreens = UserAppTypes::Count > 0 ? (UserAppTypes::Count - 1) / appsPerScreen + 1 : 1;
4242

43+
/*<<<<<<< HEAD
44+
=======
45+
static constexpr std::array<Tile::Applications, appsPerScreen * nScreens> applications {{
46+
{Symbols::stopWatch, Apps::StopWatch},
47+
{Symbols::clock, Apps::Alarm},
48+
{Symbols::hourGlass, Apps::Timer},
49+
{Symbols::shoe, Apps::Steps},
50+
{Symbols::heartBeat, Apps::HeartRate},
51+
{Symbols::music, Apps::Music},
52+
53+
{Symbols::paintbrush, Apps::Paint},
54+
{Symbols::paddle, Apps::Paddle},
55+
{"2", Apps::Twos},
56+
{Symbols::drum, Apps::Metronome},
57+
{Symbols::map, Apps::Navigation},
58+
{Symbols::calendar, Apps::Calendar},
59+
// {"M", Apps::Motion},
60+
}};
61+
>>>>>>> calendar_pr/rebase_calendar*/
4362
ScreenList<nScreens> screens;
4463
};
4564
}

src/displayapp/screens/Calendar.cpp

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include "displayapp/screens/Calendar.h"
2+
#include "components/datetime/DateTimeController.h"
3+
4+
using namespace Pinetime::Applications::Screens;
5+
6+
Calendar::Calendar(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {
7+
8+
// Create calendar object
9+
calendar = lv_calendar_create(lv_scr_act(), NULL);
10+
// Set size
11+
lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES);
12+
// Set alignment
13+
lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5);
14+
// Disable clicks
15+
lv_obj_set_click(calendar, false);
16+
17+
// Set background of today's date
18+
//lv_obj_set_style_local_bg_opa(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_OPA_COVER);
19+
//lv_obj_set_style_local_bg_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_WHITE);
20+
//lv_obj_set_style_local_radius(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, 3);
21+
22+
// Set style of today's date
23+
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED);
24+
25+
// Set style of inactive month's days
26+
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050));
27+
28+
// Get today's date
29+
today.year = static_cast<int>(dateTimeController.Year());
30+
today.month = static_cast<int>(dateTimeController.Month());
31+
today.day = static_cast<int>(dateTimeController.Day());
32+
33+
// Set today's date
34+
lv_calendar_set_today_date(calendar, &today);
35+
lv_calendar_set_showed_date(calendar, &today);
36+
37+
// Use today's date as a reference for which month to show if moved
38+
current = today;
39+
40+
}
41+
42+
bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
43+
switch (event) {
44+
case TouchEvents::SwipeLeft: {
45+
if (current.month == 12) {
46+
current.month = 1;
47+
current.year++;
48+
}
49+
else{
50+
current.month++;
51+
}
52+
lv_calendar_set_showed_date(calendar, &current);
53+
return true;
54+
}
55+
case TouchEvents::SwipeRight: {
56+
if (current.month == 1) {
57+
current.month = 12;
58+
current.year--;
59+
}
60+
else{
61+
current.month--;
62+
}
63+
lv_calendar_set_showed_date(calendar, &current);
64+
return true;
65+
}
66+
/*
67+
case TouchEvents::SwipeUp: {
68+
current.year++;
69+
lv_calendar_set_showed_date(calendar, &current);
70+
return true;
71+
}
72+
case TouchEvents::SwipeDown: {
73+
current.year--;
74+
lv_calendar_set_showed_date(calendar, &current);
75+
return true;
76+
}
77+
*/
78+
default: {
79+
return false;
80+
}
81+
}
82+
}
83+
84+
Calendar::~Calendar() {
85+
lv_obj_clean(lv_scr_act());
86+
}

src/displayapp/screens/Calendar.h

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#pragma once
2+
3+
#include "displayapp/apps/Apps.h"
4+
#include "displayapp/Controllers.h"
5+
#include "displayapp/screens/Screen.h"
6+
#include "components/datetime/DateTimeController.h"
7+
#include <lvgl/lvgl.h>
8+
9+
#include "Symbols.h"
10+
11+
namespace Pinetime {
12+
namespace Controllers {
13+
class Settings;
14+
}
15+
16+
namespace Applications {
17+
namespace Screens {
18+
class Calendar : public Screen {
19+
public:
20+
Calendar(Controllers::DateTime& dateTimeController);
21+
~Calendar() override;
22+
private:
23+
bool OnTouchEvent(TouchEvents event);
24+
Controllers::DateTime& dateTimeController;
25+
lv_obj_t* label_time;
26+
lv_obj_t * calendar;
27+
lv_calendar_date_t today;
28+
lv_calendar_date_t current;
29+
};
30+
}
31+
32+
template <>
33+
struct AppTraits<Apps::Calendar> {
34+
static constexpr Apps app = Apps::Calendar;
35+
static constexpr const char* icon = Screens::Symbols::calendar;
36+
37+
static Screens::Screen* Create(AppControllers& controllers) {
38+
return new Screens::Calendar(controllers.dateTimeController);
39+
};
40+
};
41+
}
42+
}

src/displayapp/screens/Symbols.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ namespace Pinetime {
3838
static constexpr const char* home = "\xEF\x80\x95";
3939
static constexpr const char* sleep = "\xEE\xBD\x84";
4040

41+
static constexpr const char* calendar = "\xEF\x81\xB3";
42+
4143
// fontawesome_weathericons.c
4244
// static constexpr const char* sun = "\xEF\x86\x85";
4345
static constexpr const char* cloudSun = "\xEF\x9B\x84";

0 commit comments

Comments
 (0)