WORKING on real PineTime
This commit is contained in:
parent
b002fddc29
commit
8f32478141
|
@ -478,7 +478,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Apps::Agenda:
|
case Apps::Agenda:
|
||||||
currentScreen = std::make_unique<Screens::Agenda>(this, systemTask->nimble().agenda());
|
currentScreen = std::make_unique<Screens::Agenda>(this, systemTask->nimble().agenda(), dateTimeController);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentApp = app;
|
currentApp = app;
|
||||||
|
|
|
@ -8,7 +8,7 @@ using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
using namespace Pinetime::Controllers;
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
Agenda::Agenda(DisplayApp* app, AgendaService& agenda) : Screen(app), agendaSvc(agenda) {
|
Agenda::Agenda(DisplayApp* app, AgendaService& agenda, Controllers::DateTime& dateTimeController) : Screen(app), agendaSvc(agenda), dateTimeController(dateTimeController) {
|
||||||
lv_obj_t* alignNextTo = lv_scr_act();
|
lv_obj_t* alignNextTo = lv_scr_act();
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 4; ++i) {
|
for (uint8_t i = 0; i < 4; ++i) {
|
||||||
|
@ -35,12 +35,12 @@ Agenda::~Agenda() {
|
||||||
void Agenda::Refresh() {
|
void Agenda::Refresh() {
|
||||||
using namespace date;
|
using namespace date;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
std::chrono::system_clock::time_point now = dateTimeController.CurrentDateTime();
|
||||||
auto todayDate = floor<date::days>(now);
|
auto todayDate = floor<date::days>(now);
|
||||||
auto nowTimePart = make_time(now - todayDate);
|
auto nowTimePart = make_time(now - todayDate);
|
||||||
|
|
||||||
auto todayYmd = year_month_day(todayDate);
|
auto todayYmd = year_month_day(todayDate);
|
||||||
NRF_LOG_INFO("date CURRENT %d-%u-%u %ldh%ldh%ld", (int) todayYmd.year(), (unsigned) todayYmd.month(), (unsigned) todayYmd.day(), nowTimePart.hours().count(), nowTimePart.minutes().count(), nowTimePart.seconds().count());
|
// NRF_LOG_INFO("date CURRENT %d-%u-%u %ldh%ldh%ld", (int) todayYmd.year(), (unsigned) todayYmd.month(), (unsigned) todayYmd.day(), nowTimePart.hours().count(), nowTimePart.minutes().count(), nowTimePart.seconds().count());
|
||||||
|
|
||||||
//std::cout << todayDate << ' ' << nowTimePart << '\n';
|
//std::cout << todayDate << ' ' << nowTimePart << '\n';
|
||||||
|
|
||||||
|
@ -54,19 +54,22 @@ void Agenda::Refresh() {
|
||||||
lv_label_set_text_static(agendaItem, "--h--\n .....");
|
lv_label_set_text_static(agendaItem, "--h--\n .....");
|
||||||
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x332222));
|
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x332222));
|
||||||
} else {
|
} else {
|
||||||
auto timestamp = std::chrono::system_clock::time_point{time * 1s};
|
sys_seconds timestamp = sys_days{1970_y/1/1} + seconds{time};
|
||||||
auto agendaDate = floor<days>(timestamp);
|
//auto timestamp = std::chrono::system_clock::time_point{time * 1s};
|
||||||
auto agendaTimePart = make_time(timestamp - agendaDate);
|
sys_days agendaDate = floor<days>(timestamp);
|
||||||
auto ymd = year_month_day(agendaDate);
|
time_of_day<seconds> agendaTimePart = make_time(timestamp - agendaDate);
|
||||||
|
year_month_day ymd = year_month_day(agendaDate);
|
||||||
//std::cout << agendaDate << ' ' << agendaTimePart << '\n';
|
//std::cout << agendaDate << ' ' << agendaTimePart << '\n';
|
||||||
|
|
||||||
/*std::time_t result = std::time(nullptr);
|
/*std::time_t result = std::time(nullptr);
|
||||||
std::time_t result = std::time(nullptr);
|
std::time_t result = std::time(nullptr);
|
||||||
std::chrono::time_point = */;
|
std::chrono::time_point = */;
|
||||||
|
|
||||||
NRF_LOG_INFO("unix IDX%u %lld", itemIdx, time);
|
// NRF_LOG_INFO("IDX %u", itemIdx);
|
||||||
NRF_LOG_INFO("date IDX%u %d-%u-%u %ldh%ldh%ld", itemIdx, (int) ymd.year(), (unsigned) ymd.month(), (unsigned) ymd.day(), agendaTimePart.hours().count(), agendaTimePart.minutes().count(), agendaTimePart.seconds().count());
|
// NRF_LOG_INFO("unix %u", time);
|
||||||
NRF_LOG_INFO("item IDX%u %s", itemIdx, agendaSvc.getAgendaPiece(itemIdx).data());
|
// NRF_LOG_INFO("date %d-%u-%u ", (int) ymd.year(), (unsigned) ymd.month(), (unsigned) ymd.day());
|
||||||
|
// NRF_LOG_INFO("time %ldh%ldm%ld", agendaTimePart.hours().count(), agendaTimePart.minutes().count(), agendaTimePart.seconds().count());
|
||||||
|
// NRF_LOG_INFO("item %s", agendaSvc.getAgendaPiece(itemIdx).data());
|
||||||
|
|
||||||
if (agendaDate == todayDate) {
|
if (agendaDate == todayDate) {
|
||||||
lv_label_set_text_fmt(agendaItem, "%02lldh%02lld\n %s", agendaTimePart.hours().count(), agendaTimePart.minutes().count(), agendaSvc.getAgendaPiece(itemIdx).data());
|
lv_label_set_text_fmt(agendaItem, "%02lldh%02lld\n %s", agendaTimePart.hours().count(), agendaTimePart.minutes().count(), agendaSvc.getAgendaPiece(itemIdx).data());
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
|
#include "components/datetime/DateTimeController.h"
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class AgendaService;
|
class AgendaService;
|
||||||
|
class DateTime;
|
||||||
}
|
}
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
namespace Screens {
|
namespace Screens {
|
||||||
class Agenda : public Screen {
|
class Agenda : public Screen {
|
||||||
public:
|
public:
|
||||||
Agenda(DisplayApp* app, Pinetime::Controllers::AgendaService& agendaSvc);
|
Agenda(DisplayApp* app, Pinetime::Controllers::AgendaService& agendaSvc, Pinetime::Controllers::DateTime &dateTimeController);
|
||||||
~Agenda() override;
|
~Agenda() override;
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
@ -19,6 +21,8 @@ namespace Pinetime {
|
||||||
private:
|
private:
|
||||||
Pinetime::Controllers::AgendaService& agendaSvc;
|
Pinetime::Controllers::AgendaService& agendaSvc;
|
||||||
|
|
||||||
|
Controllers::DateTime& dateTimeController;
|
||||||
|
|
||||||
lv_obj_t* agendaItems[4];
|
lv_obj_t* agendaItems[4];
|
||||||
uint8_t pagingOffset;
|
uint8_t pagingOffset;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue