Compare commits

...

1 Commits

34 changed files with 469 additions and 61 deletions

View File

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(pinetime VERSION 1.7.1 LANGUAGES C CXX ASM) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project(pinetime VERSION 1.7.99 LANGUAGES C CXX ASM)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)

View File

@ -64,7 +64,7 @@ macro(nRF5x_setup)
set(CPU_FLAGS "-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16") set(CPU_FLAGS "-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040) add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040)
add_definitions(-DFREERTOS) add_definitions(-DFREERTOS)
add_definitions(-DDEBUG_NRF_USER) #add_definitions(-DDEBUG_NRF_USER)
include_directories( include_directories(
"${NRF5_SDK_PATH}/components/drivers_nrf/nrf_soc_nosd" "${NRF5_SDK_PATH}/components/drivers_nrf/nrf_soc_nosd"
) )

View File

@ -291,10 +291,10 @@ set(LVGL_SRC
libs/lvgl/src/lv_font/lv_font_fmt_txt.c libs/lvgl/src/lv_font/lv_font_fmt_txt.c
libs/lvgl/src/lv_font/lv_font_loader.c libs/lvgl/src/lv_font/lv_font_loader.c
# LVGL Fonts # LVGL Fonts
libs/lvgl/src/lv_font/lv_font_montserrat_14.c #libs/lvgl/src/lv_font/lv_font_montserrat_14.c
libs/lvgl/src/lv_font/lv_font_montserrat_18.c #libs/lvgl/src/lv_font/lv_font_montserrat_18.c
libs/lvgl/src/lv_font/lv_font_montserrat_22.c #libs/lvgl/src/lv_font/lv_font_montserrat_22.c
libs/lvgl/src/lv_font/lv_font_montserrat_28.c #libs/lvgl/src/lv_font/lv_font_montserrat_28.c
# #
libs/lvgl/src/lv_hal/lv_hal_disp.c libs/lvgl/src/lv_hal/lv_hal_disp.c
libs/lvgl/src/lv_hal/lv_hal_indev.c libs/lvgl/src/lv_hal/lv_hal_indev.c
@ -485,7 +485,7 @@ list(APPEND SOURCE_FILES
components/ble/MusicService.cpp components/ble/MusicService.cpp
components/ble/weather/WeatherService.cpp components/ble/weather/WeatherService.cpp
components/ble/NavigationService.cpp components/ble/NavigationService.cpp
displayapp/fonts/lv_font_navi_80.c #displayapp/fonts/lv_font_navi_80.c
components/ble/BatteryInformationService.cpp components/ble/BatteryInformationService.cpp
components/ble/FSService.cpp components/ble/FSService.cpp
components/ble/ImmediateAlertService.cpp components/ble/ImmediateAlertService.cpp
@ -504,12 +504,12 @@ list(APPEND SOURCE_FILES
FreeRTOS/port_cmsis.c FreeRTOS/port_cmsis.c
displayapp/LittleVgl.cpp displayapp/LittleVgl.cpp
displayapp/fonts/jetbrains_mono_extrabold_compressed.c #displayapp/fonts/jetbrains_mono_extrabold_compressed.c
displayapp/fonts/jetbrains_mono_bold_20.c displayapp/fonts/jetbrains_mono_bold_20.c
displayapp/fonts/jetbrains_mono_76.c #displayapp/fonts/jetbrains_mono_76.c
displayapp/fonts/jetbrains_mono_42.c #displayapp/fonts/jetbrains_mono_42.c
displayapp/fonts/lv_font_sys_48.c #displayapp/fonts/lv_font_sys_48.c
displayapp/fonts/open_sans_light.c #displayapp/fonts/open_sans_light.c
displayapp/lv_pinetime_theme.c displayapp/lv_pinetime_theme.c
systemtask/SystemTask.cpp systemtask/SystemTask.cpp
@ -523,6 +523,10 @@ list(APPEND SOURCE_FILES
buttonhandler/ButtonHandler.cpp buttonhandler/ButtonHandler.cpp
touchhandler/TouchHandler.cpp touchhandler/TouchHandler.cpp
mcuasan/McuASAN.c
mcuasan/McuASAN.h
mcuasan/McuASANConfig.h
) )
list(APPEND RECOVERY_SOURCE_FILES list(APPEND RECOVERY_SOURCE_FILES
@ -712,6 +716,7 @@ include_directories(
. .
../ ../
libs/ libs/
mcuasan/
FreeRTOS/ FreeRTOS/
libs/date/includes libs/date/includes
libs/mynewt-nimble/porting/npl/freertos/include libs/mynewt-nimble/porting/npl/freertos/include
@ -803,7 +808,7 @@ link_directories(
) )
set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wextra -Warray-bounds=2 -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 -Wformat-nonliteral -ftree-vrp -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-expansion-to-defined -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type -fstack-usage -fno-exceptions -fno-non-call-exceptions) set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wextra -Warray-bounds=2 -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 -Wformat-nonliteral -ftree-vrp -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-expansion-to-defined -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type -fstack-usage -fno-exceptions -fno-non-call-exceptions -static-libasan)
add_definitions(-DCONFIG_GPIO_AS_PINRESET) add_definitions(-DCONFIG_GPIO_AS_PINRESET)
add_definitions(-DNIMBLE_CFG_CONTROLLER) add_definitions(-DNIMBLE_CFG_CONTROLLER)
add_definitions(-DOS_CPUTIME_FREQ) add_definitions(-DOS_CPUTIME_FREQ)
@ -891,7 +896,9 @@ target_compile_options(littlefs PRIVATE
set(EXECUTABLE_NAME "pinetime-app") set(EXECUTABLE_NAME "pinetime-app")
set(EXECUTABLE_FILE_NAME ${EXECUTABLE_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) 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") set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld")
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
add_executable(${EXECUTABLE_NAME} ${INCLUDE_FILES} ${SOURCE_FILES})
#target_compile_definitions(${EXECUTABLE_NAME} PUBLIC "DEBUG_NRF_USER")
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME}) set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME})
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs QCBOR) target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs QCBOR)
target_compile_options(${EXECUTABLE_NAME} PUBLIC target_compile_options(${EXECUTABLE_NAME} PUBLIC
@ -904,7 +911,7 @@ target_compile_options(${EXECUTABLE_NAME} PUBLIC
set_target_properties(${EXECUTABLE_NAME} PROPERTIES set_target_properties(${EXECUTABLE_NAME} PROPERTIES
SUFFIX ".out" SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_FILE_NAME}.map" LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_FILE_NAME}.map -static-libasan -fsanitize=kernel-address"
) )
add_custom_command(TARGET ${EXECUTABLE_NAME} add_custom_command(TARGET ${EXECUTABLE_NAME}

View File

@ -95,7 +95,7 @@
#define configUSE_TIMERS 1 #define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY (0) #define configTIMER_TASK_PRIORITY (0)
#define configTIMER_QUEUE_LENGTH 32 #define configTIMER_QUEUE_LENGTH 32
#define configTIMER_TASK_STACK_DEPTH (300) #define configTIMER_TASK_STACK_DEPTH (200)
/* Tickless Idle configuration. */ /* Tickless Idle configuration. */
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2

View File

@ -77,6 +77,7 @@ void DfuService::Init() {
} }
int DfuService::OnServiceData(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) { int DfuService::OnServiceData(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) {
NRF_LOG_INFO("[DFU] OnServiceData(%d, %d)", connectionHandle, attributeHandle);
if (bleController.IsFirmwareUpdating()) { if (bleController.IsFirmwareUpdating()) {
xTimerStart(timeoutTimer, 0); xTimerStart(timeoutTimer, 0);
} }
@ -107,26 +108,31 @@ int DfuService::OnServiceData(uint16_t connectionHandle, uint16_t attributeHandl
} }
int DfuService::SendDfuRevision(os_mbuf* om) const { int DfuService::SendDfuRevision(os_mbuf* om) const {
NRF_LOG_INFO("[DFU] SendDFURevision");
int res = os_mbuf_append(om, &revision, sizeof(revision)); int res = os_mbuf_append(om, &revision, sizeof(revision));
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
} }
int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) { int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
NRF_LOG_INFO("[DFU] WritePacketHandler(%d)", connectionHandle);
switch (state) { switch (state) {
case States::Start: { case States::Start: {
NRF_LOG_INFO("\tWritePacketHandler -- START");
softdeviceSize = om->om_data[0] + (om->om_data[1] << 8) + (om->om_data[2] << 16) + (om->om_data[3] << 24); softdeviceSize = om->om_data[0] + (om->om_data[1] << 8) + (om->om_data[2] << 16) + (om->om_data[3] << 24);
bootloaderSize = om->om_data[4] + (om->om_data[5] << 8) + (om->om_data[6] << 16) + (om->om_data[7] << 24); bootloaderSize = om->om_data[4] + (om->om_data[5] << 8) + (om->om_data[6] << 16) + (om->om_data[7] << 24);
applicationSize = om->om_data[8] + (om->om_data[9] << 8) + (om->om_data[10] << 16) + (om->om_data[11] << 24); applicationSize = om->om_data[8] + (om->om_data[9] << 8) + (om->om_data[10] << 16) + (om->om_data[11] << 24);
bleController.FirmwareUpdateTotalBytes(applicationSize); bleController.FirmwareUpdateTotalBytes(applicationSize);
NRF_LOG_INFO( NRF_LOG_INFO("[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", softdeviceSize, bootloaderSize, applicationSize);
"[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", softdeviceSize, bootloaderSize, applicationSize);
// wait until SystemTask has finished waking up all devices // wait until SystemTask has finished waking up all devices
NRF_LOG_INFO("\tWritePacketHandler -- START - -wait sleep");
while (systemTask.IsSleeping()) { while (systemTask.IsSleeping()) {
vTaskDelay(50); // 50ms vTaskDelay(50); // 50ms
} }
NRF_LOG_INFO("\tWritePacketHandler -- START - Erase");
dfuImage.Erase(); dfuImage.Erase();
NRF_LOG_INFO("\tWritePacketHandler -- START - Erase done");
uint8_t data[] {16, 1, 1}; uint8_t data[] {16, 1, 1};
notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 3); notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 3);
@ -134,6 +140,7 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
} }
return 0; return 0;
case States::Init: { case States::Init: {
NRF_LOG_INFO("\tWritePacketHandler -- INIT");
uint16_t deviceType = om->om_data[0] + (om->om_data[1] << 8); uint16_t deviceType = om->om_data[0] + (om->om_data[1] << 8);
uint16_t deviceRevision = om->om_data[2] + (om->om_data[3] << 8); uint16_t deviceRevision = om->om_data[2] + (om->om_data[3] << 8);
uint32_t applicationVersion = om->om_data[4] + (om->om_data[5] << 8) + (om->om_data[6] << 16) + (om->om_data[7] << 24); uint32_t applicationVersion = om->om_data[4] + (om->om_data[5] << 8) + (om->om_data[6] << 16) + (om->om_data[7] << 24);
@ -157,6 +164,7 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
} }
case States::Data: { case States::Data: {
NRF_LOG_INFO("\tWritePacketHandler -- DATA");
nbPacketReceived++; nbPacketReceived++;
dfuImage.Append(om->om_data, om->om_len); dfuImage.Append(om->om_data, om->om_len);
bytesReceived += om->om_len; bytesReceived += om->om_len;
@ -189,11 +197,13 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
} }
int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
NRF_LOG_INFO("[DFU] ControlPointHandler(%d)", connectionHandle);
auto opcode = static_cast<Opcodes>(om->om_data[0]); auto opcode = static_cast<Opcodes>(om->om_data[0]);
NRF_LOG_INFO("[DFU] -> ControlPointHandler"); NRF_LOG_INFO("[DFU] -> ControlPointHandler");
switch (opcode) { switch (opcode) {
case Opcodes::StartDFU: { case Opcodes::StartDFU: {
NRF_LOG_INFO("\tControlPointHandler -- StartDFU");
if (state != States::Idle && state != States::Start) { if (state != States::Idle && state != States::Start) {
NRF_LOG_INFO("[DFU] -> Start DFU requested, but we are not in Idle state"); NRF_LOG_INFO("[DFU] -> Start DFU requested, but we are not in Idle state");
return 0; return 0;
@ -218,6 +228,8 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
} }
} break; } break;
case Opcodes::InitDFUParameters: { case Opcodes::InitDFUParameters: {
NRF_LOG_INFO("\tControlPointHandler -- InitDFUParameters");
if (state != States::Init) { if (state != States::Init) {
NRF_LOG_INFO("[DFU] -> Init DFU requested, but we are not in Init state"); NRF_LOG_INFO("[DFU] -> Init DFU requested, but we are not in Init state");
return 0; return 0;
@ -235,6 +247,8 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
} }
return 0; return 0;
case Opcodes::PacketReceiptNotificationRequest: case Opcodes::PacketReceiptNotificationRequest:
NRF_LOG_INFO("\tControlPointHandler -- PacketReceiptNotificationRequest");
nbPacketsToNotify = om->om_data[1]; nbPacketsToNotify = om->om_data[1];
NRF_LOG_INFO("[DFU] -> Receive Packet Notification Request, nb packet = %d", nbPacketsToNotify); NRF_LOG_INFO("[DFU] -> Receive Packet Notification Request, nb packet = %d", nbPacketsToNotify);
return 0; return 0;
@ -249,6 +263,8 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
state = States::Data; state = States::Data;
return 0; return 0;
case Opcodes::ValidateFirmware: { case Opcodes::ValidateFirmware: {
NRF_LOG_INFO("\tControlPointHandler -- ValidateFirmware");
if (state != States::Validate) { if (state != States::Validate) {
NRF_LOG_INFO("[DFU] -> Validate firmware image requested, but we are not in Data state %d", state); NRF_LOG_INFO("[DFU] -> Validate firmware image requested, but we are not in Data state %d", state);
return 0; return 0;
@ -279,6 +295,8 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
return 0; return 0;
} }
case Opcodes::ActivateImageAndReset: case Opcodes::ActivateImageAndReset:
NRF_LOG_INFO("\tControlPointHandler -- ActivateImageAndReset");
if (state != States::Validated) { if (state != States::Validated) {
NRF_LOG_INFO("[DFU] -> Activate image and reset requested, but we are not in Validated state"); NRF_LOG_INFO("[DFU] -> Activate image and reset requested, but we are not in Validated state");
return 0; return 0;
@ -293,6 +311,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
} }
void DfuService::OnTimeout() { void DfuService::OnTimeout() {
NRF_LOG_INFO("[DFU] OnTimeout()");
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error);
Reset(); Reset();
} }

View File

@ -110,15 +110,28 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
} }
void MotionService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { void MotionService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
if(attributeHandle == stepCountHandle) /*
if(attributeHandle == stepCountHandle) {
stepCountNoficationEnabled = true; stepCountNoficationEnabled = true;
else if(attributeHandle == motionValuesHandle) NRF_LOG_INFO("ENABLE STEP NOTIFICATION");
}
else if(attributeHandle == motionValuesHandle) {
motionValuesNoficationEnabled = true; motionValuesNoficationEnabled = true;
NRF_LOG_INFO("ENABLE MOTION NOTIFICATION");
}
*/
} }
void MotionService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { void MotionService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
if(attributeHandle == stepCountHandle) /*
if(attributeHandle == stepCountHandle) {
stepCountNoficationEnabled = false; stepCountNoficationEnabled = false;
else if(attributeHandle == motionValuesHandle) NRF_LOG_INFO("DISABLE STEP NOTIFICATION");
}
else if(attributeHandle == motionValuesHandle) {
NRF_LOG_INFO("DISABLE MOTION NOTIFICATION");
motionValuesNoficationEnabled = false; motionValuesNoficationEnabled = false;
}
*/
} }

View File

@ -182,8 +182,8 @@ void NimbleController::StartAdvertising() {
int NimbleController::OnGAPEvent(ble_gap_event* event) { int NimbleController::OnGAPEvent(ble_gap_event* event) {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_ADV_COMPLETE: case BLE_GAP_EVENT_ADV_COMPLETE:
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE"); //NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE");
NRF_LOG_INFO("reason=%d; status=%0X", event->adv_complete.reason, event->connect.status); //NRF_LOG_INFO("reason=%d; status=%0X", event->adv_complete.reason, event->connect.status);
StartAdvertising(); StartAdvertising();
break; break;

View File

@ -34,7 +34,7 @@ void LittleVgl::Init() {
} }
void LittleVgl::InitDisplay() { void LittleVgl::InitDisplay() {
lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 4); /*Initialize the display buffer*/ lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 2); /*Initialize the display buffer*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/ lv_disp_drv_init(&disp_drv); /*Basic initialization*/
/*Set up the functions to access to your display*/ /*Set up the functions to access to your display*/

View File

@ -35,8 +35,8 @@ namespace Pinetime {
Pinetime::Drivers::Cst816S& touchPanel; Pinetime::Drivers::Cst816S& touchPanel;
lv_disp_buf_t disp_buf_2; lv_disp_buf_t disp_buf_2;
lv_color_t buf2_1[LV_HOR_RES_MAX * 4]; lv_color_t buf2_1[LV_HOR_RES_MAX * 2];
lv_color_t buf2_2[LV_HOR_RES_MAX * 4]; lv_color_t buf2_2[LV_HOR_RES_MAX * 2];
lv_disp_drv_t disp_drv; lv_disp_drv_t disp_drv;
lv_point_t previousClick; lv_point_t previousClick;

View File

@ -31,7 +31,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
: Screen(app), running {true}, alarmController {alarmController} { : Screen(app), running {true}, alarmController {alarmController} {
time = lv_label_create(lv_scr_act(), nullptr); time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); //lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
alarmHours = alarmController.Hours(); alarmHours = alarmController.Hours();

View File

@ -27,7 +27,7 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
percent = lv_label_create(lv_scr_act(), nullptr); percent = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); //lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); lv_label_set_text_fmt(percent, "%02i%%", batteryPercent);
lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT); lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT);
lv_obj_align(percent, nullptr, LV_ALIGN_CENTER, 0, -60); lv_obj_align(percent, nullptr, LV_ALIGN_CENTER, 0, -60);

View File

@ -24,7 +24,7 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
brightnessLevel = brightnessController.Level(); brightnessLevel = brightnessController.Level();
flashLight = lv_label_create(lv_scr_act(), nullptr); flashLight = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); //lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
lv_label_set_text_static(flashLight, Symbols::highlight); lv_label_set_text_static(flashLight, Symbols::highlight);
lv_obj_align(flashLight, nullptr, LV_ALIGN_CENTER, 0, 0); lv_obj_align(flashLight, nullptr, LV_ALIGN_CENTER, 0, 0);

View File

@ -34,7 +34,7 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
bool isHrRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; bool isHrRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
label_hr = lv_label_create(lv_scr_act(), nullptr); label_hr = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); //lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
if (isHrRunning) if (isHrRunning)
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);

View File

@ -34,8 +34,8 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
lv_arc_set_adjustable(bpmArc, true); lv_arc_set_adjustable(bpmArc, true);
lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0); lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
bpmValue = createLabel("120", bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55); //bpmValue = createLabel("120", bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55);
createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0); //createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0);
bpmTap = lv_btn_create(lv_scr_act(), nullptr); bpmTap = lv_btn_create(lv_scr_act(), nullptr);
bpmTap->user_data = this; bpmTap->user_data = this;

View File

@ -132,7 +132,7 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
: Screen(app), navService(nav) { : Screen(app), navService(nav) {
imgFlag = lv_label_create(lv_scr_act(), nullptr); imgFlag = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_navi_80); //lv_obj_set_style_local_text_font(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_navi_80);
lv_obj_set_style_local_text_color(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); lv_obj_set_style_local_text_color(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
lv_label_set_text(imgFlag, iconForName("flag")); lv_label_set_text(imgFlag, iconForName("flag"));
lv_obj_align(imgFlag, nullptr, LV_ALIGN_CENTER, 0, -60); lv_obj_align(imgFlag, nullptr, LV_ALIGN_CENTER, 0, -60);

View File

@ -16,7 +16,7 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li
lv_obj_set_style_local_border_width(background, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 1); lv_obj_set_style_local_border_width(background, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 1);
points = lv_label_create(lv_scr_act(), nullptr); points = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(points, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); //lv_obj_set_style_local_text_font(points, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text(points, "0000"); lv_label_set_text(points, "0000");
lv_obj_align(points, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 10); lv_obj_align(points, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 10);

View File

@ -6,7 +6,7 @@ using namespace Pinetime::Applications::Screens;
PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen(app) { PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen(app) {
passkeyLabel = lv_label_create(lv_scr_act(), nullptr); passkeyLabel = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00)); lv_obj_set_style_local_text_color(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00));
lv_obj_set_style_local_text_font(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); //lv_obj_set_style_local_text_font(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(passkeyLabel, "%06u", key); lv_label_set_text_fmt(passkeyLabel, "%06u", key);
lv_obj_align(passkeyLabel, nullptr, LV_ALIGN_CENTER, 0, -20); lv_obj_align(passkeyLabel, nullptr, LV_ALIGN_CENTER, 0, -20);

View File

@ -71,13 +71,13 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
// Display the time // Display the time
timeDD1 = lv_label_create(lv_scr_act(), nullptr); timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); //lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD1, "00"); lv_label_set_text(timeDD1, "00");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr); timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); //lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD2, "00"); lv_label_set_text(timeDD2, "00");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);

View File

@ -27,7 +27,7 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lSteps = lv_label_create(lv_scr_act(), nullptr); lSteps = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); //lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(lSteps, "%li", stepsCount); lv_label_set_text_fmt(lSteps, "%li", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);

View File

@ -56,7 +56,7 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
lapNr {} { lapNr {} {
time = lv_label_create(lv_scr_act(), nullptr); time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); //lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_label_set_text(time, "00:00"); lv_label_set_text(time, "00:00");
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -45); lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -45);

View File

@ -53,7 +53,7 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
: Screen(app), running {true}, timerController {timerController} { : Screen(app), running {true}, timerController {timerController} {
time = lv_label_create(lv_scr_act(), nullptr); time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); //lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
uint32_t seconds = timerController.GetTimeRemaining() / 1000; uint32_t seconds = timerController.GetTimeRemaining() / 1000;

View File

@ -58,7 +58,7 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); 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); label_time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed); //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); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);

View File

@ -61,7 +61,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_align(btn1, nullptr, LV_ALIGN_IN_TOP_LEFT, buttonXOffset, barHeight); lv_obj_align(btn1, nullptr, LV_ALIGN_IN_TOP_LEFT, buttonXOffset, barHeight);
btn1_lvl = lv_label_create(btn1, nullptr); btn1_lvl = lv_label_create(btn1, nullptr);
lv_obj_set_style_local_text_font(btn1_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); //lv_obj_set_style_local_text_font(btn1_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
lv_label_set_text_static(btn1_lvl, brightness.GetIcon()); lv_label_set_text_static(btn1_lvl, brightness.GetIcon());
btn2 = lv_btn_create(lv_scr_act(), nullptr); btn2 = lv_btn_create(lv_scr_act(), nullptr);
@ -73,7 +73,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_t* lbl_btn; lv_obj_t* lbl_btn;
lbl_btn = lv_label_create(btn2, nullptr); lbl_btn = lv_label_create(btn2, nullptr);
lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); //lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
lv_label_set_text_static(lbl_btn, Symbols::highlight); lv_label_set_text_static(lbl_btn, Symbols::highlight);
btn3 = lv_btn_create(lv_scr_act(), nullptr); btn3 = lv_btn_create(lv_scr_act(), nullptr);
@ -86,7 +86,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_align(btn3, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, buttonXOffset, 0); lv_obj_align(btn3, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, buttonXOffset, 0);
btn3_lvl = lv_label_create(btn3, nullptr); btn3_lvl = lv_label_create(btn3, nullptr);
lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); //lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) { if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) {
lv_obj_add_state(btn3, LV_STATE_CHECKED); lv_obj_add_state(btn3, LV_STATE_CHECKED);
@ -103,7 +103,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_align(btn4, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, - buttonXOffset, 0); lv_obj_align(btn4, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, - buttonXOffset, 0);
lbl_btn = lv_label_create(btn4, nullptr); lbl_btn = lv_label_create(btn4, nullptr);
lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); //lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
lv_label_set_text_static(lbl_btn, Symbols::settings); lv_label_set_text_static(lbl_btn, Symbols::settings);
lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);

View File

@ -24,13 +24,13 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a
// Display the time // Display the time
timeDD1 = lv_label_create(lv_scr_act(), nullptr); timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); //lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD1, "12"); lv_label_set_text(timeDD1, "12");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr); timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); //lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD2, "34"); lv_label_set_text(timeDD2, "34");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);

View File

@ -39,34 +39,34 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime
hoursValue = static_cast<int>(dateTimeController.Hours()); hoursValue = static_cast<int>(dateTimeController.Hours());
lblHours = lv_label_create(lv_scr_act(), nullptr); lblHours = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblHours, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); //lv_obj_set_style_local_text_font(lblHours, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(lblHours, "%02d", hoursValue); lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
lv_label_set_align(lblHours, LV_LABEL_ALIGN_CENTER); lv_label_set_align(lblHours, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblHours, lv_scr_act(), LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT); lv_obj_align(lblHours, lv_scr_act(), LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT);
lv_obj_set_auto_realign(lblHours, true); lv_obj_set_auto_realign(lblHours, true);
lv_obj_t * lblColon1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_t * lblColon1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); //lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblColon1, ":"); lv_label_set_text_static(lblColon1, ":");
lv_label_set_align(lblColon1, LV_LABEL_ALIGN_CENTER); lv_label_set_align(lblColon1, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblColon1, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_HOURS + POS_X_MINUTES) / 2, POS_Y_TEXT + OFS_Y_COLON); lv_obj_align(lblColon1, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_HOURS + POS_X_MINUTES) / 2, POS_Y_TEXT + OFS_Y_COLON);
minutesValue = static_cast<int>(dateTimeController.Minutes()); minutesValue = static_cast<int>(dateTimeController.Minutes());
lblMinutes = lv_label_create(lv_scr_act(), nullptr); lblMinutes = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); // lv_obj_set_style_local_text_font(lblMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue); lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
lv_label_set_align(lblMinutes, LV_LABEL_ALIGN_CENTER); lv_label_set_align(lblMinutes, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblMinutes, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT); lv_obj_align(lblMinutes, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT);
lv_obj_set_auto_realign(lblMinutes, true); lv_obj_set_auto_realign(lblMinutes, true);
lv_obj_t * lblColon2 = lv_label_create(lv_scr_act(), nullptr); lv_obj_t * lblColon2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); // lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblColon2, ":"); lv_label_set_text_static(lblColon2, ":");
lv_label_set_align(lblColon2, LV_LABEL_ALIGN_CENTER); lv_label_set_align(lblColon2, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblColon2, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON); lv_obj_align(lblColon2, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON);
lv_obj_t * lblSeconds = lv_label_create(lv_scr_act(), nullptr); lv_obj_t * lblSeconds = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); //lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblSeconds, "00"); lv_label_set_text_static(lblSeconds, "00");
lv_label_set_align(lblSeconds, LV_LABEL_ALIGN_CENTER); lv_label_set_align(lblSeconds, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblSeconds, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT); lv_obj_align(lblSeconds, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT);

View File

@ -43,7 +43,7 @@ SettingSteps::SettingSteps(
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
stepValue = lv_label_create(lv_scr_act(), nullptr); stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); //v_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal());
lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER);
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);

View File

@ -13,8 +13,8 @@ void HeartRateTask::Start() {
messageQueue = xQueueCreate(10, 1); messageQueue = xQueueCreate(10, 1);
controller.SetHeartRateTask(this); controller.SetHeartRateTask(this);
if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle)) //if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); // APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
} }
void HeartRateTask::Process(void* instance) { void HeartRateTask::Process(void* instance) {

View File

@ -74,7 +74,7 @@ typedef int16_t lv_coord_t;
#define LV_MEM_CUSTOM 0 #define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
/* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ /* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (14U * 1024U) #define LV_MEM_SIZE (8U * 1024U)
/* Complier prefix for a big array declaration */ /* Complier prefix for a big array declaration */
#define LV_MEM_ATTR #define LV_MEM_ATTR

View File

@ -57,6 +57,10 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger; Pinetime::Logging::DummyLogger logger;
#endif #endif
extern "C" {
#include "McuASAN.h"
}
static constexpr uint8_t touchPanelTwiAddress = 0x15; static constexpr uint8_t touchPanelTwiAddress = 0x15;
static constexpr uint8_t motionSensorTwiAddress = 0x18; static constexpr uint8_t motionSensorTwiAddress = 0x18;
static constexpr uint8_t heartRateSensorTwiAddress = 0x44; static constexpr uint8_t heartRateSensorTwiAddress = 0x44;
@ -301,6 +305,9 @@ void nimble_port_ll_task_func(void* args) {
int main(void) { int main(void) {
logger.Init(); logger.Init();
McuASAN_Init();
auto* toto = malloc(9);
nrf_drv_clock_init(); nrf_drv_clock_init();

278
src/mcuasan/McuASAN.c Normal file
View File

@ -0,0 +1,278 @@
/*
* Copyright (c) 2021, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "./McuASANConfig.h"
#if McuASAN_CONFIG_IS_ENABLED
#include "McuASAN.h"
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <nrf_log.h>
#ifdef __cplusplus
extern "C" {
#endif
#if 1
/* hooks if using -fsanitize=address */
/* -fasan-shadow-offset=number */
/* -fsanitize=kernel-address */
static void __asan_ReportGenericError(void) {
#if 0
NRF_LOG_INFO("ASAN generic failure");
#else
__asm volatile("bkpt #0"); /* stop application */
for (;;) {
}
#endif
}
/* below are the required callbacks needed by ASAN */
void __asan_report_store1(void* address) {
__asan_ReportGenericError();
}
void __asan_report_store2(void* address) {
__asan_ReportGenericError();
}
void __asan_report_store4(void* address) {
__asan_ReportGenericError();
}
void __asan_report_store_n(void* address) {
__asan_ReportGenericError();
}
void __asan_report_load1(void* address) {
__asan_ReportGenericError();
}
void __asan_report_load2(void* address) {
__asan_ReportGenericError();
}
void __asan_report_load4(void* address) {
__asan_ReportGenericError();
}
void __asan_report_load_n(void* address) {
__asan_ReportGenericError();
}
#endif
#if 1
static void NYI(void) {
__asm volatile("bkpt #0"); /* stop application */
for (;;) {
}
}
void __asan_stack_malloc_1(size_t size, void* addr) {
NYI();
}
void __asan_stack_malloc_2(size_t size, void* addr) {
NYI();
}
void __asan_stack_malloc_3(size_t size, void* addr) {
NYI();
}
void __asan_stack_malloc_4(size_t size, void* addr) {
NYI();
}
void __asan_handle_no_return(void) {
NYI();
}
void __asan_option_detect_stack_use_after_return(void) {
NYI();
}
void __asan_register_globals(void) {
NYI();
}
void __asan_unregister_globals(void) {
NYI();
}
void __asan_version_mismatch_check_v8(void) {
NYI();
}
#endif
/* see https://github.com/gcc-mirror/gcc/blob/master/libsanitizer/asan/asan_interface_internal.h */
static uint8_t shadow[McuASAN_CONFIG_APP_MEM_SIZE /
8]; /* one shadow byte for 8 application memory bytes. A 1 means that the memory address is poisoned */
#if McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE > 0
static void* freeQuarantineList[McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE];
/*!< list of free'd blocks in quarantine */
static int freeQuarantineListIdx; /* index in list (ring buffer), points to free element in list */
#endif
typedef enum {
kIsWrite, /* write access */
kIsRead, /* read access */
} rw_mode_e;
static uint8_t* MemToShadow(void* address) {
address -= McuASAN_CONFIG_APP_MEM_START;
return shadow + (((uint32_t) address) >> 3); /* divided by 8: every byte has a shadow bit */
}
static void PoisonShadowByte1Addr(void* addr) {
if (addr >= (void*) McuASAN_CONFIG_APP_MEM_START && addr < (void*) (McuASAN_CONFIG_APP_MEM_START + McuASAN_CONFIG_APP_MEM_SIZE)) {
*MemToShadow(addr) |= 1 << ((uint32_t) addr & 7); /* mark memory in shadow as poisoned with shadow bit */
}
}
static void ClearShadowByte1Addr(void* addr) {
if (addr >= (void*) McuASAN_CONFIG_APP_MEM_START && addr < (void*) (McuASAN_CONFIG_APP_MEM_START + McuASAN_CONFIG_APP_MEM_SIZE)) {
*MemToShadow(addr) &= ~(1 << ((uint32_t) addr & 7)); /* clear shadow bit: it is a valid memory */
}
}
static bool SlowPathCheck(int8_t shadow_value, void* address, size_t kAccessSize) {
/* return true if access to address is poisoned */
int8_t last_accessed_byte = (((uint32_t) address) & 7) + kAccessSize - 1;
return (last_accessed_byte >= shadow_value);
}
static void ReportError(void* address, size_t kAccessSize, rw_mode_e mode) {
// NRF_LOG_INFO("ASAN ptr failure: addr 0x%x, %s, size: %d", address, mode==kIsRead?"read":"write", kAccessSize);
__asm volatile("bkpt #0"); /* stop application if debugger is attached */
}
static void CheckShadow(void* address, size_t kAccessSize, rw_mode_e mode) {
int8_t* shadow_address;
int8_t shadow_value;
if (address >= (void*) McuASAN_CONFIG_APP_MEM_START && address < (void*) (McuASAN_CONFIG_APP_MEM_START + McuASAN_CONFIG_APP_MEM_SIZE)) {
shadow_address = (int8_t*) MemToShadow(address);
shadow_value = *shadow_address;
if (shadow_value == -1) {
ReportError(address, kAccessSize, mode);
} else if (shadow_value != 0) { /* fast check: poisoned! */
if (SlowPathCheck(shadow_value, address, kAccessSize)) {
ReportError(address, kAccessSize, mode);
}
}
}
}
void __asan_load4_noabort(void* address) {
CheckShadow(address, 4, kIsRead); /* check if we are reading from poisoned memory */
}
void __asan_store4_noabort(void* address) {
CheckShadow(address, 4, kIsWrite); /* check if we are writing to poisoned memory */
}
void __asan_load2_noabort(void* address) {
CheckShadow(address, 2, kIsRead); /* check if we are reading from poisoned memory */
}
void __asan_store2_noabort(void* address) {
CheckShadow(address, 2, kIsWrite); /* check if we are writing to poisoned memory */
}
void __asan_load1_noabort(void* address) {
CheckShadow(address, 1, kIsRead); /* check if we are reading from poisoned memory */
}
void __asan_store1_noabort(void* address) {
CheckShadow(address, 1, kIsWrite); /* check if we are writing to poisoned memory */
}
#if McuASAN_CONFIG_CHECK_MALLOC_FREE
/* undo possible defines for malloc and free */
#ifdef malloc
#undef malloc
void* malloc(size_t);
#endif
#ifdef free
#undef free
void free(void*);
#endif
/*
* rrrrrrrr red zone border (incl. size below)
* size
* memory returned
* rrrrrrrr red zone boarder
*/
void* __asan_malloc(size_t size) {
NRF_LOG_INFO("[ASAN] malloc()");
/* malloc allocates the requested amount of memory with redzones around it.
* The shadow values corresponding to the redzones are poisoned and the shadow values
* for the memory region are cleared.
*/
void* p = malloc(size + 2 * McuASAN_CONFIG_MALLOC_RED_ZONE_BORDER); /* add size_t for the size of the block */
void* q;
q = p;
/* poison red zone at the beginning */
for (int i = 0; i < McuASAN_CONFIG_MALLOC_RED_ZONE_BORDER; i++) {
PoisonShadowByte1Addr(q);
q++;
}
*((size_t*) (q - sizeof(size_t))) = size; /* store memory size, needed for the free() part */
/* clear valid memory */
for (int i = 0; i < size; i++) {
ClearShadowByte1Addr(q);
q++;
}
/* poison red zone at the end */
for (int i = 0; i < McuASAN_CONFIG_MALLOC_RED_ZONE_BORDER; i++) {
PoisonShadowByte1Addr(q);
q++;
}
return p + McuASAN_CONFIG_MALLOC_RED_ZONE_BORDER; /* return pointer to valid memory */
}
#endif
#if McuASAN_CONFIG_CHECK_MALLOC_FREE
void __asan_free(void* p) {
NRF_LOG_INFO("[ASAN] Free()");
/* Poisons shadow values for the entire region and put the chunk of memory into a quarantine queue
* (such that this chunk will not be returned again by malloc during some period of time).
*/
size_t size = *((size_t*) (p - sizeof(size_t))); /* get size */
void* q = p;
for (int i = 0; i < size; i++) {
PoisonShadowByte1Addr(q);
q++;
}
q = p - McuASAN_CONFIG_MALLOC_RED_ZONE_BORDER; /* calculate beginning of malloc()ed block */
#if McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE > 0
/* put the memory block into quarantine */
freeQuarantineList[freeQuarantineListIdx] = q;
freeQuarantineListIdx++;
if (freeQuarantineListIdx >= McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE) {
freeQuarantineListIdx = 0;
}
if (freeQuarantineList[freeQuarantineListIdx] != NULL) {
free(freeQuarantineList[freeQuarantineListIdx]);
freeQuarantineList[freeQuarantineListIdx] = NULL;
}
#else
free(q); /* free block */
#endif
}
#endif /* McuASAN_CONFIG_CHECK_MALLOC_FREE */
void McuASAN_Init(void) {
NRF_LOG_INFO("[ASAN] Init()");
for (int i = 0; i < sizeof(shadow); i++) { /* initialize full shadow map */
shadow[i] = -1; /* poison everything */
}
/* because the shadow is part of the memory area: poison the shadow */
for (int i = 0; i < sizeof(shadow); i += 8) {
PoisonShadowByte1Addr(&shadow[i]);
}
#if McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE > 0
for (int i = 0; i < McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE; i++) {
freeQuarantineList[i] = NULL;
}
freeQuarantineListIdx = 0;
#endif
}
#ifdef __cplusplus
}
#endif
#endif /* McuASAN_CONFIG_IS_ENABLED */

38
src/mcuasan/McuASAN.h Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2021, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MCUASAN_H_
#define MCUASAN_H_
#include <stddef.h>
#include "McuASANConfig.h"
#if McuASAN_CONFIG_IS_ENABLED && McuASAN_CONFIG_CHECK_MALLOC_FREE
/* replace malloc and free calls */
#define malloc __asan_malloc
#define free __asan_free
#endif
/*! \brief
* Allocate a memory block
*/
void *__asan_malloc(size_t size);
/*!
* \brief
* Free a memory block
*/
void __asan_free(void *p);
/*! \brief
* Call the init function first to initialize the module.
*/
void McuASAN_Init(void);
#endif /* MCUASAN_H_ */

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2021, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MCUASANCONFIG_H_
#define MCUASANCONFIG_H_
#ifndef McuASAN_CONFIG_IS_ENABLED
#define McuASAN_CONFIG_IS_ENABLED (1)
/*!< 1: ASAN is enabled; 0: ASAN is disabled */
#endif
#ifndef McuASAN_CONFIG_CHECK_MALLOC_FREE
#define McuASAN_CONFIG_CHECK_MALLOC_FREE (1)
/*!< 1: check malloc() and free() */
#endif
#ifndef McuASAN_CONFIG_APP_MEM_START
#define McuASAN_CONFIG_APP_MEM_START 0x20000000
/*!< base RAM address */
#endif
#ifndef McuASAN_CONFIG_APP_MEM_SIZE
#define McuASAN_CONFIG_APP_MEM_SIZE (64*1024)
/*!< Memory size in bytes */
#endif
#if McuASAN_CONFIG_CHECK_MALLOC_FREE
#ifndef McuASAN_CONFIG_MALLOC_RED_ZONE_BORDER
#define McuASAN_CONFIG_MALLOC_RED_ZONE_BORDER (8)
/*!< red zone border in bytes around memory blocks. Must be larger than sizeof(size_t)! */
#endif
#ifndef McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE
#define McuASAN_CONFIG_FREE_QUARANTINE_LIST_SIZE (8)
/*!< list of free blocks in quarantine until they are released. Use 0 for no list. */
#endif
#endif /* McuASAN_CONFIG_CHECK_MALLOC_FREE */
#endif /* MCUASANCONFIG_H_ */

View File

@ -8120,15 +8120,15 @@
// <e> NRF_LOG_ENABLED - nrf_log - Logger // <e> NRF_LOG_ENABLED - nrf_log - Logger
//========================================================== //==========================================================
#ifndef NRF_LOG_ENABLED #ifndef NRF_LOG_ENABLED
#define NRF_LOG_ENABLED 0 #define NRF_LOG_ENABLED 1
#endif #endif
#ifndef NRF_LOG_BACKEND_RTT_ENABLED #ifndef NRF_LOG_BACKEND_RTT_ENABLED
#define NRF_LOG_BACKEND_RTT_ENABLED 0 #define NRF_LOG_BACKEND_RTT_ENABLED 1
#endif #endif
#ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT #ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0 #define NRF_LOG_BACKEND_SERIAL_USES_RTT 1
#endif #endif
// <h> Log message pool - Configuration of log message pool // <h> Log message pool - Configuration of log message pool

View File

@ -465,7 +465,7 @@ void SystemTask::UpdateMotion() {
motionSensor.ResetStepCounter(); motionSensor.ResetStepCounter();
stepCounterMustBeReset = false; stepCounterMustBeReset = false;
} }
/*
auto motionValues = motionSensor.Process(); auto motionValues = motionSensor.Process();
motionController.IsSensorOk(motionSensor.IsOk()); motionController.IsSensorOk(motionSensor.IsOk());
@ -473,6 +473,7 @@ void SystemTask::UpdateMotion() {
if (motionController.ShouldWakeUp(isSleeping)) { if (motionController.ShouldWakeUp(isSleeping)) {
GoToRunning(); GoToRunning();
} }
*/
} }
void SystemTask::HandleButtonAction(Controllers::ButtonActions action) { void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {