This commit is contained in:
Joaquim 2021-02-01 12:14:49 +00:00
parent ccd423bcef
commit a4361de0cf
12 changed files with 14 additions and 242 deletions

View File

@ -319,7 +319,6 @@ set(LVGL_SRC
libs/lvgl/src/lv_widgets/lv_cont.c libs/lvgl/src/lv_widgets/lv_cont.c
libs/lvgl/src/lv_widgets/lv_cpicker.c libs/lvgl/src/lv_widgets/lv_cpicker.c
libs/lvgl/src/lv_widgets/lv_dropdown.c libs/lvgl/src/lv_widgets/lv_dropdown.c
libs/lvgl/src/lv_widgets/lv_gauge.c
libs/lvgl/src/lv_widgets/lv_img.c libs/lvgl/src/lv_widgets/lv_img.c
libs/lvgl/src/lv_widgets/lv_imgbtn.c libs/lvgl/src/lv_widgets/lv_imgbtn.c
libs/lvgl/src/lv_widgets/lv_keyboard.c libs/lvgl/src/lv_widgets/lv_keyboard.c
@ -472,11 +471,8 @@ list(APPEND SOURCE_FILES
displayapp/screens/Clock.cpp displayapp/screens/Clock.cpp
displayapp/screens/Tile.cpp displayapp/screens/Tile.cpp
displayapp/screens/Meter.cpp displayapp/screens/Meter.cpp
#displayapp/screens/Gauge.cpp
displayapp/screens/InfiniPaint.cpp displayapp/screens/InfiniPaint.cpp
displayapp/screens/Paddle.cpp displayapp/screens/Paddle.cpp
#displayapp/screens/DropDownDemo.cpp
displayapp/screens/Modal.cpp
displayapp/screens/BatteryIcon.cpp displayapp/screens/BatteryIcon.cpp
displayapp/screens/BleIcon.cpp displayapp/screens/BleIcon.cpp
displayapp/screens/NotificationIcon.cpp displayapp/screens/NotificationIcon.cpp
@ -567,11 +563,9 @@ set(INCLUDE_FILES
displayapp/screens/Clock.h displayapp/screens/Clock.h
displayapp/screens/Tile.h displayapp/screens/Tile.h
displayapp/screens/Meter.h displayapp/screens/Meter.h
displayapp/screens/Gauge.h
displayapp/screens/InfiniPaint.h displayapp/screens/InfiniPaint.h
displayapp/screens/Paddle.h displayapp/screens/Paddle.h
displayapp/screens/DropDownDemo.h displayapp/screens/DropDownDemo.h
displayapp/screens/Modal.h
displayapp/screens/BatteryIcon.h displayapp/screens/BatteryIcon.h
displayapp/screens/BleIcon.h displayapp/screens/BleIcon.h
displayapp/screens/NotificationIcon.h displayapp/screens/NotificationIcon.h

View File

@ -2,6 +2,6 @@
namespace Pinetime { namespace Pinetime {
namespace Applications { namespace Applications {
enum class Apps {None, Launcher, Clock, SysInfo, Meter, Gauge, Brightness, Music, FirmwareValidation, Paint, Paddle, Notifications, Twos, HeartRate, Navigation}; enum class Apps {None, Launcher, Clock, SysInfo, Meter, Brightness, Music, FirmwareValidation, Paint, Paddle, Notifications, Twos, HeartRate, Navigation};
} }
} }

View File

@ -10,7 +10,6 @@
#include "displayapp/screens/Clock.h" #include "displayapp/screens/Clock.h"
#include "displayapp/screens/FirmwareUpdate.h" #include "displayapp/screens/FirmwareUpdate.h"
#include "displayapp/screens/FirmwareValidation.h" #include "displayapp/screens/FirmwareValidation.h"
#include "displayapp/screens/Gauge.h"
#include "displayapp/screens/InfiniPaint.h" #include "displayapp/screens/InfiniPaint.h"
#include "displayapp/screens/Paddle.h" #include "displayapp/screens/Paddle.h"
#include "displayapp/screens/Meter.h" #include "displayapp/screens/Meter.h"
@ -46,7 +45,6 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
heartRateController{heartRateController} { heartRateController{heartRateController} {
msgQueue = xQueueCreate(queueSize, itemSize); msgQueue = xQueueCreate(queueSize, itemSize);
onClockApp = true; onClockApp = true;
modal.reset(new Screens::Modal(this));
} }
void DisplayApp::Start() { void DisplayApp::Start() {
@ -111,7 +109,6 @@ void DisplayApp::Refresh() {
state = States::Running; state = States::Running;
break; break;
case Messages::UpdateDateTime: case Messages::UpdateDateTime:
// modal->Show();
break; break;
case Messages::UpdateBleConnection: case Messages::UpdateBleConnection:
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : Screens::Clock::BleConnectionStates::NotConnected); // clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : Screens::Clock::BleConnectionStates::NotConnected);
@ -204,13 +201,9 @@ void DisplayApp::RunningState() {
currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager, heartRateController)); currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager, heartRateController));
onClockApp = true; onClockApp = true;
break; break;
// case Apps::Test: currentScreen.reset(new Screens::Message(this)); break;
case Apps::SysInfo: currentScreen.reset(new Screens::SystemInfo(this, dateTimeController, batteryController, brightnessController, bleController, watchdog)); break; case Apps::SysInfo: currentScreen.reset(new Screens::SystemInfo(this, dateTimeController, batteryController, brightnessController, bleController, watchdog)); break;
case Apps::Meter: currentScreen.reset(new Screens::Meter(this)); break; case Apps::Meter: currentScreen.reset(new Screens::Meter(this)); break;
case Apps::Twos: currentScreen.reset(new Screens::Twos(this)); break; case Apps::Twos: currentScreen.reset(new Screens::Twos(this)); break;
//case Apps::Gauge: currentScreen.reset(new Screens::Gauge(this)); break;
case Apps::Paint: currentScreen.reset(new Screens::InfiniPaint(this, lvgl)); break; case Apps::Paint: currentScreen.reset(new Screens::InfiniPaint(this, lvgl)); break;
case Apps::Paddle: currentScreen.reset(new Screens::Paddle(this, lvgl)); break; case Apps::Paddle: currentScreen.reset(new Screens::Paddle(this, lvgl)); break;
case Apps::Brightness : currentScreen.reset(new Screens::Brightness(this, brightnessController)); break; case Apps::Brightness : currentScreen.reset(new Screens::Brightness(this, brightnessController)); break;

View File

@ -9,7 +9,7 @@
#include "TouchEvents.h" #include "TouchEvents.h"
#include "components/brightness/BrightnessController.h" #include "components/brightness/BrightnessController.h"
#include "components/firmwarevalidator/FirmwareValidator.h" #include "components/firmwarevalidator/FirmwareValidator.h"
#include "displayapp/screens/Modal.h" #include "displayapp/screens/Screen.h"
namespace Pinetime { namespace Pinetime {
@ -85,7 +85,6 @@ namespace Pinetime {
Apps nextApp = Apps::None; Apps nextApp = Apps::None;
bool onClockApp = false; // TODO find a better way to know that we should handle gestures and button differently for the Clock app. bool onClockApp = false; // TODO find a better way to know that we should handle gestures and button differently for the Clock app.
Controllers::BrightnessController brightnessController; Controllers::BrightnessController brightnessController;
std::unique_ptr<Screens::Modal> modal;
Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::FirmwareValidator validator; Pinetime::Controllers::FirmwareValidator validator;
TouchModes touchMode = TouchModes::Gestures; TouchModes touchMode = TouchModes::Gestures;

View File

@ -8,11 +8,14 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp *app) : Screen(app), ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp *app) :
Screen(app),
screens{app, { screens{app, {
[this]() -> std::unique_ptr<Screen> { return CreateScreen1(); }, [this]() -> std::unique_ptr<Screen> { return CreateScreen2(); }, [this]() -> std::unique_ptr<Screen> { return CreateScreen1(); },
[this]() -> std::unique_ptr<Screen> { return CreateScreen2(); },
//[this]() -> std::unique_ptr<Screen> { return CreateScreen3(); } //[this]() -> std::unique_ptr<Screen> { return CreateScreen3(); }
}} }
}
{ {
} }
@ -72,7 +75,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen3()
{ {
std::array<Screens::Tile::Applications, 6> applications{ std::array<Screens::Tile::Applications, 6> applications{
{{"A", Apps::Meter}, {{"A", Apps::Meter},
{"B", Apps::Gauge}, {"B", Apps::None},
{"C", Apps::Clock}, {"C", Apps::Clock},
{"D", Apps::Music}, {"D", Apps::Music},
{"E", Apps::SysInfo}, {"E", Apps::SysInfo},

View File

@ -1,60 +0,0 @@
#include "Gauge.h"
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
Gauge::Gauge(Pinetime::Applications::DisplayApp *app) : Screen(app) {
/*Create a style*/
// ##joaquimorg to FIX
//lv_style_copy(&style, &lv_style_pretty_color);
//style.body.main_color = LV_COLOR_CYAN; /*Line color at the beginning*/
//style.body.grad_color = LV_COLOR_RED; /*Line color at the end*/
//style.body.padding.left = 10; /*Scale line length*/
//style.body.padding.inner = 8 ; /*Scale label padding*/
//style.body.border.color = lv_color_hex3(0x333); /*Needle middle circle color*/
//style.line.width = 3;
//style.text.color = LV_COLOR_WHITE;
//style.line.color = LV_COLOR_RED; /*Line color after the critical value*/
/*Describe the color for the needles*/
needle_colors[0] = LV_COLOR_ORANGE;
/*Create a gauge*/
gauge1 = lv_gauge_create(lv_scr_act(), nullptr);
// ##joaquimorg to FIX
//lv_gauge_set_style(gauge1, LV_GAUGE_STYLE_MAIN, &style);
lv_gauge_set_needle_count(gauge1, 1, needle_colors);
lv_obj_set_size(gauge1, 180, 180);
lv_obj_align(gauge1, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_gauge_set_scale(gauge1, 360, 60, 0);
lv_gauge_set_range(gauge1, 0, 59);
/*Set the values*/
lv_gauge_set_value(gauge1, 0, value);
}
Gauge::~Gauge() {
lv_obj_clean(lv_scr_act());
}
bool Gauge::Refresh() {
// lv_lmeter_set_value(lmeter, value++); /*Set the current value*/
// if(value>=60) value = 0;
lv_gauge_set_value(gauge1, 0, value++);
if(value == 59) value = 0;
return running;
}
bool Gauge::OnButtonPushed() {
running = false;
return true;
}

View File

@ -1,30 +0,0 @@
#pragma once
#include <cstdint>
#include "Screen.h"
#include <lvgl/lvgl.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
class Gauge : public Screen{
public:
Gauge(DisplayApp* app);
~Gauge() override;
bool Refresh() override;
bool OnButtonPushed() override;
private:
lv_style_t style;
lv_color_t needle_colors[3];
lv_obj_t * gauge1;
uint32_t value=30;
bool running = true;
};
}
}
}

View File

@ -1,85 +0,0 @@
#include "Modal.h"
#include <lvgl/lvgl.h>
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
Modal::Modal(Pinetime::Applications::DisplayApp *app) : Screen(app) {
}
Modal::~Modal() {
lv_obj_clean(lv_scr_act());
}
bool Modal::Refresh() {
return running;
}
bool Modal::OnButtonPushed() {
running = false;
return true;
}
void Modal::Hide() {
/* Delete the parent modal background */
lv_obj_del_async(lv_obj_get_parent(mbox));
mbox = NULL; /* happens before object is actually deleted! */
isVisible = false;
}
void Modal::mbox_event_cb(lv_obj_t *obj, lv_event_t evt) {
auto* m = static_cast<Modal *>(obj->user_data);
m->OnEvent(obj, evt);
}
void Modal::OnEvent(lv_obj_t *event_obj, lv_event_t evt) {
if(evt == LV_EVENT_DELETE && event_obj == mbox) {
Hide();
} else if(evt == LV_EVENT_VALUE_CHANGED) {
/* A button was clicked */
lv_msgbox_start_auto_close(mbox, 0);
// Hide();
}
}
void Modal::Show(const char* msg) {
if(isVisible) return;
isVisible = true;
// ##joaquimorg to FIX
/*lv_style_copy(&modal_style, &lv_style_plain_color);
modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK;
modal_style.body.opa = LV_OPA_50;*/
obj = lv_obj_create(lv_scr_act(), nullptr);
// ##joaquimorg to FIX
//lv_obj_set_style(obj, &modal_style);
lv_obj_set_pos(obj, 0, 0);
lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES);
// ##joaquimorg to FIX
//lv_obj_set_opa_scale_enable(obj, true); /* Enable opacity scaling for the animation */
static const char * btns2[] = {"Ok", ""};
/* Create the message box as a child of the modal background */
mbox = lv_msgbox_create(obj, nullptr);
lv_msgbox_add_btns(mbox, btns2);
lv_msgbox_set_text(mbox, msg);
lv_obj_align(mbox, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(mbox, Modal::mbox_event_cb);
mbox->user_data = this;
/* Fade the message box in with an animation */
// ##joaquimorg to FIX
/*lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_time(&a, 500, 0);
lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER);
lv_anim_set_exec_cb(&a, obj, (lv_anim_exec_xcb_t)lv_obj_set_opa_scale);
lv_anim_create(&a);*/
}

View File

@ -1,36 +0,0 @@
#pragma once
#include "Screen.h"
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
class Modal : public Screen{
public:
Modal(DisplayApp* app);
~Modal() override;
void Show(const char* msg);
void Hide();
bool Refresh() override;
bool OnButtonPushed() override;
static void mbox_event_cb(lv_obj_t *obj, lv_event_t evt);
private:
void OnEvent(lv_obj_t *event_obj, lv_event_t evt);
lv_style_t modal_style;
lv_obj_t *obj;
lv_obj_t *mbox;
lv_obj_t *info;
bool running = true;
bool isVisible = false;
};
}
}
}

View File

@ -21,9 +21,6 @@ Tile::Tile(DisplayApp* app, std::array<Applications, 6>& applications) : Screen(
} }
} }
// ????
//modal.reset(new Modal(app));
btnm1 = lv_btnmatrix_create(lv_scr_act(), nullptr); btnm1 = lv_btnmatrix_create(lv_scr_act(), nullptr);
lv_btnmatrix_set_map(btnm1, btnm_map1); lv_btnmatrix_set_map(btnm1, btnm_map1);
lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES); lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES);

View File

@ -3,7 +3,6 @@
#include <lvgl/lvgl.h> #include <lvgl/lvgl.h>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include "Modal.h"
#include "Screen.h" #include "Screen.h"
#include "../Apps.h" #include "../Apps.h"
@ -29,8 +28,6 @@ namespace Pinetime {
lv_obj_t * btnm1; lv_obj_t * btnm1;
bool running = true; bool running = true;
std::unique_ptr<Modal> modal;
const char* btnm_map1[8]; const char* btnm_map1[8];
Pinetime::Applications::Apps apps[6]; Pinetime::Applications::Apps apps[6];
}; };

@ -1 +1 @@
Subproject commit bd42ffeadb44df5dee6b7a92aeb93e3ef1d2a1f8 Subproject commit a17cad009b3ea6e7709a33bbd1c73afaada86892