From 83f6d7d81b80809de0bc850a0b445bc035098dba Mon Sep 17 00:00:00 2001 From: JF Date: Mon, 17 Aug 2020 16:31:00 +0200 Subject: [PATCH 1/2] Fix most of the warnings. Remaining warnings come from nimble source code. --- src/BlinkApp/BlinkApp.cpp | 25 ------ src/BlinkApp/BlinkApp.h | 15 ---- src/CMakeLists.txt | 4 - .../Ble/AlertNotificationClient.cpp | 2 +- .../Ble/AlertNotificationService.cpp | 9 +-- src/Components/Ble/CurrentTimeService.cpp | 5 +- src/Components/Ble/DeviceInformationService.h | 10 +-- src/Components/Ble/DfuService.cpp | 4 +- src/Components/Ble/MusicService.cpp | 3 +- src/Components/Ble/NimbleController.cpp | 7 +- src/Components/Ble/NimbleController.h | 2 +- src/DisplayApp/DisplayApp.cpp | 3 + src/DisplayApp/DisplayApp.h | 7 +- src/DisplayApp/LittleVgl.h | 4 - src/DisplayApp/Screens/Clock.cpp | 5 +- src/DisplayApp/Screens/FirmwareValidation.cpp | 2 +- src/DisplayApp/Screens/Message.cpp | 81 ------------------- src/DisplayApp/Screens/Message.h | 31 ------- src/DisplayApp/Screens/Symbols.h | 38 ++++----- src/DisplayApp/Screens/SystemInfo.cpp | 7 +- src/DisplayApp/Screens/Tile.cpp | 1 - src/SystemTask/SystemMonitor.h | 2 +- src/SystemTask/SystemTask.cpp | 1 - src/drivers/Cst816s.cpp | 7 +- src/drivers/SpiMaster.cpp | 2 - src/graphics.cpp | 4 +- .../mynewt-nimble/nimble/host/src/ble_gap.c | 2 + 27 files changed, 59 insertions(+), 224 deletions(-) delete mode 100644 src/BlinkApp/BlinkApp.cpp delete mode 100644 src/BlinkApp/BlinkApp.h delete mode 100644 src/DisplayApp/Screens/Message.cpp delete mode 100644 src/DisplayApp/Screens/Message.h diff --git a/src/BlinkApp/BlinkApp.cpp b/src/BlinkApp/BlinkApp.cpp deleted file mode 100644 index a988dfd3..00000000 --- a/src/BlinkApp/BlinkApp.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "BlinkApp.h" -#include -#include -#include -#include - -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(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); - } -} diff --git a/src/BlinkApp/BlinkApp.h b/src/BlinkApp/BlinkApp.h deleted file mode 100644 index 15c863a3..00000000 --- a/src/BlinkApp/BlinkApp.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include -#include - -namespace Pinetime { - namespace Applications { - class BlinkApp { - public: - void Start(); - private: - TaskHandle_t taskHandle; - static void Process(void* instance); - }; - } -} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c4487afe..b48b8510 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -321,11 +321,9 @@ list(APPEND IMAGE_FILES list(APPEND SOURCE_FILES Logging/NrfLogger.cpp - BlinkApp/BlinkApp.cpp DisplayApp/DisplayApp.cpp DisplayApp/Screens/Screen.cpp DisplayApp/Screens/Clock.cpp - DisplayApp/Screens/Message.cpp DisplayApp/Screens/Tile.cpp DisplayApp/Screens/Meter.cpp DisplayApp/Screens/Gauge.cpp @@ -402,12 +400,10 @@ list(APPEND GRAPHICS_SOURCE_FILES set(INCLUDE_FILES Logging/Logger.h Logging/NrfLogger.h - BlinkApp/BlinkApp.h DisplayApp/DisplayApp.h DisplayApp/TouchEvents.h DisplayApp/Screens/Screen.h DisplayApp/Screens/Clock.h - DisplayApp/Screens/Message.h DisplayApp/Screens/Tile.h DisplayApp/Screens/Meter.h DisplayApp/Screens/Gauge.h diff --git a/src/Components/Ble/AlertNotificationClient.cpp b/src/Components/Ble/AlertNotificationClient.cpp index b65e019d..3e4b495f 100644 --- a/src/Components/Ble/AlertNotificationClient.cpp +++ b/src/Components/Ble/AlertNotificationClient.cpp @@ -116,7 +116,7 @@ void AlertNotificationClient::OnNotification(ble_gap_event *event) { char *s = (char *) &data[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) { s[i] = 0x0A; } diff --git a/src/Components/Ble/AlertNotificationService.cpp b/src/Components/Ble/AlertNotificationService.cpp index 0faa17c8..ce2f7dd7 100644 --- a/src/Components/Ble/AlertNotificationService.cpp +++ b/src/Components/Ble/AlertNotificationService.cpp @@ -26,8 +26,8 @@ void AlertNotificationService::Init() { ASSERT(res == 0); } -AlertNotificationService::AlertNotificationService ( Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager ) : m_systemTask{systemTask}, m_notificationManager{notificationManager}, - characteristicDefinition{ +AlertNotificationService::AlertNotificationService ( System::SystemTask& systemTask, NotificationManager& notificationManager ) + : characteristicDefinition{ { .uuid = (ble_uuid_t *) &ansCharUuid, .access_cb = AlertNotificationCallback, @@ -48,8 +48,7 @@ AlertNotificationService::AlertNotificationService ( Pinetime::System::SystemTas { 0 }, - } -{ + }, m_systemTask{systemTask}, m_notificationManager{notificationManager} { } 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]; 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) { s[i] = 0x0A; } diff --git a/src/Components/Ble/CurrentTimeService.cpp b/src/Components/Ble/CurrentTimeService.cpp index 80ad9c25..3a6264e2 100644 --- a/src/Components/Ble/CurrentTimeService.cpp +++ b/src/Components/Ble/CurrentTimeService.cpp @@ -57,7 +57,7 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl return 0; } -CurrentTimeService::CurrentTimeService(DateTime &dateTimeController) : m_dateTimeController{dateTimeController}, +CurrentTimeService::CurrentTimeService(DateTime &dateTimeController) : characteristicDefinition{ { .uuid = (ble_uuid_t *) &ctChrUuid, @@ -80,8 +80,7 @@ CurrentTimeService::CurrentTimeService(DateTime &dateTimeController) : m_dateTim { 0 }, - } - { + }, m_dateTimeController{dateTimeController} { } diff --git a/src/Components/Ble/DeviceInformationService.h b/src/Components/Ble/DeviceInformationService.h index d768da8e..7d7cea96 100644 --- a/src/Components/Ble/DeviceInformationService.h +++ b/src/Components/Ble/DeviceInformationService.h @@ -22,11 +22,11 @@ namespace Pinetime { static constexpr uint16_t fwRevisionId {0x2a26}; static constexpr uint16_t hwRevisionId {0x2a27}; - static constexpr char* manufacturerName = "Codingfield"; - static constexpr char* modelNumber = "1"; - static constexpr char* serialNumber = "9.8.7.6.5.4"; - static constexpr char* fwRevision = "0.7.0"; - static constexpr char* hwRevision = "1.0.0"; + static constexpr const char* manufacturerName = "Codingfield"; + static constexpr const char* modelNumber = "1"; + static constexpr const char* serialNumber = "9.8.7.6.5.4"; + static constexpr const char* fwRevision = "0.7.0"; + static constexpr const char* hwRevision = "1.0.0"; static constexpr ble_uuid16_t deviceInfoUuid { .u { .type = BLE_UUID_TYPE_16 }, diff --git a/src/Components/Ble/DfuService.cpp b/src/Components/Ble/DfuService.cpp index c6d8493f..fcbefdd0 100644 --- a/src/Components/Ble/DfuService.cpp +++ b/src/Components/Ble/DfuService.cpp @@ -394,14 +394,14 @@ void DfuService::DfuImage::WriteMagicNumber() { } 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); } } bool DfuService::DfuImage::Validate() { uint32_t chunkSize = 200; - int currentOffset = 0; + size_t currentOffset = 0; uint16_t crc = 0; bool first = true; diff --git a/src/Components/Ble/MusicService.cpp b/src/Components/Ble/MusicService.cpp index 5ec76697..b5fa5356 100644 --- a/src/Components/Ble/MusicService.cpp +++ b/src/Components/Ble/MusicService.cpp @@ -117,7 +117,6 @@ unsigned char Pinetime::Controllers::MusicService::status() void Pinetime::Controllers::MusicService::event(char event) { auto *om = ble_hs_mbuf_from_flat(&event, 1); - int ret; uint16_t connectionHandle = m_system.nimble().connHandle(); @@ -125,6 +124,6 @@ void Pinetime::Controllers::MusicService::event(char event) return; } - ret = ble_gattc_notify_custom(connectionHandle, m_eventHandle, om); + ble_gattc_notify_custom(connectionHandle, m_eventHandle, om); } diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp index d7bbd8be..a865a824 100644 --- a/src/Components/Ble/NimbleController.cpp +++ b/src/Components/Ble/NimbleController.cpp @@ -139,14 +139,13 @@ void NimbleController::StartAdvertising() { rsp_fields.name_len = strlen("Pinetime-JF"); rsp_fields.name_is_complete = 1; - int res; - res = ble_gap_adv_set_fields(&fields); + ble_gap_adv_set_fields(&fields); // 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); - res = ble_gap_adv_start(addrType, NULL, 180000, + ble_gap_adv_start(addrType, NULL, 180000, &adv_params, GAPEventCallback, this); // 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 diff --git a/src/Components/Ble/NimbleController.h b/src/Components/Ble/NimbleController.h index dff93c87..49f4377b 100644 --- a/src/Components/Ble/NimbleController.h +++ b/src/Components/Ble/NimbleController.h @@ -43,7 +43,7 @@ namespace Pinetime { uint16_t connHandle(); private: - static constexpr char* deviceName = "Pinetime-JF"; + static constexpr const char* deviceName = "Pinetime-JF"; Pinetime::System::SystemTask& systemTask; Pinetime::Controllers::Ble& bleController; DateTime& dateTimeController; diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 93557807..175bdc80 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -79,6 +79,9 @@ void DisplayApp::Refresh() { RunningState(); queueTimeout = 20; break; + default: + queueTimeout = portMAX_DELAY; + break; } Messages msg; diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index a6df95c1..478953c8 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -30,11 +30,10 @@ namespace Pinetime { class DisplayApp { public: enum class States {Idle, Running}; - enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed, - NewNotification, BleFirmwareUpdateStarted, BleFirmwareUpdateFinished - }; - enum class FullRefreshDirections { None, Up, Down }; + enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, ButtonPushed, + NewNotification, BleFirmwareUpdateStarted }; + enum class FullRefreshDirections { None, Up, Down }; DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &, Controllers::Battery &batteryController, Controllers::Ble &bleController, diff --git a/src/DisplayApp/LittleVgl.h b/src/DisplayApp/LittleVgl.h index 8bd56ddf..5c1c4434 100644 --- a/src/DisplayApp/LittleVgl.h +++ b/src/DisplayApp/LittleVgl.h @@ -6,10 +6,6 @@ #include #include - -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 Components { class LittleVgl { diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index fc6441e8..06fab9aa 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -121,13 +121,12 @@ bool Clock::Refresh() { auto hour = time.hours().count(); auto minute = time.minutes().count(); - auto second = time.seconds().count(); char minutesChar[3]; - sprintf(minutesChar, "%02d", minute); + sprintf(minutesChar, "%02d", static_cast(minute)); char hoursChar[3]; - sprintf(hoursChar, "%02d", hour); + sprintf(hoursChar, "%02d", static_cast(hour)); char timeStr[6]; sprintf(timeStr, "%c%c:%c%c", hoursChar[0],hoursChar[1],minutesChar[0], minutesChar[1]); diff --git a/src/DisplayApp/Screens/FirmwareValidation.cpp b/src/DisplayApp/Screens/FirmwareValidation.cpp index 70d32575..fb2dd956 100644 --- a/src/DisplayApp/Screens/FirmwareValidation.cpp +++ b/src/DisplayApp/Screens/FirmwareValidation.cpp @@ -29,7 +29,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp *app, labelVersionValue = lv_label_create(lv_scr_act(), NULL); lv_obj_align(labelVersionValue, labelVersionInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0); 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); labelIsValidated = lv_label_create(lv_scr_act(), NULL); diff --git a/src/DisplayApp/Screens/Message.cpp b/src/DisplayApp/Screens/Message.cpp deleted file mode 100644 index b83cb751..00000000 --- a/src/DisplayApp/Screens/Message.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include "Message.h" -#include - - -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(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; -} diff --git a/src/DisplayApp/Screens/Message.h b/src/DisplayApp/Screens/Message.h deleted file mode 100644 index 3ace66fe..00000000 --- a/src/DisplayApp/Screens/Message.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include "Screen.h" -#include -#include - -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; - }; - } - } -} diff --git a/src/DisplayApp/Screens/Symbols.h b/src/DisplayApp/Screens/Symbols.h index 54c3f8f0..69078c8a 100644 --- a/src/DisplayApp/Screens/Symbols.h +++ b/src/DisplayApp/Screens/Symbols.h @@ -4,25 +4,25 @@ namespace Pinetime { namespace Applications { namespace Screens { namespace Symbols { - static constexpr char* none = ""; - static constexpr char* batteryFull = "\xEF\x89\x80"; - static constexpr char* batteryEmpty = "\xEF\x89\x84"; - static constexpr char* batteryThreeQuarter = "\xEF\x89\x81"; - static constexpr char* batteryHalf = "\xEF\x89\x82"; - static constexpr char* batteryOneQuarter = "\xEF\x89\x83"; - static constexpr char* heartBeat = "\xEF\x88\x9E"; - static constexpr char* bluetoothFull = "\xEF\x8A\x93"; - static constexpr char* bluetooth = "\xEF\x8A\x94"; - static constexpr char* plug = "\xEF\x87\xA6"; - static constexpr char* shoe = "\xEF\x95\x8B"; - static constexpr char* clock = "\xEF\x80\x97"; - static constexpr char* info = "\xEF\x84\xA9"; - static constexpr char* list = "\xEF\x80\xBA"; - static constexpr char* sun = "\xEF\x86\x85"; - static constexpr char* check = "\xEF\x95\xA0"; - static constexpr char* music = "\xEF\x80\x81"; - static constexpr char* tachometer = "\xEF\x8F\xBD"; - static constexpr char* asterisk = "\xEF\x81\xA9"; + static constexpr const char* none = ""; + static constexpr const char* batteryFull = "\xEF\x89\x80"; + static constexpr const char* batteryEmpty = "\xEF\x89\x84"; + static constexpr const char* batteryThreeQuarter = "\xEF\x89\x81"; + static constexpr const char* batteryHalf = "\xEF\x89\x82"; + static constexpr const char* batteryOneQuarter = "\xEF\x89\x83"; + static constexpr const char* heartBeat = "\xEF\x88\x9E"; + static constexpr const char* bluetoothFull = "\xEF\x8A\x93"; + static constexpr const char* bluetooth = "\xEF\x8A\x94"; + static constexpr const char* plug = "\xEF\x87\xA6"; + static constexpr const char* shoe = "\xEF\x95\x8B"; + static constexpr const char* clock = "\xEF\x80\x97"; + static constexpr const char* info = "\xEF\x84\xA9"; + static constexpr const char* list = "\xEF\x80\xBA"; + static constexpr const char* sun = "\xEF\x86\x85"; + static constexpr const char* check = "\xEF\x95\xA0"; + static constexpr const char* music = "\xEF\x80\x81"; + static constexpr const char* tachometer = "\xEF\x8F\xBD"; + static constexpr const char* asterisk = "\xEF\x81\xA9"; } } } diff --git a/src/DisplayApp/Screens/SystemInfo.cpp b/src/DisplayApp/Screens/SystemInfo.cpp index b355f419..ef55eb5f 100644 --- a/src/DisplayApp/Screens/SystemInfo.cpp +++ b/src/DisplayApp/Screens/SystemInfo.cpp @@ -49,6 +49,7 @@ std::unique_ptr SystemInfo::CreateScreen1() { uint8_t brightness = 0; switch(brightnessController.Level()) { + case Controllers::BrightnessController::Levels::Off: brightness = 0; break; case Controllers::BrightnessController::Levels::Low: brightness = 1; break; case Controllers::BrightnessController::Levels::Medium: brightness = 2; break; case Controllers::BrightnessController::Levels::High: brightness = 3; break; @@ -82,10 +83,10 @@ std::unique_ptr SystemInfo::CreateScreen1() { // TODO handle more than 100 days of uptime sprintf(t1, "Pinetime\n" - "Version:%d.%d.%d\n" + "Version:%ld.%ld.%ld\n" "Build: %s\n" " %s\n" - "Date: %02d/%02d/%04d\n" + "Date: %02d/%02hhu/%04d\n" "Time: %02d:%02d:%02d\n" "Uptime: %02lud %02lu:%02lu:%02lu\n" "Battery: %d%%\n" @@ -93,7 +94,7 @@ std::unique_ptr SystemInfo::CreateScreen1() { "Last reset: %s\n", Version::Major(), Version::Minor(), Version::Patch(), __DATE__, __TIME__, - dateTimeController.Day(), dateTimeController.Month(), dateTimeController.Year(), + dateTimeController.Day(), static_cast(dateTimeController.Month()), dateTimeController.Year(), dateTimeController.Hours(), dateTimeController.Minutes(), dateTimeController.Seconds(), uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds, batteryPercent, brightness, resetReason); diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/DisplayApp/Screens/Tile.cpp index 5d4da2cf..1447d789 100644 --- a/src/DisplayApp/Screens/Tile.cpp +++ b/src/DisplayApp/Screens/Tile.cpp @@ -46,7 +46,6 @@ bool Tile::Refresh() { } void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) { - auto* tile = static_cast(obj->user_data); if(event == LV_EVENT_VALUE_CHANGED) { app->StartApp(apps[buttonId]); running = false; diff --git a/src/SystemTask/SystemMonitor.h b/src/SystemTask/SystemMonitor.h index 8fcfafb2..ec1fd817 100644 --- a/src/SystemTask/SystemMonitor.h +++ b/src/SystemTask/SystemMonitor.h @@ -28,7 +28,7 @@ namespace Pinetime { if(xTaskGetTickCount() - lastTick > 10000) { NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize()); 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); if (tasksStatus[i].usStackHighWaterMark < 20) NRF_LOG_INFO("WARNING!!! Task %s task is nearly full, only %dB available", tasksStatus[i].pcTaskName, diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp index d4b78187..1ee8e918 100644 --- a/src/SystemTask/SystemTask.cpp +++ b/src/SystemTask/SystemTask.cpp @@ -136,7 +136,6 @@ void SystemTask::Work() { case Messages::BleFirmwareUpdateFinished: doNotGoToSleep = false; xTimerStart(idleTimer, 0); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::BleFirmwareUpdateFinished); if(bleController.State() == Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated) NVIC_SystemReset(); break; diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index 60cd402c..6afbf734 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -60,9 +60,9 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { uint16_t y = (yHigh << 8) | yLow; auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/ - auto finger = touchData[touchIdIndex + (touchStep * i)] >> 4; - auto pressure = touchData[touchXYIndex + (touchStep * i)]; - auto area = touchData[touchMiscIndex + (touchStep * i)] >> 4; + //auto finger = touchData[touchIdIndex + (touchStep * i)] >> 4; + //auto pressure = touchData[touchXYIndex + (touchStep * i)]; + //auto area = touchData[touchMiscIndex + (touchStep * i)] >> 4; info.x = x; info.y = y; @@ -89,7 +89,6 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { // case Gestures::LongPress: NRF_LOG_INFO("Gesture : Long press"); break; // default : NRF_LOG_INFO("Unknown"); break; // } - } diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp index 8087d386..8d36b9cd 100644 --- a/src/drivers/SpiMaster.cpp +++ b/src/drivers/SpiMaster.cpp @@ -117,8 +117,6 @@ void SpiMaster::OnEndEvent() { spiBaseAddress->TASKS_START = 1; } else { - uint8_t* buffer = nullptr; - size_t size = 0; if(taskToNotify != nullptr) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; vTaskNotifyGiveFromISR(taskToNotify, &xHigherPriorityTaskWoken); diff --git a/src/graphics.cpp b/src/graphics.cpp index 3b53703c..b8376d6d 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -103,10 +103,10 @@ void Process(void* instance) { static constexpr uint32_t screenWidth = 240; static constexpr uint32_t screenWidthInBytes = screenWidth*2; // LCD display 16bits color (1 pixel = 2 bytes) 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(displayLineBuffer), screenWidth); spiNorFlash.Read((line*screenWidthInBytes)+screenWidth, reinterpret_cast(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]); } } diff --git a/src/libs/mynewt-nimble/nimble/host/src/ble_gap.c b/src/libs/mynewt-nimble/nimble/host/src/ble_gap.c index be4a1cb3..e32482e6 100644 --- a/src/libs/mynewt-nimble/nimble/host/src/ble_gap.c +++ b/src/libs/mynewt-nimble/nimble/host/src/ble_gap.c @@ -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); } + /* // NRF LOG support max 6 params in log 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 " "max_ce_len=%d own_addr_type=%d", params->scan_itvl, params->scan_window, params->itvl_min, params->itvl_max, params->latency, params->supervision_timeout, params->min_ce_len, params->max_ce_len, own_addr_type); + */ } #endif From 1e1bb1c6b7d7fdf6299c97bc11555b08f034f324 Mon Sep 17 00:00:00 2001 From: JF Date: Mon, 17 Aug 2020 16:48:12 +0200 Subject: [PATCH 2/2] Build lvgl, nimble and nrf sdk as static libs. This allows to specify custom build param and to remove warnings from these libs. This also speeds up the build of the whole project as those libs are now built once for the 3 targets. --- src/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b48b8510..d5b4e1be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -363,11 +363,6 @@ list(APPEND SOURCE_FILES FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis.c - ${TINYCRYPT_SRC} - ${NIMBLE_SRC} - ${LVGL_SRC} - #${IMAGE_FILES} - ${SDK_SOURCE_FILES} DisplayApp/LittleVgl.cpp DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c @@ -378,8 +373,6 @@ list(APPEND SOURCE_FILES ) list(APPEND GRAPHICS_SOURCE_FILES - ${SDK_SOURCE_FILES} - # FreeRTOS FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c @@ -564,10 +557,47 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") 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 + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -O0> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$: -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 + $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$: -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 + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$: -MP -MD -std=c99 -x assembler-with-cpp> + ) + # Build autonomous binary (without support for bootloader) set(EXECUTABLE_NAME "pinetime-app") set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld") add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl) target_compile_options(${EXECUTABLE_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> @@ -596,6 +626,7 @@ set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app") set(EXECUTABLE_MCUBOOT_WITH_BOOTLOADER_NAME "pinetime-mcuboot-app-wth-bootloader") set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld") add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl) target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> @@ -622,6 +653,7 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} # Build binary that writes the graphic assets for the bootloader set(EXECUTABLE_GRAPHICS_NAME "pinetime-graphics") add_executable(${EXECUTABLE_GRAPHICS_NAME} ${GRAPHICS_SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_GRAPHICS_NAME} nrf-sdk) target_compile_options(${EXECUTABLE_GRAPHICS_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3>