summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2021-01-04 18:56:56 (GMT)
committerGitea <gitea@fake.local>2021-01-04 18:56:56 (GMT)
commit1d940af924bac5728a4d494f780e298e5b67b707 (patch)
tree24540888f3d038ca3c88a0789b63faa8ac07d631 /src/displayapp/screens
parent04abc91f157f5925ffa404728291a69893acf8cf (diff)
parent50ae0ae5e073ac48652e6c26549f9b19655e8da3 (diff)
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/ApplicationList.cpp14
-rw-r--r--src/displayapp/screens/ApplicationList.h7
-rw-r--r--src/displayapp/screens/BatteryIcon.cpp1
-rw-r--r--src/displayapp/screens/BatteryIcon.h2
-rw-r--r--src/displayapp/screens/Brightness.cpp2
-rw-r--r--src/displayapp/screens/Brightness.h5
-rw-r--r--src/displayapp/screens/Clock.cpp15
-rw-r--r--src/displayapp/screens/Clock.h20
-rw-r--r--src/displayapp/screens/DropDownDemo.cpp4
-rw-r--r--src/displayapp/screens/DropDownDemo.h6
-rw-r--r--src/displayapp/screens/FirmwareUpdate.cpp3
-rw-r--r--src/displayapp/screens/FirmwareUpdate.h11
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp8
-rw-r--r--src/displayapp/screens/FirmwareValidation.h5
-rw-r--r--src/displayapp/screens/Gauge.cpp1
-rw-r--r--src/displayapp/screens/Gauge.h4
-rw-r--r--src/displayapp/screens/InfiniPaint.cpp3
-rw-r--r--src/displayapp/screens/InfiniPaint.h23
-rw-r--r--src/displayapp/screens/Label.cpp1
-rw-r--r--src/displayapp/screens/Label.h1
-rw-r--r--src/displayapp/screens/Meter.cpp2
-rw-r--r--src/displayapp/screens/Meter.h6
-rw-r--r--src/displayapp/screens/Modal.cpp2
-rw-r--r--src/displayapp/screens/Modal.h7
-rw-r--r--src/displayapp/screens/Music.cpp8
-rw-r--r--src/displayapp/screens/Music.h20
-rw-r--r--src/displayapp/screens/Notifications.cpp4
-rw-r--r--src/displayapp/screens/Notifications.h9
-rw-r--r--src/displayapp/screens/Paddle.cpp190
-rw-r--r--src/displayapp/screens/Paddle.h52
-rw-r--r--src/displayapp/screens/ScreenList.h6
-rw-r--r--src/displayapp/screens/Symbols.h4
-rw-r--r--src/displayapp/screens/SystemInfo.cpp30
-rw-r--r--src/displayapp/screens/SystemInfo.h23
-rw-r--r--src/displayapp/screens/Tab.cpp67
-rw-r--r--src/displayapp/screens/Tab.h23
-rw-r--r--src/displayapp/screens/Tile.cpp8
-rw-r--r--src/displayapp/screens/Tile.h8
-rw-r--r--src/displayapp/screens/Twos.cpp271
-rw-r--r--src/displayapp/screens/Twos.h34
40 files changed, 675 insertions, 235 deletions
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp
index 7eb9718..0b8face 100644
--- a/src/displayapp/screens/ApplicationList.cpp
+++ b/src/displayapp/screens/ApplicationList.cpp
@@ -1,9 +1,10 @@
-#include <libs/lvgl/lvgl.h>
-#include <displayapp/DisplayApp.h>
-#include <functional>
#include "ApplicationList.h"
-#include "Tile.h"
+#include <lvgl/lvgl.h>
+#include <array>
#include "Symbols.h"
+#include "Tile.h"
+#include "displayapp/Apps.h"
+#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
@@ -59,8 +60,8 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
{Symbols::asterisk, Apps::Meter},
{Symbols::paintbrush, Apps::Paint},
{Symbols::info, Apps::Notifications},
- {Symbols::none, Apps::None},
- {Symbols::none, Apps::None}
+ {Symbols::paddle, Apps::Paddle},
+ {"2", Apps::Twos}
}
};
@@ -80,3 +81,4 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen3() {
return std::unique_ptr<Screen>(new Screens::Tile(app, applications));
}
+
diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h
index 9c95acb..aefb238 100644
--- a/src/displayapp/screens/ApplicationList.h
+++ b/src/displayapp/screens/ApplicationList.h
@@ -1,14 +1,9 @@
#pragma once
-#include <functional>
-#include <vector>
+#include <memory>
-#include "components/ble/NimbleController.h"
#include "Screen.h"
-#include "Label.h"
#include "ScreenList.h"
-#include "Gauge.h"
-#include "Meter.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp
index 26939d1..4c10247 100644
--- a/src/displayapp/screens/BatteryIcon.cpp
+++ b/src/displayapp/screens/BatteryIcon.cpp
@@ -1,5 +1,6 @@
#include "BatteryIcon.h"
#include "Symbols.h"
+
using namespace Pinetime::Applications::Screens;
const char* BatteryIcon::GetBatteryIcon(float batteryPercent) {
diff --git a/src/displayapp/screens/BatteryIcon.h b/src/displayapp/screens/BatteryIcon.h
index 58f04a8..f100192 100644
--- a/src/displayapp/screens/BatteryIcon.h
+++ b/src/displayapp/screens/BatteryIcon.h
@@ -1,7 +1,5 @@
#pragma once
-#include <libs/lvgl/src/lv_draw/lv_img_decoder.h>
-
namespace Pinetime {
namespace Applications {
namespace Screens {
diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp
index 8ea9a77..c8085be 100644
--- a/src/displayapp/screens/Brightness.cpp
+++ b/src/displayapp/screens/Brightness.cpp
@@ -1,5 +1,5 @@
-#include <libs/lvgl/lvgl.h>
#include "Brightness.h"
+#include <lvgl/lvgl.h>
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/Brightness.h b/src/displayapp/screens/Brightness.h
index 7d599ac..7aee968 100644
--- a/src/displayapp/screens/Brightness.h
+++ b/src/displayapp/screens/Brightness.h
@@ -1,8 +1,9 @@
#pragma once
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include "components/brightness/BrightnessController.h"
+#include <lvgl/src/lv_core/lv_obj.h>
+#include <cstdint>
#include "Screen.h"
+#include "components/brightness/BrightnessController.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 977321c1..5765914 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -1,15 +1,16 @@
-#include <cstdio>
-
-#include <libs/date/includes/date/date.h>
-#include "components/datetime/DateTimeController.h"
-#include <libs/lvgl/lvgl.h>
#include "Clock.h"
-#include "../DisplayApp.h"
+
+#include <date/date.h>
+#include <lvgl/lvgl.h>
+#include <cstdio>
#include "BatteryIcon.h"
#include "BleIcon.h"
+#include "NotificationIcon.h"
#include "Symbols.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h"
-#include "NotificationIcon.h"
+#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index 58149a7..4c5f60a 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -1,17 +1,19 @@
#pragma once
-#include <cstdint>
+#include <lvgl/src/lv_core/lv_obj.h>
#include <chrono>
-
+#include <cstdint>
+#include <memory>
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include "components/ble/NotificationManager.h"
-#include "components/battery/BatteryController.h"
-#include "components/ble/BleController.h"
+#include "components/datetime/DateTimeController.h"
namespace Pinetime {
+ namespace Controllers {
+ class Battery;
+ class Ble;
+ class NotificationManager;
+ }
+
namespace Applications {
namespace Screens {
@@ -34,7 +36,7 @@ namespace Pinetime {
T value;
bool isUpdated = true;
};
- class Clock : public Screen{
+ class Clock : public Screen {
public:
Clock(DisplayApp* app,
Controllers::DateTime& dateTimeController,
diff --git a/src/displayapp/screens/DropDownDemo.cpp b/src/displayapp/screens/DropDownDemo.cpp
index ce3acd5..37728e1 100644
--- a/src/displayapp/screens/DropDownDemo.cpp
+++ b/src/displayapp/screens/DropDownDemo.cpp
@@ -1,6 +1,6 @@
-#include <libs/lvgl/lvgl.h>
-#include <libraries/log/nrf_log.h>
#include "DropDownDemo.h"
+#include <lvgl/lvgl.h>
+#include <libraries/log/nrf_log.h>
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/DropDownDemo.h b/src/displayapp/screens/DropDownDemo.h
index 7c75efc..d66aeed 100644
--- a/src/displayapp/screens/DropDownDemo.h
+++ b/src/displayapp/screens/DropDownDemo.h
@@ -2,15 +2,13 @@
#include <cstdint>
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
- class DropDownDemo : public Screen{
+ class DropDownDemo : public Screen {
public:
DropDownDemo(DisplayApp* app);
~DropDownDemo() override;
diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp
index 778409e..b9f891d 100644
--- a/src/displayapp/screens/FirmwareUpdate.cpp
+++ b/src/displayapp/screens/FirmwareUpdate.cpp
@@ -1,5 +1,6 @@
-#include <libs/lvgl/lvgl.h>
#include "FirmwareUpdate.h"
+#include <lvgl/lvgl.h>
+#include "components/ble/BleController.h"
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h
index 893fe68..262e7af 100644
--- a/src/displayapp/screens/FirmwareUpdate.h
+++ b/src/displayapp/screens/FirmwareUpdate.h
@@ -1,15 +1,12 @@
#pragma once
-#include <cstdint>
-#include <chrono>
-
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include "components/ble/BleController.h"
+#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
+ namespace Controllers {
+ class Ble;
+ }
namespace Applications {
namespace Screens {
diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp
index 4ac399f..d4165dc 100644
--- a/src/displayapp/screens/FirmwareValidation.cpp
+++ b/src/displayapp/screens/FirmwareValidation.cpp
@@ -1,8 +1,8 @@
-#include <libs/lvgl/lvgl.h>
#include "FirmwareValidation.h"
-#include "../DisplayApp.h"
-#include "../../Version.h"
+#include <lvgl/lvgl.h>
+#include "Version.h"
#include "components/firmwarevalidator/FirmwareValidator.h"
+#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
@@ -87,5 +87,3 @@ void FirmwareValidation::OnButtonEvent(lv_obj_t *object, lv_event_t event) {
}
}
-
-
diff --git a/src/displayapp/screens/FirmwareValidation.h b/src/displayapp/screens/FirmwareValidation.h
index 947f557..9eea86b 100644
--- a/src/displayapp/screens/FirmwareValidation.h
+++ b/src/displayapp/screens/FirmwareValidation.h
@@ -1,10 +1,7 @@
#pragma once
-#include <cstdint>
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Controllers {
diff --git a/src/displayapp/screens/Gauge.cpp b/src/displayapp/screens/Gauge.cpp
index 81c283c..1b9f2c6 100644
--- a/src/displayapp/screens/Gauge.cpp
+++ b/src/displayapp/screens/Gauge.cpp
@@ -1,4 +1,3 @@
-#include <libs/lvgl/lvgl.h>
#include "Gauge.h"
#include "../DisplayApp.h"
diff --git a/src/displayapp/screens/Gauge.h b/src/displayapp/screens/Gauge.h
index 03c06be..2a6b8f8 100644
--- a/src/displayapp/screens/Gauge.h
+++ b/src/displayapp/screens/Gauge.h
@@ -2,9 +2,7 @@
#include <cstdint>
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include <lvgl/lvgl.h>
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp
index 3ea75e9..65be662 100644
--- a/src/displayapp/screens/InfiniPaint.cpp
+++ b/src/displayapp/screens/InfiniPaint.cpp
@@ -1,7 +1,6 @@
-#include <libs/lvgl/lvgl.h>
-#include <libraries/log/nrf_log.h>
#include "InfiniPaint.h"
#include "../DisplayApp.h"
+#include "../LittleVgl.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h
index f29135d..9a7ac07 100644
--- a/src/displayapp/screens/InfiniPaint.h
+++ b/src/displayapp/screens/InfiniPaint.h
@@ -1,31 +1,30 @@
#pragma once
+#include <lvgl/lvgl.h>
#include <cstdint>
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include <drivers/St7789.h>
-#include "displayapp/LittleVgl.h"
namespace Pinetime {
+ namespace Components {
+ class LittleVgl;
+ }
namespace Applications {
namespace Screens {
-
+
class InfiniPaint : public Screen {
public:
InfiniPaint(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
-
+
~InfiniPaint() override;
-
+
bool Refresh() override;
-
+
bool OnButtonPushed() override;
-
+
bool OnTouchEvent(TouchEvents event) override;
-
+
bool OnTouchEvent(uint16_t x, uint16_t y) override;
-
+
private:
Pinetime::Components::LittleVgl& lvgl;
static constexpr uint16_t width = 10;
diff --git a/src/displayapp/screens/Label.cpp b/src/displayapp/screens/Label.cpp
index 540776c..4be7742 100644
--- a/src/displayapp/screens/Label.cpp
+++ b/src/displayapp/screens/Label.cpp
@@ -1,4 +1,3 @@
-#include <libs/lvgl/lvgl.h>
#include "Label.h"
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/Label.h b/src/displayapp/screens/Label.h
index 3e7b379..dba89bb 100644
--- a/src/displayapp/screens/Label.h
+++ b/src/displayapp/screens/Label.h
@@ -1,6 +1,5 @@
#pragma once
-#include <vector>
#include "Screen.h"
#include <lvgl/lvgl.h>
diff --git a/src/displayapp/screens/Meter.cpp b/src/displayapp/screens/Meter.cpp
index 273e111..3c8e703 100644
--- a/src/displayapp/screens/Meter.cpp
+++ b/src/displayapp/screens/Meter.cpp
@@ -1,5 +1,5 @@
-#include <libs/lvgl/lvgl.h>
#include "Meter.h"
+#include <lvgl/lvgl.h>
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/Meter.h b/src/displayapp/screens/Meter.h
index ddf8be8..86888dd 100644
--- a/src/displayapp/screens/Meter.h
+++ b/src/displayapp/screens/Meter.h
@@ -1,11 +1,9 @@
#pragma once
#include <cstdint>
-#include <chrono>
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include <lvgl/src/lv_core/lv_style.h>
+#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/Modal.cpp b/src/displayapp/screens/Modal.cpp
index 29f7bfa..d1a110e 100644
--- a/src/displayapp/screens/Modal.cpp
+++ b/src/displayapp/screens/Modal.cpp
@@ -1,5 +1,5 @@
-#include <libs/lvgl/lvgl.h>
#include "Modal.h"
+#include <lvgl/lvgl.h>
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/Modal.h b/src/displayapp/screens/Modal.h
index c616c29..9cc177f 100644
--- a/src/displayapp/screens/Modal.h
+++ b/src/displayapp/screens/Modal.h
@@ -1,11 +1,8 @@
#pragma once
-#include <cstdint>
-#include <chrono>
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include <lvgl/src/lv_core/lv_style.h>
+#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index 225a15a..c4ae3ac 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -15,9 +15,13 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#include <libs/lvgl/lvgl.h>
-
#include "Music.h"
+#include <cstdint>
+#include "../DisplayApp.h"
+#include "components/ble/MusicService.h"
+#include "displayapp/icons/music/disc.cpp"
+#include "displayapp/icons/music/disc_f_1.cpp"
+#include "displayapp/icons/music/disc_f_2.cpp"
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index 81ba793..66bde21 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -17,24 +17,16 @@
*/
#pragma once
-#include <cstdint>
-#include <chrono>
+#include <FreeRTOS.h>
+#include <lvgl/src/lv_core/lv_obj.h>
#include <string>
-
-#include "components/gfx/Gfx.h"
-#include "components/battery/BatteryController.h"
-#include "components/ble/BleController.h"
-#include "components/ble/MusicService.h"
#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include "../../Version.h"
-#include "displayapp/icons/music/disc.cpp"
-#include "displayapp/icons/music/disc_f_1.cpp"
-#include "displayapp/icons/music/disc_f_2.cpp"
namespace Pinetime {
+ namespace Controllers {
+ class MusicService;
+ }
+
namespace Applications {
namespace Screens {
class Music : public Screen {
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 85848b2..51a601c 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -1,7 +1,5 @@
-#include <libs/lvgl/lvgl.h>
-#include <displayapp/DisplayApp.h>
-#include <functional>
#include "Notifications.h"
+#include <displayapp/DisplayApp.h>
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index fb4e1ef..f5c6a86 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -1,11 +1,10 @@
#pragma once
-#include <functional>
-#include <vector>
-
+#include <lvgl/lvgl.h>
+#include <cstdint>
+#include <memory>
#include "Screen.h"
-#include "ScreenList.h"
-
+#include "components/ble/NotificationManager.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp
new file mode 100644
index 0000000..9a04b3b
--- /dev/null
+++ b/src/displayapp/screens/Paddle.cpp
@@ -0,0 +1,190 @@
+#include "Paddle.h"
+#include "../DisplayApp.h"
+#include "../LittleVgl.h"
+
+using namespace Pinetime::Applications::Screens;
+extern lv_font_t jetbrains_mono_extrabold_compressed;
+extern lv_font_t jetbrains_mono_bold_20;
+
+namespace{
+const uint8_t paddle_map[] = {
+ 0xfc, 0xfe, 0xfc, 0xff, /*Color of index 0*/
+ 0xff, 0xff, 0xff, 0xff, /*Color of index 1*/
+
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+};
+
+const uint8_t ball_map[] = {
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed,
+ 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed,
+ 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed,
+ 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+ 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed, 0x6f, 0xed,
+};
+}
+
+Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl{lvgl} {
+ app->SetTouchMode(DisplayApp::TouchModes::Polling);
+
+ points = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text(points, "0");
+ lv_obj_align(points, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
+
+ paddle.header.always_zero = 0;
+ paddle.header.w = 4;
+ paddle.header.h = 60;
+ paddle.data_size = 68;
+ paddle.header.cf = LV_IMG_CF_INDEXED_1BIT;
+ paddle.data = paddle_map;
+ paddle_image = lv_img_create(lv_scr_act(), nullptr);
+ lv_img_set_src(paddle_image, &paddle);
+
+ ball.header.always_zero = 0;
+ ball.header.w = 24;
+ ball.header.h = 24;
+ ball.data_size = 24 * 24 * LV_COLOR_SIZE / 8;
+ ball.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
+ ball.data = ball_map;
+ ball_image = lv_img_create(lv_scr_act(), nullptr);
+ lv_img_set_src(ball_image, &ball);
+}
+
+Paddle::~Paddle() {
+ // Reset the touchmode
+ app->SetTouchMode(DisplayApp::TouchModes::Gestures);
+ lv_obj_clean(lv_scr_act());
+}
+
+bool Paddle::Refresh() {
+ if((counter++ % 5) == 0){
+ counter = 0;
+
+ ballX += dx;
+ ballY += dy;
+
+ lv_obj_set_pos(ball_image, ballX, ballY);
+
+ //checks if it has touched the sides (floor and ceiling)
+ if(ballY <= 0 || ballY >= 215){
+ dy *= -1;
+ }
+
+ //checks if it has touched the side (left side)
+ if(ballX >= 215){
+ dx *= -1;
+ }
+
+ //checks if it is in the position of the paddle
+ if(ballY <= (paddleBottomY + 16) && ballY >= (paddleTopY - 8)){
+ if(ballX >= 0 && ballX < 4){
+ lv_obj_set_pos(ball_image, 5, ballY);
+ dx *= -1;
+ score++;
+ }
+ }
+
+ //checks if it has gone behind the paddle
+ else if(ballX <= -40){
+ ballX = 107;
+ ballY = 107;
+ score = 0;
+ }
+ sprintf(scoreStr, "%d", score);
+ lv_label_set_text(points, scoreStr);
+ }
+ return running;
+}
+
+bool Paddle::OnButtonPushed() {
+ running = false;
+ return true;
+}
+
+bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ return true;
+}
+
+bool Paddle::OnTouchEvent(uint16_t x, uint16_t y) {
+ lv_obj_set_pos(paddle_image, 0, y - 30); // sets the center paddle pos. (30px offset) with the the y_coordinate of the finger and defaults the x_coordinate to 0
+ paddleTopY = y - 30; // refreshes the upper extreme of the paddle
+ paddleBottomY = y + 30; // refreshes the lower extreme of the paddle
+ return true;
+}
diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h
new file mode 100644
index 0000000..358bd2f
--- /dev/null
+++ b/src/displayapp/screens/Paddle.h
@@ -0,0 +1,52 @@
+#pragma once
+
+#include <lvgl/lvgl.h>
+#include <cstdint>
+#include "Screen.h"
+
+namespace Pinetime {
+ namespace Components {
+ class LittleVgl;
+ }
+ namespace Applications {
+ namespace Screens {
+
+ class Paddle : public Screen{
+ public:
+ Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
+ ~Paddle() override;
+
+ bool Refresh() override;
+ bool OnButtonPushed() override;
+ bool OnTouchEvent(TouchEvents event) override;
+ bool OnTouchEvent(uint16_t x, uint16_t y) override;
+
+ private:
+ Pinetime::Components::LittleVgl& lvgl;
+
+ int paddleBottomY = 90; // bottom extreme of the paddle
+ int paddleTopY = 150; //top extreme of the paddle
+
+ int ballX = 107; // Initial x_coordinate for the ball (12px offset from the center to counteract the ball's 24px size)
+ int ballY = 107; // Initial y_coordinate for the ball
+
+ int dx = 2; // Velocity of the ball in the x_coordinate
+ int dy = 3; // Velocity of the ball in the y_coordinate
+
+ int counter = 0; // init Frame refresh limit counter
+ int score = 0;
+
+ char scoreStr[10];
+
+ lv_img_dsc_t paddle;
+ lv_img_dsc_t ball;
+
+ lv_obj_t* points;
+ lv_obj_t* paddle_image; // pointer to paddle image
+ lv_obj_t* ball_image; // pointer to ball image
+
+ bool running = true;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h
index b198634..736e363 100644
--- a/src/displayapp/screens/ScreenList.h
+++ b/src/displayapp/screens/ScreenList.h
@@ -1,10 +1,10 @@
#pragma once
-#include <vector>
+#include <array>
#include <functional>
-#include "components/ble/NimbleController.h"
+#include <memory>
#include "Screen.h"
-#include "Label.h"
+#include "../DisplayApp.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h
index aeea324..b66b5fa 100644
--- a/src/displayapp/screens/Symbols.h
+++ b/src/displayapp/screens/Symbols.h
@@ -24,7 +24,9 @@ namespace Pinetime {
static constexpr const char* tachometer = "\xEF\x8F\xBD";
static constexpr const char* asterisk = "\xEF\x81\xA9";
static constexpr const char* paintbrush = "\xEF\x87\xBC";
+ static constexpr const char* paddle = "\xEF\x91\x9D";
}
}
}
-} \ No newline at end of file
+}
+
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index 867fdae..2de5dad 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -1,9 +1,13 @@
-#include <libs/lvgl/lvgl.h>
-#include <displayapp/DisplayApp.h>
-#include <functional>
#include "SystemInfo.h"
-#include "../../Version.h"
-#include "Tile.h"
+#include <lvgl/lvgl.h>
+#include "../DisplayApp.h"
+#include "Label.h"
+#include "Version.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
+#include "components/brightness/BrightnessController.h"
+#include "components/datetime/DateTimeController.h"
+#include "drivers/Watchdog.h"
using namespace Pinetime::Applications::Screens;
@@ -43,10 +47,7 @@ bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
}
std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
- auto batteryPercentF = batteryController.PercentRemaining();
- uint16_t batteryPercent = 0;
- if(batteryPercentF > 100.0f) batteryPercent = 100;
- else if(batteryPercentF < 0.0f) batteryPercent = 0;
+ auto batteryPercent = static_cast<uint8_t>(batteryController.PercentRemaining());
uint8_t brightness = 0;
switch(brightnessController.Level()) {
@@ -83,7 +84,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
uptimeSeconds = uptimeSeconds % secondsInAMinute;
// TODO handle more than 100 days of uptime
- sprintf(t1, "Pinetime\n"
+ sprintf(t1, "InfiniTime\n"
"Version:%ld.%ld.%ld\n"
"Build: %s\n"
" %s\n"
@@ -111,6 +112,13 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
}
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
- strncpy(t3, "Hello from\nthe developer!", 27);
+ sprintf(t3, "Hello from\nthe developer!\n"
+ "Software Licensed\n"
+ "under the terms of\n"
+ "the GNU General\n"
+ "Public License v3\n"
+ "Source code:\n"
+ "https://github.com/\n"
+ " JF002/Pinetime");
return std::unique_ptr<Screen>(new Screens::Label(app, t3));
}
diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h
index 987a584..75268c7 100644
--- a/src/displayapp/screens/SystemInfo.h
+++ b/src/displayapp/screens/SystemInfo.h
@@ -1,17 +1,24 @@
#pragma once
-#include <functional>
-#include <vector>
-
-#include "components/ble/NimbleController.h"
+#include <memory>
#include "Screen.h"
-#include "Label.h"
#include "ScreenList.h"
-#include "Gauge.h"
-#include "Meter.h"
namespace Pinetime {
+ namespace Controllers {
+ class DateTime;
+ class Battery;
+ class BrightnessController;
+ class Ble;
+ }
+
+ namespace Drivers {
+ class WatchdogView;
+ }
+
namespace Applications {
+ class DisplayApp;
+
namespace Screens {
class SystemInfo : public Screen {
public:
@@ -36,7 +43,7 @@ namespace Pinetime {
char t1[200];
char t2[200];
- char t3[30];
+ char t3[200];
ScreenList<3> screens;
std::unique_ptr<Screen> CreateScreen1();
diff --git a/src/displayapp/screens/Tab.cpp b/src/displayapp/screens/Tab.cpp
deleted file mode 100644
index 44b806c..0000000
--- a/src/displayapp/screens/Tab.cpp
+++ /dev/null
@@ -1,67 +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 "Tab.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) {
-// Tile* screen = static_cast<Tile *>(obj->user_data);
-// screen->OnObjectEvent(obj, event);
-//}
-
-Tab::Tab(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) {
-/*Create a Tab view object*/
- lv_obj_t *tabview;
- tabview = lv_tabview_create(lv_scr_act(), NULL);
-
- /*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
- lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1");
- lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2");
- lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");
-
-
- /*Add content to the tabs*/
- lv_obj_t * label = lv_label_create(tab1, NULL);
- lv_label_set_text(label, "This the first tab\n\n"
- "If the content\n"
- "of a tab\n"
- "become too long\n"
- "the it \n"
- "automatically\n"
- "become\n"
- "scrollable.");
-
- label = lv_label_create(tab2, NULL);
- lv_label_set_text(label, "Second tab");
-
- label = lv_label_create(tab3, NULL);
- lv_label_set_text(label, "Third tab");
-
-}
-
-Tab::~Tab() {
- lv_obj_clean(lv_scr_act());
-}
-
-void Tab::Refresh(bool fullRefresh) {
-
-}
-
-void Tab::OnObjectEvent(lv_obj_t *obj, lv_event_t event) {
- if(event == LV_EVENT_CLICKED) {
- NRF_LOG_INFO("Clicked");
- }
- else if(event == LV_EVENT_VALUE_CHANGED) {
- NRF_LOG_INFO("Toggled");
- }
-}
diff --git a/src/displayapp/screens/Tab.h b/src/displayapp/screens/Tab.h
deleted file mode 100644
index e16dbb9..0000000
--- a/src/displayapp/screens/Tab.h
+++ /dev/null
@@ -1,23 +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 Tab : public Screen {
- public:
- explicit Tab(DisplayApp* app, Components::Gfx& gfx);
- ~Tab() override;
- void Refresh(bool fullRefresh) override;
- void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
-
- private:
-
- };
- }
- }
-}
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index 75fa6ef..c1a5e94 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -1,11 +1,5 @@
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include <libs/lvgl/src/lv_font/lv_font.h>
-#include <libs/lvgl/lvgl.h>
-
#include "Tile.h"
-#include "displayapp/DisplayApp.h"
-#include "Symbols.h"
-#include "../../Version.h"
+#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h
index cf5fcf1..7edf67b 100644
--- a/src/displayapp/screens/Tile.h
+++ b/src/displayapp/screens/Tile.h
@@ -1,11 +1,11 @@
#pragma once
+#include <lvgl/lvgl.h>
#include <cstdint>
-#include "Screen.h"
-#include <bits/unique_ptr.h>
+#include <memory>
#include "Modal.h"
-#include <lvgl/src/lv_core/lv_style.h>
-#include <displayapp/Apps.h>
+#include "Screen.h"
+#include "../Apps.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp
new file mode 100644
index 0000000..f36e35d
--- /dev/null
+++ b/src/displayapp/screens/Twos.cpp
@@ -0,0 +1,271 @@
+#include "Twos.h"
+#include <lvgl/lvgl.h>
+#include <string>
+#include <charconv>
+#include <array>
+#include <vector>
+#include <utility>
+
+using namespace Pinetime::Applications::Screens;
+
+extern lv_font_t jetbrains_mono_bold_20;
+
+Twos::Twos(Pinetime::Applications::DisplayApp *app) : Screen(app) {
+
+ // create styles to apply to different valued tiles
+ static lv_style_t style_cell1;
+ lv_style_copy(&style_cell1, &lv_style_plain);
+ style_cell1.body.border.width = 1;
+ style_cell1.text.font = &jetbrains_mono_bold_20;
+ style_cell1.body.padding.top = 16;
+ style_cell1.body.padding.bottom = 16;
+ style_cell1.body.main_color = LV_COLOR_MAKE(214, 197, 165);
+ style_cell1.body.grad_color = LV_COLOR_MAKE(214, 197, 165);
+ style_cell1.text.color = LV_COLOR_BLACK;
+
+ static lv_style_t style_cell2;
+ lv_style_copy(&style_cell2, &style_cell1);
+ style_cell2.body.main_color = LV_COLOR_MAKE(209, 146, 92);
+ style_cell2.body.grad_color = LV_COLOR_MAKE(209, 146, 92);
+ style_cell2.text.color = LV_COLOR_WHITE;
+
+ static lv_style_t style_cell3;
+ lv_style_copy(&style_cell3, &style_cell2);
+ style_cell3.body.main_color = LV_COLOR_MAKE(246, 94, 59);
+ style_cell3.body.grad_color = LV_COLOR_MAKE(246, 94, 59);
+
+ static lv_style_t style_cell4;
+ lv_style_copy(&style_cell4, &style_cell3);
+ style_cell4.body.main_color = LV_COLOR_MAKE(212, 170, 28);
+ style_cell4.body.grad_color = LV_COLOR_MAKE(212, 170, 28);
+
+ // format grid display
+ gridDisplay = lv_table_create(lv_scr_act(), nullptr);
+ lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL1, &style_cell1);
+ lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL2, &style_cell2);
+ lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL3, &style_cell3);
+ lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL4, &style_cell4);
+ lv_table_set_col_cnt(gridDisplay, 4);
+ lv_table_set_row_cnt(gridDisplay, 4);
+ lv_table_set_col_width(gridDisplay, 0, LV_HOR_RES/4);
+ lv_table_set_col_width(gridDisplay, 1, LV_HOR_RES/4);
+ lv_table_set_col_width(gridDisplay, 2, LV_HOR_RES/4);
+ lv_table_set_col_width(gridDisplay, 3, LV_HOR_RES/4);
+ lv_obj_align(gridDisplay, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+
+ // initialize grid
+ for(int row = 0; row < 4; row++) {
+ for(int col = 0; col < 4; col++) {
+ grid[row][col].value = 0;
+ lv_table_set_cell_type(gridDisplay, row, col, 2);
+ lv_table_set_cell_align(gridDisplay, row, col, LV_LABEL_ALIGN_CENTER);
+ }
+ }
+ placeNewTile();
+ placeNewTile();
+
+ // format score text
+ scoreText = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_width(scoreText, LV_HOR_RES);
+ lv_label_set_align(scoreText, LV_ALIGN_IN_LEFT_MID);
+ lv_obj_align(scoreText, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
+ lv_label_set_text(scoreText, ("Score: " + std::to_string(score)).c_str());
+}
+
+Twos::~Twos() {
+ lv_obj_clean(lv_scr_act());
+}
+
+bool Twos::Refresh() {
+ return running;
+}
+
+bool Twos::OnButtonPushed() {
+ running = false;
+ return true;
+}
+
+bool Twos::placeNewTile() {
+ std::vector< std::pair <int,int> > availableCells;
+ for(int row = 0; row < 4; row++) {
+ for(int col = 0; col < 4; col++) {
+ if(!grid[row][col].value) {
+ availableCells.push_back(std::make_pair(row, col));
+ }
+ }
+ }
+
+ if (availableCells.size() == 0) {
+ return false; // game lost
+ }
+
+ auto it = availableCells.cbegin();
+ int random = rand() % availableCells.size();
+ std::advance(it, random);
+ std::pair <int,int> newCell = *it;
+
+ if ((rand() % 100) < 90) grid[newCell.first][newCell.second].value = 2;
+ else grid[newCell.first][newCell.second].value = 4;
+ updateGridDisplay(grid);
+ return true;
+}
+
+bool Twos::tryMerge(Tile grid[][4], int &newRow, int &newCol, int oldRow, int oldCol) {
+ if((grid[newRow][newCol].value == grid[oldRow][oldCol].value)) {
+ if((newCol != oldCol) || (newRow != oldRow)) {
+ if(!grid[newRow][newCol].merged) {
+ unsigned int newVal = grid[oldRow][oldCol].value *= 2;
+ grid[newRow][newCol].value = newVal;
+ score += newVal;
+ lv_label_set_text(scoreText, ("Score: " + std::to_string(score)).c_str());
+ grid[oldRow][oldCol].value = 0;
+ grid[newRow][newCol].merged = true;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool Twos::tryMove(Tile grid[][4], int newRow, int newCol, int oldRow, int oldCol) {
+ if(((newCol >= 0) && (newCol != oldCol)) || ((newRow >= 0) && (newRow != oldRow))) {
+ grid[newRow][newCol].value = grid[oldRow][oldCol].value;
+ grid[oldRow][oldCol].value = 0;
+ return true;
+ }
+ return false;
+}
+
+bool Twos::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ bool validMove;
+ validMove = false;
+ for(int row = 0; row < 4; row++) {
+ for(int col = 0; col < 4; col++) {
+ grid[row][col].merged = false; // reinitialize merge state
+ }
+ }
+ switch(event) {
+ case TouchEvents::SwipeLeft:
+ for(int col = 1; col < 4; col++) { // ignore tiles already on far left
+ for(int row = 0; row < 4; row++) {
+ if(grid[row][col].value) {
+ int newCol = -1;
+ for(int potentialNewCol = col - 1; potentialNewCol >= 0; potentialNewCol--) {
+ if(!grid[row][potentialNewCol].value) {
+ newCol = potentialNewCol;
+ }
+ else { // blocked by another tile
+ if(tryMerge(grid, row, potentialNewCol, row, col)) validMove = true;
+ break;
+ }
+ }
+ if(tryMove(grid, row, newCol, row, col)) validMove = true;
+ }
+ }
+ }
+ if (validMove) {
+ placeNewTile();
+ }
+ return true;
+ case TouchEvents::SwipeRight:
+ for(int col = 2; col >= 0; col--) { // ignore tiles already on far right
+ for(int row = 0; row < 4; row++) {
+ if(grid[row][col].value) {
+ int newCol = -1;
+ for(int potentialNewCol = col + 1; potentialNewCol < 4; potentialNewCol++) {
+ if(!grid[row][potentialNewCol].value) {
+ newCol = potentialNewCol;
+ }
+ else { // blocked by another tile
+ if(tryMerge(grid, row, potentialNewCol, row, col)) validMove = true;
+ break;
+ }
+ }
+ if(tryMove(grid, row, newCol, row, col)) validMove = true;
+ }
+ }
+ }
+ if (validMove) {
+ placeNewTile();
+ }
+ return true;
+ case TouchEvents::SwipeUp:
+ for(int row = 1; row < 4; row++) { // ignore tiles already on top
+ for(int col = 0; col < 4; col++) {
+ if(grid[row][col].value) {
+ int newRow = -1;
+ for(int potentialNewRow = row - 1; potentialNewRow >= 0; potentialNewRow--) {
+ if(!grid[potentialNewRow][col].value) {
+ newRow = potentialNewRow;
+ }
+ else { // blocked by another tile
+ if(tryMerge(grid, potentialNewRow, col, row, col)) validMove = true;
+ break;
+ }
+ }
+ if(tryMove(grid, newRow, col, row, col)) validMove = true;
+ }
+ }
+ }
+ if (validMove) {
+ placeNewTile();
+ }
+ return true;
+ case TouchEvents::SwipeDown:
+ for(int row = 2; row >=0; row--) { // ignore tiles already on bottom
+ for(int col = 0; col < 4; col++) {
+ if(grid[row][col].value) {
+ int newRow = -1;
+ for(int potentialNewRow = row + 1; potentialNewRow < 4; potentialNewRow++) {
+ if(!grid[potentialNewRow][col].value) {
+ newRow = potentialNewRow;
+ }
+ else { // blocked by another tile
+ if(tryMerge(grid, potentialNewRow, col, row, col)) validMove = true;
+ break;
+ }
+ }
+ if(tryMove(grid, newRow, col, row, col)) validMove = true;
+ }
+ }
+ }
+ if (validMove) {
+ placeNewTile();
+ }
+ return true;
+ default:
+ return false;
+ }
+ return false;
+}
+
+void Twos::updateGridDisplay(Tile grid[][4]) {
+ for(int row = 0; row < 4; row++) {
+ for(int col = 0; col < 4; col++) {
+ if (grid[row][col].value) {
+ lv_table_set_cell_value(gridDisplay, row, col, (std::to_string(grid[row][col].value)).c_str());
+ }
+ else {
+ lv_table_set_cell_value(gridDisplay, row, col, "");
+ }
+ switch (grid[row][col].value) {
+ case 0:
+ case 2:
+ case 4:
+ lv_table_set_cell_type(gridDisplay, row, col, 1);
+ break;
+ case 8:
+ case 16:
+ lv_table_set_cell_type(gridDisplay, row, col, 2);
+ break;
+ case 32:
+ case 64:
+ lv_table_set_cell_type(gridDisplay, row, col, 3);
+ break;
+ default:
+ lv_table_set_cell_type(gridDisplay, row, col, 4);
+ break;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h
new file mode 100644
index 0000000..ad80ca1
--- /dev/null
+++ b/src/displayapp/screens/Twos.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <lvgl/src/lv_core/lv_obj.h>
+#include "Screen.h"
+
+namespace Pinetime {
+ namespace Applications {
+ struct Tile {
+ bool merged = false;
+ unsigned int value = 0;
+ };
+ namespace Screens {
+ class Twos : public Screen {
+ public:
+ Twos(DisplayApp* app);
+ ~Twos() override;
+ bool Refresh() override;
+ bool OnButtonPushed() override;
+ bool OnTouchEvent(TouchEvents event) override;
+
+ private:
+ bool running = true;
+ lv_obj_t *scoreText;
+ lv_obj_t *gridDisplay;
+ Tile grid[4][4];
+ unsigned int score = 0;
+ void updateGridDisplay(Tile grid[][4]);
+ bool tryMerge(Tile grid[][4], int &newRow, int &newCol, int oldRow, int oldCol);
+ bool tryMove(Tile grid[][4], int newRow, int newCol, int oldRow, int oldCol);
+ bool placeNewTile();
+ };
+ }
+ }
+} \ No newline at end of file