Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/List.cpp
displayapp/screens/BatteryInfo.cpp
displayapp/screens/Steps.cpp
displayapp/screens/Timer.cpp

## Settings
displayapp/screens/settings/QuickSettings.cpp
Expand Down Expand Up @@ -459,6 +460,7 @@ list(APPEND SOURCE_FILES
components/firmwarevalidator/FirmwareValidator.cpp
components/motor/MotorController.cpp
components/settings/Settings.cpp
components/timer/TimerController.cpp
drivers/Cst816s.cpp
FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c
Expand Down Expand Up @@ -520,6 +522,7 @@ list(APPEND RECOVERY_SOURCE_FILES
components/ble/HeartRateService.cpp
components/firmwarevalidator/FirmwareValidator.cpp
components/settings/Settings.cpp
components/timer/TimerController.cpp
drivers/Cst816s.cpp
FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c
Expand Down Expand Up @@ -590,6 +593,7 @@ set(INCLUDE_FILES
displayapp/screens/Notifications.h
displayapp/screens/HeartRate.h
displayapp/screens/Motion.h
displayapp/screens/Timer.h
drivers/St7789.h
drivers/SpiNorFlash.h
drivers/SpiMaster.h
Expand Down Expand Up @@ -619,6 +623,7 @@ set(INCLUDE_FILES
components/ble/BleClient.h
components/ble/HeartRateService.h
components/settings/Settings.h
components/timer/TimerController.h
drivers/Cst816s.h
FreeRTOS/portmacro.h
FreeRTOS/portmacro_cmsis.h
Expand Down
1 change: 0 additions & 1 deletion src/components/motor/MotorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ MotorController::MotorController(Controllers::Settings& settingsController) : se
void MotorController::Init() {
nrf_gpio_cfg_output(pinMotor);
nrf_gpio_pin_set(pinMotor);
app_timer_init();
app_timer_create(&vibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrate);
}

Expand Down
64 changes: 64 additions & 0 deletions src/components/timer/TimerController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Created by florian on 16.05.21.
//

#include "TimerController.h"
#include "systemtask/SystemTask.h"
#include "app_timer.h"
#include "task.h"

using namespace Pinetime::Controllers;


APP_TIMER_DEF(timerAppTimer);


TimerController::TimerController(System::SystemTask& systemTask) : systemTask{systemTask} {
}


void TimerController::Init() {
app_timer_create(&timerAppTimer, APP_TIMER_MODE_SINGLE_SHOT, timerEnd);

}

void TimerController::StartTimer(uint32_t duration) {
app_timer_stop(timerAppTimer);
auto currentTicks = xTaskGetTickCount();
app_timer_start(timerAppTimer, APP_TIMER_TICKS(duration), this);
endTicks = currentTicks + APP_TIMER_TICKS(duration);
timerRunning = true;
}

uint32_t TimerController::GetTimeRemaining() {
if (!timerRunning) {
return 0;
}
auto currentTicks = xTaskGetTickCount();

TickType_t deltaTicks = 0;
if (currentTicks > endTicks) {
deltaTicks = 0xffffffff - currentTicks;
deltaTicks += (endTicks + 1);
} else {
deltaTicks = endTicks - currentTicks;
}

return (static_cast<TickType_t>(deltaTicks) / static_cast<TickType_t>(configTICK_RATE_HZ)) * 1000;
}

void TimerController::timerEnd(void* p_context) {

auto* controller = static_cast<Controllers::TimerController*> (p_context);
controller->timerRunning = false;
controller->systemTask.PushMessage(System::SystemTask::Messages::OnTimerDone);
}

void TimerController::StopTimer() {
app_timer_stop(timerAppTimer);
timerRunning = false;
}

bool TimerController::IsRunning() {
return timerRunning;
}
36 changes: 36 additions & 0 deletions src/components/timer/TimerController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include <cstdint>
#include "app_timer.h"
#include "portmacro_cmsis.h"

namespace Pinetime {
namespace System {
class SystemTask;
}
namespace Controllers {

class TimerController {
public:
TimerController(Pinetime::System::SystemTask& systemTask);

void Init();

void StartTimer(uint32_t duration);

void StopTimer();

uint32_t GetTimeRemaining();

bool IsRunning();

private:
System::SystemTask& systemTask;

static void timerEnd(void* p_context);

TickType_t endTicks;
bool timerRunning = false;
};
}
}
1 change: 1 addition & 0 deletions src/displayapp/Apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Pinetime {
FirmwareValidation,
NotificationsPreview,
Notifications,
Timer,
FlashLight,
BatteryInfo,
Music,
Expand Down
18 changes: 16 additions & 2 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <libraries/log/nrf_log.h>
#include <displayapp/screens/HeartRate.h>
#include <displayapp/screens/Motion.h>
#include <displayapp/screens/Timer.h>
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/datetime/DateTimeController.h"
Expand Down Expand Up @@ -55,7 +56,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::MotionController& motionController)
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController)
: lcd {lcd},
lvgl {lvgl},
touchPanel {touchPanel},
Expand All @@ -68,7 +70,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
heartRateController {heartRateController},
settingsController {settingsController},
motorController {motorController},
motionController {motionController} {
motionController {motionController},
timerController {timerController} {
msgQueue = xQueueCreate(queueSize, itemSize);
// Start clock when smartwatch boots
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
Expand Down Expand Up @@ -148,6 +151,14 @@ void DisplayApp::Refresh() {
case Messages::NewNotification:
LoadApp(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
break;
case Messages::TimerDone:
if (currentApp == Apps::Timer) {
auto *timer = dynamic_cast<Screens::Timer*>(currentScreen.get());
timer->setDone();
} else {
LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down);
}
break;
case Messages::TouchEvent: {
if (state != States::Running)
break;
Expand Down Expand Up @@ -264,6 +275,9 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::Timer:
currentScreen = std::make_unique<Screens::Timer>(this, timerController);
break;

// Settings
case Apps::QuickSettings:
Expand Down
5 changes: 4 additions & 1 deletion src/displayapp/DisplayApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "components/firmwarevalidator/FirmwareValidator.h"
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
#include "components/timer/TimerController.h"
#include "Messages.h"

namespace Pinetime {
Expand Down Expand Up @@ -53,7 +54,8 @@ namespace Pinetime {
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::MotionController& motionController);
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController);
void Start();
void PushMessage(Display::Messages msg);

Expand All @@ -76,6 +78,7 @@ namespace Pinetime {
Pinetime::Controllers::Settings& settingsController;
Pinetime::Controllers::MotorController& motorController;
Pinetime::Controllers::MotionController& motionController;
Pinetime::Controllers::TimerController& timerController;

Pinetime::Controllers::FirmwareValidator validator;
Controllers::BrightnessController brightnessController;
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Pinetime {
TouchEvent,
ButtonPushed,
NewNotification,
TimerDone,
BleFirmwareUpdateStarted,
UpdateTimeOut
};
Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/fonts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Do not enable font compression and horizontal subpixel hinting
* Load the file `JetBrainsMono-Bold.tff` and specify the following range : `0x20-0x7f, 0x410-0x44f`
* Add a 2nd font, load the file `FontAwesome5-Solid+Brands+Regular.woff` and specify the following
range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf029, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024`
range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf029, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252`
* Click on Convert, and download the file `jetbrains_mono_bold_20.c` and copy it in `src/DisplayApp/Fonts`

Add new symbols:
Expand Down
36 changes: 22 additions & 14 deletions src/displayapp/fonts/jetbrains_mono_bold_20.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,13 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = {
0x7, 0xe0, 0x0, 0x7, 0xf0, 0x0, 0x3, 0xff,
0xff, 0xff, 0xcf, 0xff, 0xff, 0xe0,

/* U+F252 "" */
0xff, 0xff, 0xff, 0xfd, 0x80, 0x33, 0x80, 0xe7,
0xff, 0xc7, 0xff, 0xf, 0xfe, 0xf, 0xf8, 0xf,
0xe0, 0xf, 0x80, 0x7f, 0xc0, 0xe3, 0x83, 0x83,
0x86, 0x3, 0x1f, 0xff, 0x3f, 0xfe, 0x7f, 0xfd,
0xff, 0xff, 0xff, 0xf8,

/* U+F293 "" */
0x7, 0xe0, 0x3f, 0xe0, 0xfb, 0xe3, 0xf3, 0xe7,
0xe3, 0xdf, 0xd3, 0xf9, 0xb3, 0xf9, 0x4f, 0xf8,
Expand Down Expand Up @@ -1184,17 +1191,18 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 3380, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
{.bitmap_index = 3418, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
{.bitmap_index = 3456, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
{.bitmap_index = 3494, .adv_w = 280, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
{.bitmap_index = 3532, .adv_w = 200, .box_w = 11, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 3561, .adv_w = 280, .box_w = 16, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
{.bitmap_index = 3599, .adv_w = 400, .box_w = 25, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 3665, .adv_w = 360, .box_w = 23, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
{.bitmap_index = 3714, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3764, .adv_w = 400, .box_w = 25, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3824, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 3877, .adv_w = 360, .box_w = 22, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3932, .adv_w = 360, .box_w = 22, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3985, .adv_w = 320, .box_w = 20, .box_h = 15, .ofs_x = 0, .ofs_y = 0}
{.bitmap_index = 3494, .adv_w = 240, .box_w = 15, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3530, .adv_w = 280, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
{.bitmap_index = 3568, .adv_w = 200, .box_w = 11, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 3597, .adv_w = 280, .box_w = 16, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
{.bitmap_index = 3635, .adv_w = 400, .box_w = 25, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 3701, .adv_w = 360, .box_w = 23, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
{.bitmap_index = 3750, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3800, .adv_w = 400, .box_w = 25, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3860, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 3913, .adv_w = 360, .box_w = 22, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 3968, .adv_w = 360, .box_w = 22, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
{.bitmap_index = 4021, .adv_w = 320, .box_w = 20, .box_h = 15, .ofs_x = 0, .ofs_y = 0}
};

/*---------------------
Expand All @@ -1205,8 +1213,8 @@ static const uint16_t unicode_list_2[] = {
0x0, 0x16, 0x23, 0x26, 0x27, 0x28, 0x39, 0x47,
0x4a, 0x4b, 0x4c, 0x50, 0x68, 0x94, 0x128, 0x184,
0x1e5, 0x1fb, 0x21d, 0x23f, 0x240, 0x241, 0x242, 0x243,
0x292, 0x293, 0x2f1, 0x3dc, 0x3fc, 0x45c, 0x54a, 0x55f,
0x59e, 0x59f, 0x6a8
0x251, 0x292, 0x293, 0x2f1, 0x3dc, 0x3fc, 0x45c, 0x54a,
0x55f, 0x59e, 0x59f, 0x6a8
};

/*Collect the unicode lists and glyph_id offsets*/
Expand All @@ -1222,7 +1230,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
},
{
.range_start = 61441, .range_length = 1705, .glyph_id_start = 160,
.unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 35, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
.unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 36, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/screens/ApplicationList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen1() {
{Symbols::map, Apps::Navigation},
{Symbols::shoe, Apps::Steps},
{Symbols::heartBeat, Apps::HeartRate},
{"", Apps::None},
{Symbols::hourGlass, Apps::Timer},
}};

return std::make_unique<Screens::Tile>(0, 2, app, settingsController, batteryController, dateTimeController, applications);
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/Symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Pinetime {
static constexpr const char* pause = "\xEF\x81\x8C";
static constexpr const char* stop = "\xEF\x81\x8D";
static constexpr const char* stopWatch = "\xEF\x8B\xB2";
static constexpr const char* hourGlass = "\xEF\x89\x92";
static constexpr const char* lapsFlag = "\xEF\x80\xA4";

// lv_font_sys_48.c
Expand Down
Loading