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

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