Fix most of the warnings. Remaining warnings come from nimble source code.

This commit is contained in:
JF 2020-08-17 16:31:00 +02:00
parent 18686ac2cb
commit 83f6d7d81b
27 changed files with 59 additions and 224 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
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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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} {
}

View File

@ -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 },

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

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

View File

@ -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,

View File

@ -6,10 +6,6 @@
#include <drivers/St7789.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 Components {
class LittleVgl {

View File

@ -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<int>(minute));
char hoursChar[3];
sprintf(hoursChar, "%02d", hour);
sprintf(hoursChar, "%02d", static_cast<int>(hour));
char timeStr[6];
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);
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);

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 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";
}
}
}

View File

@ -49,6 +49,7 @@ std::unique_ptr<Screen> 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<Screen> 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<Screen> SystemInfo::CreateScreen1() {
"Last reset: %s\n",
Version::Major(), Version::Minor(), Version::Patch(),
__DATE__, __TIME__,
dateTimeController.Day(), dateTimeController.Month(), dateTimeController.Year(),
dateTimeController.Day(), static_cast<uint8_t>(dateTimeController.Month()), dateTimeController.Year(),
dateTimeController.Hours(), dateTimeController.Minutes(), dateTimeController.Seconds(),
uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds,
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) {
auto* tile = static_cast<Tile*>(obj->user_data);
if(event == LV_EVENT_VALUE_CHANGED) {
app->StartApp(apps[buttonId]);
running = false;

View File

@ -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,

View File

@ -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;

View File

@ -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;
// }
}

View File

@ -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);

View File

@ -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<uint8_t *>(displayLineBuffer), 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]);
}
}

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);
}
/* // 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