Merge branch 'removeWarnings' of JF/PineTime into develop

This commit is contained in:
JF 2020-08-19 16:04:05 +02:00 committed by Gitea
commit 9906a708c9
27 changed files with 98 additions and 231 deletions

View File

@ -1,25 +0,0 @@
#include "BlinkApp.h"
#include <FreeRTOS.h>
#include <task.h>
#include <libraries/log/nrf_log.h>
#include <boards.h>
using namespace Pinetime::Applications;
void BlinkApp::Start() {
if (pdPASS != xTaskCreate(BlinkApp::Process, "BlinkApp", 256, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
void BlinkApp::Process(void *instance) {
auto* app = static_cast<BlinkApp*>(instance);
NRF_LOG_INFO("BlinkApp task started!");
while (1) {
// NRF_LOG_INFO("BlinkApp task running!");
// nrf_gpio_pin_toggle(22);
// nrf_gpio_pin_toggle(23);
// nrf_gpio_pin_toggle(14);
vTaskDelay(1000);
}
}

View File

@ -1,15 +0,0 @@
#pragma once
#include <FreeRTOS.h>
#include <task.h>
namespace Pinetime {
namespace Applications {
class BlinkApp {
public:
void Start();
private:
TaskHandle_t taskHandle;
static void Process(void* instance);
};
}
}

View File

@ -321,11 +321,9 @@ list(APPEND IMAGE_FILES
list(APPEND SOURCE_FILES list(APPEND SOURCE_FILES
Logging/NrfLogger.cpp Logging/NrfLogger.cpp
BlinkApp/BlinkApp.cpp
DisplayApp/DisplayApp.cpp DisplayApp/DisplayApp.cpp
DisplayApp/Screens/Screen.cpp DisplayApp/Screens/Screen.cpp
DisplayApp/Screens/Clock.cpp DisplayApp/Screens/Clock.cpp
DisplayApp/Screens/Message.cpp
DisplayApp/Screens/Tile.cpp DisplayApp/Screens/Tile.cpp
DisplayApp/Screens/Meter.cpp DisplayApp/Screens/Meter.cpp
DisplayApp/Screens/Gauge.cpp DisplayApp/Screens/Gauge.cpp
@ -365,11 +363,6 @@ list(APPEND SOURCE_FILES
FreeRTOS/port.c FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis_systick.c
FreeRTOS/port_cmsis.c FreeRTOS/port_cmsis.c
${TINYCRYPT_SRC}
${NIMBLE_SRC}
${LVGL_SRC}
#${IMAGE_FILES}
${SDK_SOURCE_FILES}
DisplayApp/LittleVgl.cpp DisplayApp/LittleVgl.cpp
DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c
@ -380,8 +373,6 @@ list(APPEND SOURCE_FILES
) )
list(APPEND GRAPHICS_SOURCE_FILES list(APPEND GRAPHICS_SOURCE_FILES
${SDK_SOURCE_FILES}
# FreeRTOS # FreeRTOS
FreeRTOS/port.c FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis_systick.c
@ -402,12 +393,10 @@ list(APPEND GRAPHICS_SOURCE_FILES
set(INCLUDE_FILES set(INCLUDE_FILES
Logging/Logger.h Logging/Logger.h
Logging/NrfLogger.h Logging/NrfLogger.h
BlinkApp/BlinkApp.h
DisplayApp/DisplayApp.h DisplayApp/DisplayApp.h
DisplayApp/TouchEvents.h DisplayApp/TouchEvents.h
DisplayApp/Screens/Screen.h DisplayApp/Screens/Screen.h
DisplayApp/Screens/Clock.h DisplayApp/Screens/Clock.h
DisplayApp/Screens/Message.h
DisplayApp/Screens/Tile.h DisplayApp/Screens/Tile.h
DisplayApp/Screens/Meter.h DisplayApp/Screens/Meter.h
DisplayApp/Screens/Gauge.h DisplayApp/Screens/Gauge.h
@ -568,10 +557,47 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() endif()
# NRF SDK
add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES})
target_include_directories(nrf-sdk SYSTEM PUBLIC . ../)
target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(nrf-sdk PRIVATE
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
)
# NimBLE
add_library(nimble STATIC ${NIMBLE_SRC} ${TINYCRYPT_SRC})
target_include_directories(nimble SYSTEM PUBLIC . ../)
target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(nimble PRIVATE
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
)
# lvgl
add_library(lvgl STATIC ${LVGL_SRC})
target_include_directories(lvgl SYSTEM PUBLIC . ../)
target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(lvgl PRIVATE
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
)
# Build autonomous binary (without support for bootloader) # Build autonomous binary (without support for bootloader)
set(EXECUTABLE_NAME "pinetime-app") set(EXECUTABLE_NAME "pinetime-app")
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} ${SOURCE_FILES})
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl)
target_compile_options(${EXECUTABLE_NAME} PUBLIC target_compile_options(${EXECUTABLE_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3> $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3> $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
@ -600,6 +626,7 @@ set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app")
set(EXECUTABLE_MCUBOOT_WITH_BOOTLOADER_NAME "pinetime-mcuboot-app-wth-bootloader") set(EXECUTABLE_MCUBOOT_WITH_BOOTLOADER_NAME "pinetime-mcuboot-app-wth-bootloader")
set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld") set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld")
add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES}) add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES})
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl)
target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3> $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3> $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
@ -626,6 +653,7 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
# Build binary that writes the graphic assets for the bootloader # Build binary that writes the graphic assets for the bootloader
set(EXECUTABLE_GRAPHICS_NAME "pinetime-graphics") set(EXECUTABLE_GRAPHICS_NAME "pinetime-graphics")
add_executable(${EXECUTABLE_GRAPHICS_NAME} ${GRAPHICS_SOURCE_FILES}) add_executable(${EXECUTABLE_GRAPHICS_NAME} ${GRAPHICS_SOURCE_FILES})
target_link_libraries(${EXECUTABLE_GRAPHICS_NAME} nrf-sdk)
target_compile_options(${EXECUTABLE_GRAPHICS_NAME} PUBLIC target_compile_options(${EXECUTABLE_GRAPHICS_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3> $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3> $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>

View File

@ -116,7 +116,7 @@ void AlertNotificationClient::OnNotification(ble_gap_event *event) {
char *s = (char *) &data[3]; char *s = (char *) &data[3];
auto messageSize = min(maxMessageSize, (bufferSize-3)); auto messageSize = min(maxMessageSize, (bufferSize-3));
for (int i = 0; i < messageSize-1; i++) { for (uint i = 0; i < messageSize-1; i++) {
if (s[i] == 0x00) { if (s[i] == 0x00) {
s[i] = 0x0A; s[i] = 0x0A;
} }

View File

@ -26,8 +26,8 @@ void AlertNotificationService::Init() {
ASSERT(res == 0); ASSERT(res == 0);
} }
AlertNotificationService::AlertNotificationService ( Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager ) : m_systemTask{systemTask}, m_notificationManager{notificationManager}, AlertNotificationService::AlertNotificationService ( System::SystemTask& systemTask, NotificationManager& notificationManager )
characteristicDefinition{ : characteristicDefinition{
{ {
.uuid = (ble_uuid_t *) &ansCharUuid, .uuid = (ble_uuid_t *) &ansCharUuid,
.access_cb = AlertNotificationCallback, .access_cb = AlertNotificationCallback,
@ -48,8 +48,7 @@ AlertNotificationService::AlertNotificationService ( Pinetime::System::SystemTas
{ {
0 0
}, },
} }, m_systemTask{systemTask}, m_notificationManager{notificationManager} {
{
} }
int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle, int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle,
@ -67,7 +66,7 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle
char *s = (char *) &data[3]; char *s = (char *) &data[3];
auto messageSize = min(maxMessageSize, (bufferSize-3)); auto messageSize = min(maxMessageSize, (bufferSize-3));
for (int i = 0; i < messageSize-1; i++) { for (uint i = 0; i < messageSize-1; i++) {
if (s[i] == 0x00) { if (s[i] == 0x00) {
s[i] = 0x0A; s[i] = 0x0A;
} }

View File

@ -57,7 +57,7 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl
return 0; return 0;
} }
CurrentTimeService::CurrentTimeService(DateTime &dateTimeController) : m_dateTimeController{dateTimeController}, CurrentTimeService::CurrentTimeService(DateTime &dateTimeController) :
characteristicDefinition{ characteristicDefinition{
{ {
.uuid = (ble_uuid_t *) &ctChrUuid, .uuid = (ble_uuid_t *) &ctChrUuid,
@ -80,8 +80,7 @@ CurrentTimeService::CurrentTimeService(DateTime &dateTimeController) : m_dateTim
{ {
0 0
}, },
} }, m_dateTimeController{dateTimeController} {
{
} }

View File

@ -22,11 +22,11 @@ namespace Pinetime {
static constexpr uint16_t fwRevisionId {0x2a26}; static constexpr uint16_t fwRevisionId {0x2a26};
static constexpr uint16_t hwRevisionId {0x2a27}; static constexpr uint16_t hwRevisionId {0x2a27};
static constexpr char* manufacturerName = "Codingfield"; static constexpr const char* manufacturerName = "Codingfield";
static constexpr char* modelNumber = "1"; static constexpr const char* modelNumber = "1";
static constexpr char* serialNumber = "9.8.7.6.5.4"; static constexpr const char* serialNumber = "9.8.7.6.5.4";
static constexpr char* fwRevision = "0.7.0"; static constexpr const char* fwRevision = "0.7.0";
static constexpr char* hwRevision = "1.0.0"; static constexpr const char* hwRevision = "1.0.0";
static constexpr ble_uuid16_t deviceInfoUuid { static constexpr ble_uuid16_t deviceInfoUuid {
.u { .type = BLE_UUID_TYPE_16 }, .u { .type = BLE_UUID_TYPE_16 },

View File

@ -394,14 +394,14 @@ void DfuService::DfuImage::WriteMagicNumber() {
} }
void DfuService::DfuImage::Erase() { void DfuService::DfuImage::Erase() {
for (int erased = 0; erased < maxSize; erased += 0x1000) { for (size_t erased = 0; erased < maxSize; erased += 0x1000) {
spiNorFlash.SectorErase(writeOffset + erased); spiNorFlash.SectorErase(writeOffset + erased);
} }
} }
bool DfuService::DfuImage::Validate() { bool DfuService::DfuImage::Validate() {
uint32_t chunkSize = 200; uint32_t chunkSize = 200;
int currentOffset = 0; size_t currentOffset = 0;
uint16_t crc = 0; uint16_t crc = 0;
bool first = true; bool first = true;

View File

@ -117,7 +117,6 @@ unsigned char Pinetime::Controllers::MusicService::status()
void Pinetime::Controllers::MusicService::event(char event) void Pinetime::Controllers::MusicService::event(char event)
{ {
auto *om = ble_hs_mbuf_from_flat(&event, 1); auto *om = ble_hs_mbuf_from_flat(&event, 1);
int ret;
uint16_t connectionHandle = m_system.nimble().connHandle(); uint16_t connectionHandle = m_system.nimble().connHandle();
@ -125,6 +124,6 @@ void Pinetime::Controllers::MusicService::event(char event)
return; return;
} }
ret = ble_gattc_notify_custom(connectionHandle, m_eventHandle, om); ble_gattc_notify_custom(connectionHandle, m_eventHandle, om);
} }

View File

@ -139,14 +139,13 @@ void NimbleController::StartAdvertising() {
rsp_fields.name_len = strlen("Pinetime-JF"); rsp_fields.name_len = strlen("Pinetime-JF");
rsp_fields.name_is_complete = 1; rsp_fields.name_is_complete = 1;
int res; ble_gap_adv_set_fields(&fields);
res = ble_gap_adv_set_fields(&fields);
// ASSERT(res == 0); // TODO this one sometimes fails with error 22 (notsync) // ASSERT(res == 0); // TODO this one sometimes fails with error 22 (notsync)
res = ble_gap_adv_rsp_set_fields(&rsp_fields); ble_gap_adv_rsp_set_fields(&rsp_fields);
// ASSERT(res == 0); // ASSERT(res == 0);
res = ble_gap_adv_start(addrType, NULL, 180000, ble_gap_adv_start(addrType, NULL, 180000,
&adv_params, GAPEventCallback, this); &adv_params, GAPEventCallback, this);
// ASSERT(res == 0);// TODO I've disabled these ASSERT as they sometime asserts and reset the mcu. // ASSERT(res == 0);// TODO I've disabled these ASSERT as they sometime asserts and reset the mcu.
// For now, the advertising is restarted as soon as it ends. There may be a race condition // For now, the advertising is restarted as soon as it ends. There may be a race condition

View File

@ -43,7 +43,7 @@ namespace Pinetime {
uint16_t connHandle(); uint16_t connHandle();
private: private:
static constexpr char* deviceName = "Pinetime-JF"; static constexpr const char* deviceName = "Pinetime-JF";
Pinetime::System::SystemTask& systemTask; Pinetime::System::SystemTask& systemTask;
Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::Ble& bleController;
DateTime& dateTimeController; DateTime& dateTimeController;

View File

@ -79,6 +79,9 @@ void DisplayApp::Refresh() {
RunningState(); RunningState();
queueTimeout = 20; queueTimeout = 20;
break; break;
default:
queueTimeout = portMAX_DELAY;
break;
} }
Messages msg; Messages msg;

View File

@ -30,11 +30,10 @@ namespace Pinetime {
class DisplayApp { class DisplayApp {
public: public:
enum class States {Idle, Running}; enum class States {Idle, Running};
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed, enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, ButtonPushed,
NewNotification, BleFirmwareUpdateStarted, BleFirmwareUpdateFinished NewNotification, BleFirmwareUpdateStarted };
};
enum class FullRefreshDirections { None, Up, Down };
enum class FullRefreshDirections { None, Up, Down };
DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &, DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &,
Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::Battery &batteryController, Controllers::Ble &bleController,

View File

@ -6,10 +6,6 @@
#include <drivers/St7789.h> #include <drivers/St7789.h>
#include <drivers/Cst816s.h> #include <drivers/Cst816s.h>
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
namespace Pinetime { namespace Pinetime {
namespace Components { namespace Components {
class LittleVgl { class LittleVgl {

View File

@ -121,13 +121,12 @@ bool Clock::Refresh() {
auto hour = time.hours().count(); auto hour = time.hours().count();
auto minute = time.minutes().count(); auto minute = time.minutes().count();
auto second = time.seconds().count();
char minutesChar[3]; char minutesChar[3];
sprintf(minutesChar, "%02d", minute); sprintf(minutesChar, "%02d", static_cast<int>(minute));
char hoursChar[3]; char hoursChar[3];
sprintf(hoursChar, "%02d", hour); sprintf(hoursChar, "%02d", static_cast<int>(hour));
char timeStr[6]; char timeStr[6];
sprintf(timeStr, "%c%c:%c%c", hoursChar[0],hoursChar[1],minutesChar[0], minutesChar[1]); sprintf(timeStr, "%c%c:%c%c", hoursChar[0],hoursChar[1],minutesChar[0], minutesChar[1]);

View File

@ -29,7 +29,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp *app,
labelVersionValue = lv_label_create(lv_scr_act(), NULL); labelVersionValue = lv_label_create(lv_scr_act(), NULL);
lv_obj_align(labelVersionValue, labelVersionInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_obj_align(labelVersionValue, labelVersionInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
lv_label_set_recolor(labelVersionValue, true); lv_label_set_recolor(labelVersionValue, true);
sprintf(version, "%d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); sprintf(version, "%ld.%ld.%ld", Version::Major(), Version::Minor(), Version::Patch());
lv_label_set_text(labelVersionValue, version); lv_label_set_text(labelVersionValue, version);
labelIsValidated = lv_label_create(lv_scr_act(), NULL); labelIsValidated = lv_label_create(lv_scr_act(), NULL);

View File

@ -1,81 +0,0 @@
#include <cstdio>
#include <libs/date/includes/date/date.h>
#include <Components/DateTime/DateTimeController.h>
#include <Version.h>
#include <libs/lvgl/src/lv_core/lv_obj.h>
#include <libs/lvgl/src/lv_font/lv_font.h>
#include <libs/lvgl/lvgl.h>
#include <libraries/log/nrf_log.h>
#include "Message.h"
#include <DisplayApp/DisplayApp.h>
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_bold_20;
static void event_handler(lv_obj_t * obj, lv_event_t event) {
Message* screen = static_cast<Message *>(obj->user_data);
screen->OnObjectEvent(obj, event);
}
Message::Message(DisplayApp* app) : Screen(app) {
backgroundLabel = lv_label_create(lv_scr_act(), NULL);
backgroundLabel->user_data = this;
lv_obj_set_click(backgroundLabel, true);
lv_obj_set_event_cb(backgroundLabel, event_handler);
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text(backgroundLabel, "");
button = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(button, event_handler);
lv_obj_align(button, NULL, LV_ALIGN_CENTER, 0, -40);
button->user_data = this;
label = lv_label_create(button, NULL);
lv_label_set_text(label, "Hello!");
labelClick = lv_label_create(lv_scr_act(), NULL);
lv_obj_align(labelClick, button, LV_ALIGN_OUT_BOTTOM_MID, 0, 30);
lv_label_set_text(labelClick, "0");
}
Message::~Message() {
lv_obj_clean(lv_scr_act());
}
bool Message::Refresh() {
if(previousClickCount != clickCount) {
lv_label_set_text_fmt(labelClick, "%d", clickCount);
previousClickCount = clickCount;
}
return running;
}
void Message::OnObjectEvent(lv_obj_t *obj, lv_event_t event) {
if(obj == backgroundLabel) {
if(event == LV_EVENT_CLICKED) {
app->PushMessage(DisplayApp::Messages::SwitchScreen);
NRF_LOG_INFO("SCREEN");
}
return ;
}
if(event == LV_EVENT_CLICKED) {
NRF_LOG_INFO("Clicked");
clickCount++;
}
else if(event == LV_EVENT_VALUE_CHANGED) {
NRF_LOG_INFO("Toggled");
}
}
bool Message::OnButtonPushed() {
running = false;
return true;
}

View File

@ -1,31 +0,0 @@
#pragma once
#include <cstdint>
#include "Screen.h"
#include <bits/unique_ptr.h>
#include <lvgl/src/lv_core/lv_style.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
class Message : public Screen{
public:
explicit Message(DisplayApp* app);
~Message() override;
bool Refresh() override;
bool OnButtonPushed();
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
private:
lv_obj_t * label;
lv_obj_t* backgroundLabel;
lv_obj_t * button;
lv_obj_t * labelClick;
uint32_t clickCount = 0 ;
uint32_t previousClickCount = 0;
bool running = true;
};
}
}
}

View File

@ -4,25 +4,25 @@ namespace Pinetime {
namespace Applications { namespace Applications {
namespace Screens { namespace Screens {
namespace Symbols { namespace Symbols {
static constexpr char* none = ""; static constexpr const char* none = "";
static constexpr char* batteryFull = "\xEF\x89\x80"; static constexpr const char* batteryFull = "\xEF\x89\x80";
static constexpr char* batteryEmpty = "\xEF\x89\x84"; static constexpr const char* batteryEmpty = "\xEF\x89\x84";
static constexpr char* batteryThreeQuarter = "\xEF\x89\x81"; static constexpr const char* batteryThreeQuarter = "\xEF\x89\x81";
static constexpr char* batteryHalf = "\xEF\x89\x82"; static constexpr const char* batteryHalf = "\xEF\x89\x82";
static constexpr char* batteryOneQuarter = "\xEF\x89\x83"; static constexpr const char* batteryOneQuarter = "\xEF\x89\x83";
static constexpr char* heartBeat = "\xEF\x88\x9E"; static constexpr const char* heartBeat = "\xEF\x88\x9E";
static constexpr char* bluetoothFull = "\xEF\x8A\x93"; static constexpr const char* bluetoothFull = "\xEF\x8A\x93";
static constexpr char* bluetooth = "\xEF\x8A\x94"; static constexpr const char* bluetooth = "\xEF\x8A\x94";
static constexpr char* plug = "\xEF\x87\xA6"; static constexpr const char* plug = "\xEF\x87\xA6";
static constexpr char* shoe = "\xEF\x95\x8B"; static constexpr const char* shoe = "\xEF\x95\x8B";
static constexpr char* clock = "\xEF\x80\x97"; static constexpr const char* clock = "\xEF\x80\x97";
static constexpr char* info = "\xEF\x84\xA9"; static constexpr const char* info = "\xEF\x84\xA9";
static constexpr char* list = "\xEF\x80\xBA"; static constexpr const char* list = "\xEF\x80\xBA";
static constexpr char* sun = "\xEF\x86\x85"; static constexpr const char* sun = "\xEF\x86\x85";
static constexpr char* check = "\xEF\x95\xA0"; static constexpr const char* check = "\xEF\x95\xA0";
static constexpr char* music = "\xEF\x80\x81"; static constexpr const char* music = "\xEF\x80\x81";
static constexpr char* tachometer = "\xEF\x8F\xBD"; static constexpr const char* tachometer = "\xEF\x8F\xBD";
static constexpr char* asterisk = "\xEF\x81\xA9"; static constexpr const char* asterisk = "\xEF\x81\xA9";
} }
} }
} }

View File

@ -49,6 +49,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
uint8_t brightness = 0; uint8_t brightness = 0;
switch(brightnessController.Level()) { switch(brightnessController.Level()) {
case Controllers::BrightnessController::Levels::Off: brightness = 0; break;
case Controllers::BrightnessController::Levels::Low: brightness = 1; break; case Controllers::BrightnessController::Levels::Low: brightness = 1; break;
case Controllers::BrightnessController::Levels::Medium: brightness = 2; break; case Controllers::BrightnessController::Levels::Medium: brightness = 2; break;
case Controllers::BrightnessController::Levels::High: brightness = 3; break; case Controllers::BrightnessController::Levels::High: brightness = 3; break;
@ -82,10 +83,10 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
// TODO handle more than 100 days of uptime // TODO handle more than 100 days of uptime
sprintf(t1, "Pinetime\n" sprintf(t1, "Pinetime\n"
"Version:%d.%d.%d\n" "Version:%ld.%ld.%ld\n"
"Build: %s\n" "Build: %s\n"
" %s\n" " %s\n"
"Date: %02d/%02d/%04d\n" "Date: %02d/%02hhu/%04d\n"
"Time: %02d:%02d:%02d\n" "Time: %02d:%02d:%02d\n"
"Uptime: %02lud %02lu:%02lu:%02lu\n" "Uptime: %02lud %02lu:%02lu:%02lu\n"
"Battery: %d%%\n" "Battery: %d%%\n"
@ -93,7 +94,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
"Last reset: %s\n", "Last reset: %s\n",
Version::Major(), Version::Minor(), Version::Patch(), Version::Major(), Version::Minor(), Version::Patch(),
__DATE__, __TIME__, __DATE__, __TIME__,
dateTimeController.Day(), dateTimeController.Month(), dateTimeController.Year(), dateTimeController.Day(), static_cast<uint8_t>(dateTimeController.Month()), dateTimeController.Year(),
dateTimeController.Hours(), dateTimeController.Minutes(), dateTimeController.Seconds(), dateTimeController.Hours(), dateTimeController.Minutes(), dateTimeController.Seconds(),
uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds, uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds,
batteryPercent, brightness, resetReason); batteryPercent, brightness, resetReason);

View File

@ -46,7 +46,6 @@ bool Tile::Refresh() {
} }
void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) { void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) {
auto* tile = static_cast<Tile*>(obj->user_data);
if(event == LV_EVENT_VALUE_CHANGED) { if(event == LV_EVENT_VALUE_CHANGED) {
app->StartApp(apps[buttonId]); app->StartApp(apps[buttonId]);
running = false; running = false;

View File

@ -28,7 +28,7 @@ namespace Pinetime {
if(xTaskGetTickCount() - lastTick > 10000) { if(xTaskGetTickCount() - lastTick > 10000) {
NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize()); NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize());
auto nb = uxTaskGetSystemState(tasksStatus, 10, NULL); auto nb = uxTaskGetSystemState(tasksStatus, 10, NULL);
for (int i = 0; i < nb; i++) { for (uint32_t i = 0; i < nb; i++) {
NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark); NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark);
if (tasksStatus[i].usStackHighWaterMark < 20) if (tasksStatus[i].usStackHighWaterMark < 20)
NRF_LOG_INFO("WARNING!!! Task %s task is nearly full, only %dB available", tasksStatus[i].pcTaskName, NRF_LOG_INFO("WARNING!!! Task %s task is nearly full, only %dB available", tasksStatus[i].pcTaskName,

View File

@ -136,7 +136,6 @@ void SystemTask::Work() {
case Messages::BleFirmwareUpdateFinished: case Messages::BleFirmwareUpdateFinished:
doNotGoToSleep = false; doNotGoToSleep = false;
xTimerStart(idleTimer, 0); xTimerStart(idleTimer, 0);
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::BleFirmwareUpdateFinished);
if(bleController.State() == Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated) if(bleController.State() == Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated)
NVIC_SystemReset(); NVIC_SystemReset();
break; break;

View File

@ -60,9 +60,9 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
uint16_t y = (yHigh << 8) | yLow; uint16_t y = (yHigh << 8) | yLow;
auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/ auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/
auto finger = touchData[touchIdIndex + (touchStep * i)] >> 4; //auto finger = touchData[touchIdIndex + (touchStep * i)] >> 4;
auto pressure = touchData[touchXYIndex + (touchStep * i)]; //auto pressure = touchData[touchXYIndex + (touchStep * i)];
auto area = touchData[touchMiscIndex + (touchStep * i)] >> 4; //auto area = touchData[touchMiscIndex + (touchStep * i)] >> 4;
info.x = x; info.x = x;
info.y = y; info.y = y;
@ -89,7 +89,6 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
// case Gestures::LongPress: NRF_LOG_INFO("Gesture : Long press"); break; // case Gestures::LongPress: NRF_LOG_INFO("Gesture : Long press"); break;
// default : NRF_LOG_INFO("Unknown"); break; // default : NRF_LOG_INFO("Unknown"); break;
// } // }
} }

View File

@ -117,8 +117,6 @@ void SpiMaster::OnEndEvent() {
spiBaseAddress->TASKS_START = 1; spiBaseAddress->TASKS_START = 1;
} else { } else {
uint8_t* buffer = nullptr;
size_t size = 0;
if(taskToNotify != nullptr) { if(taskToNotify != nullptr) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(taskToNotify, &xHigherPriorityTaskWoken); vTaskNotifyGiveFromISR(taskToNotify, &xHigherPriorityTaskWoken);

View File

@ -103,10 +103,10 @@ void Process(void* instance) {
static constexpr uint32_t screenWidth = 240; static constexpr uint32_t screenWidth = 240;
static constexpr uint32_t screenWidthInBytes = screenWidth*2; // LCD display 16bits color (1 pixel = 2 bytes) static constexpr uint32_t screenWidthInBytes = screenWidth*2; // LCD display 16bits color (1 pixel = 2 bytes)
uint16_t displayLineBuffer[screenWidth]; uint16_t displayLineBuffer[screenWidth];
for(int line = 0; line < screenWidth; line++) { for(uint32_t line = 0; line < screenWidth; line++) {
spiNorFlash.Read(line*screenWidthInBytes, reinterpret_cast<uint8_t *>(displayLineBuffer), screenWidth); spiNorFlash.Read(line*screenWidthInBytes, reinterpret_cast<uint8_t *>(displayLineBuffer), screenWidth);
spiNorFlash.Read((line*screenWidthInBytes)+screenWidth, reinterpret_cast<uint8_t *>(displayLineBuffer) + screenWidth, screenWidth); spiNorFlash.Read((line*screenWidthInBytes)+screenWidth, reinterpret_cast<uint8_t *>(displayLineBuffer) + screenWidth, screenWidth);
for(int col = 0; col < screenWidth; col++) { for(uint32_t col = 0; col < screenWidth; col++) {
gfx.pixel_draw(col, line, displayLineBuffer[col]); gfx.pixel_draw(col, line, displayLineBuffer[col]);
} }
} }

View File

@ -310,12 +310,14 @@ ble_gap_log_conn(uint8_t own_addr_type, const ble_addr_t *peer_addr,
BLE_HS_LOG_ADDR(INFO, peer_addr->val); BLE_HS_LOG_ADDR(INFO, peer_addr->val);
} }
/* // NRF LOG support max 6 params in log
BLE_HS_LOG(INFO, " scan_itvl=%d scan_window=%d itvl_min=%d itvl_max=%d " BLE_HS_LOG(INFO, " scan_itvl=%d scan_window=%d itvl_min=%d itvl_max=%d "
"latency=%d supervision_timeout=%d min_ce_len=%d " "latency=%d supervision_timeout=%d min_ce_len=%d "
"max_ce_len=%d own_addr_type=%d", "max_ce_len=%d own_addr_type=%d",
params->scan_itvl, params->scan_window, params->itvl_min, params->scan_itvl, params->scan_window, params->itvl_min,
params->itvl_max, params->latency, params->supervision_timeout, params->itvl_max, params->latency, params->supervision_timeout,
params->min_ce_len, params->max_ce_len, own_addr_type); params->min_ce_len, params->max_ce_len, own_addr_type);
*/
} }
#endif #endif