Skip to content

Commit

Permalink
Merged the Calendar app PR into the most recent upstream code: 'ecf2f…
Browse files Browse the repository at this point in the history
…56'. 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.
  • Loading branch information
JustScott committed Jan 10, 2024
2 parents ecf2f56 + 72c8b14 commit 4eac31b
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/Label.cpp
displayapp/screens/FirmwareUpdate.cpp
displayapp/screens/Music.cpp
displayapp/screens/Calendar.cpp
displayapp/screens/Navigation.cpp
displayapp/screens/Metronome.cpp
displayapp/screens/Motion.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "displayapp/screens/StopWatch.h"
#include "displayapp/screens/Metronome.h"
#include "displayapp/screens/Music.h"
#include "displayapp/screens/Calendar.h"
#include "displayapp/screens/Navigation.h"
#include "displayapp/screens/Notifications.h"
#include "displayapp/screens/SystemInfo.h"
Expand Down Expand Up @@ -540,6 +541,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
case Apps::FlashLight:
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);
break;
case Apps::Calendar:
currentScreen = std::make_unique<Screens::Calendar>(dateTimeController);
break;
default: {
const auto* d = std::find_if(userApps.begin(), userApps.end(), [app](const AppDescription& appDescription) {
return appDescription.app == app;
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/apps/Apps.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Pinetime {
Twos,
HeartRate,
Navigation,
Calendar,
StopWatch,
Metronome,
Motion,
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ else ()
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Twos")
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Metronome")
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Navigation")
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Calendar")
#set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Weather")
#set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Motion")
set(USERAPP_TYPES "${DEFAULT_USER_APP_TYPES}" CACHE STRING "List of user apps to build into the firmware")
Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/fonts/fonts.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
{
"file": "FontAwesome5-Solid+Brands+Regular.woff",
"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"
"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"
}
],
"bpp": 1,
Expand Down
19 changes: 19 additions & 0 deletions src/displayapp/screens/ApplicationList.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ namespace Pinetime {

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

/*<<<<<<< HEAD
=======
static constexpr std::array<Tile::Applications, appsPerScreen * nScreens> applications {{
{Symbols::stopWatch, Apps::StopWatch},
{Symbols::clock, Apps::Alarm},
{Symbols::hourGlass, Apps::Timer},
{Symbols::shoe, Apps::Steps},
{Symbols::heartBeat, Apps::HeartRate},
{Symbols::music, Apps::Music},
{Symbols::paintbrush, Apps::Paint},
{Symbols::paddle, Apps::Paddle},
{"2", Apps::Twos},
{Symbols::drum, Apps::Metronome},
{Symbols::map, Apps::Navigation},
{Symbols::calendar, Apps::Calendar},
// {"M", Apps::Motion},
}};
>>>>>>> calendar_pr/rebase_calendar*/
ScreenList<nScreens> screens;
};
}
Expand Down
86 changes: 86 additions & 0 deletions src/displayapp/screens/Calendar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "displayapp/screens/Calendar.h"
#include "components/datetime/DateTimeController.h"

using namespace Pinetime::Applications::Screens;

Calendar::Calendar(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {

// Create calendar object
calendar = lv_calendar_create(lv_scr_act(), NULL);
// Set size
lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES);
// Set alignment
lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5);
// Disable clicks
lv_obj_set_click(calendar, false);

// Set background of today's date
//lv_obj_set_style_local_bg_opa(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_OPA_COVER);
//lv_obj_set_style_local_bg_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_WHITE);
//lv_obj_set_style_local_radius(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, 3);

// Set style of today's date
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED);

// Set style of inactive month's days
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050));

// Get today's date
today.year = static_cast<int>(dateTimeController.Year());
today.month = static_cast<int>(dateTimeController.Month());
today.day = static_cast<int>(dateTimeController.Day());

// Set today's date
lv_calendar_set_today_date(calendar, &today);
lv_calendar_set_showed_date(calendar, &today);

// Use today's date as a reference for which month to show if moved
current = today;

}

bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case TouchEvents::SwipeLeft: {
if (current.month == 12) {
current.month = 1;
current.year++;
}
else{
current.month++;
}
lv_calendar_set_showed_date(calendar, &current);
return true;
}
case TouchEvents::SwipeRight: {
if (current.month == 1) {
current.month = 12;
current.year--;
}
else{
current.month--;
}
lv_calendar_set_showed_date(calendar, &current);
return true;
}
/*
case TouchEvents::SwipeUp: {
current.year++;
lv_calendar_set_showed_date(calendar, &current);
return true;
}
case TouchEvents::SwipeDown: {
current.year--;
lv_calendar_set_showed_date(calendar, &current);
return true;
}
*/
default: {
return false;
}
}
}

Calendar::~Calendar() {
lv_obj_clean(lv_scr_act());
}
42 changes: 42 additions & 0 deletions src/displayapp/screens/Calendar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#include "displayapp/apps/Apps.h"
#include "displayapp/Controllers.h"
#include "displayapp/screens/Screen.h"
#include "components/datetime/DateTimeController.h"
#include <lvgl/lvgl.h>

#include "Symbols.h"

namespace Pinetime {
namespace Controllers {
class Settings;
}

namespace Applications {
namespace Screens {
class Calendar : public Screen {
public:
Calendar(Controllers::DateTime& dateTimeController);
~Calendar() override;
private:
bool OnTouchEvent(TouchEvents event);
Controllers::DateTime& dateTimeController;
lv_obj_t* label_time;
lv_obj_t * calendar;
lv_calendar_date_t today;
lv_calendar_date_t current;
};
}

template <>
struct AppTraits<Apps::Calendar> {
static constexpr Apps app = Apps::Calendar;
static constexpr const char* icon = Screens::Symbols::calendar;

static Screens::Screen* Create(AppControllers& controllers) {
return new Screens::Calendar(controllers.dateTimeController);
};
};
}
}
2 changes: 2 additions & 0 deletions src/displayapp/screens/Symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace Pinetime {
static constexpr const char* home = "\xEF\x80\x95";
static constexpr const char* sleep = "\xEE\xBD\x84";

static constexpr const char* calendar = "\xEF\x81\xB3";

// fontawesome_weathericons.c
// static constexpr const char* sun = "\xEF\x86\x85";
static constexpr const char* cloudSun = "\xEF\x9B\x84";
Expand Down

0 comments on commit 4eac31b

Please sign in to comment.