InfiniTime.git

commit 3011dec66bb6b980e19d435c35bbb385ee200b88

Author: JF <jf@codingfield.com>

Merge branch 'paint' of JF/PineTime into develop

 src/CMakeLists.txt | 2 
 src/DisplayApp/Apps.h | 2 
 src/DisplayApp/DisplayApp.cpp | 7 ++
 src/DisplayApp/Fonts/Readme.md | 2 
 src/DisplayApp/Fonts/jetbrains_mono_bold_20.c | 39 +++++++++++-------
 src/DisplayApp/Screens/ApplicationList.cpp | 2 
 src/DisplayApp/Screens/InfiniPaint.cpp | 44 +++++++++++++++++++++
 src/DisplayApp/Screens/InfiniPaint.h | 35 ++++++++++++++++
 src/DisplayApp/Screens/Screen.h | 3 +
 src/DisplayApp/Screens/Symbols.h | 1 


diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dbd919bc81b87d3307333b928d67fc83f637306e..8ccd82bc3e4405da6aec455d47bab717e45ffeaf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -329,6 +329,7 @@   DisplayApp/Screens/Clock.cpp
   DisplayApp/Screens/Tile.cpp
   DisplayApp/Screens/Meter.cpp
   DisplayApp/Screens/Gauge.cpp
+  DisplayApp/Screens/InfiniPaint.cpp
   DisplayApp/Screens/DropDownDemo.cpp
   DisplayApp/Screens/Modal.cpp
   DisplayApp/Screens/BatteryIcon.cpp
@@ -403,6 +404,7 @@   DisplayApp/Screens/Clock.h
   DisplayApp/Screens/Tile.h
   DisplayApp/Screens/Meter.h
   DisplayApp/Screens/Gauge.h
+  DisplayApp/Screens/InfiniPaint.h
   DisplayApp/Screens/DropDownDemo.h
   DisplayApp/Screens/Modal.h
   DisplayApp/Screens/BatteryIcon.h




diff --git a/src/DisplayApp/Apps.h b/src/DisplayApp/Apps.h
index 2666d905776f3692b94aed6564ea9fb5e4cd537d..3842e4e58778874797b469dad9b8218183e5d986 100644
--- a/src/DisplayApp/Apps.h
+++ b/src/DisplayApp/Apps.h
@@ -2,6 +2,6 @@ #pragma once
 
 namespace Pinetime {
   namespace Applications {
-    enum class Apps {None, Launcher, Clock, SysInfo, Meter, Gauge, Brightness, Music, FirmwareValidation};
+    enum class Apps {None, Launcher, Clock, SysInfo, Meter, Gauge, Brightness, Music, FirmwareValidation, Paint};
   }
 }
\ No newline at end of file




diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp
index 6de746cc168e4396ccb8b3fb1a194ee06be30da9..8def1acbb644ea88471aebdb7bc6862ce51adde5 100644
--- a/src/DisplayApp/DisplayApp.cpp
+++ b/src/DisplayApp/DisplayApp.cpp
@@ -174,8 +174,11 @@   }
 
   if(touchMode == TouchModes::Polling) {
     auto info = touchPanel.GetTouchInfo();
-    if(info.action == 2) // 2 = contact
-      lvgl.SetNewTapEvent(info.x, info.y);
+    if(info.action == 2) {// 2 = contact
+      if(!currentScreen->OnTouchEvent(info.x, info.y)) {
+        lvgl.SetNewTapEvent(info.x, info.y);
+      }
+    }
   }
 }
 




diff --git a/src/DisplayApp/Fonts/Readme.md b/src/DisplayApp/Fonts/Readme.md
index 584ed030fc71e52dcb63fef7956292ed06cb8b10..7ebf2e2395e3822e85171bffe522191bd3c9e21e 100644
--- a/src/DisplayApp/Fonts/Readme.md
+++ b/src/DisplayApp/Fonts/Readme.md
@@ -10,7 +10,7 @@  * Size : 20
  * Bpp : 1 bit-per-pixel
  * Do not enable font compression and horizontal subpixel hinting
  * Load the file `JetBrainsMono-Bold.woff` and specify the following range : `0x20-0x7f`
- * Add a 2nd font, load the file `FontAwesome5-Solid+Brands+Regular.woff` and specify the following range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069`
+ * Add a 2nd font, load the file `FontAwesome5-Solid+Brands+Regular.woff` and specify the following range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc`
  * Click on Convert, and download the file `jetbrains_mono_bold_20.c` and copy it in `src/DisplayApp/Fonts`
   
 Add new symbols:




diff --git a/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c b/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c
index e411cf79344bb7647c7e065404796626f56aa343..27ad0055b65ce319715a0897dcde3ca36917c9c1 100644
--- a/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c
+++ b/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c
@@ -487,6 +487,14 @@     0xfc, 0xff, 0xf9, 0xff, 0xf1, 0xff, 0xc3, 0xff,
     0x83, 0xfe, 0x3, 0xf8, 0x1, 0xc0, 0x3, 0x80,
     0x7, 0x0, 0xe, 0x0,
 
+    /* U+F1FC "" */
+    0x0, 0x0, 0xf0, 0x0, 0x1f, 0x0, 0x3, 0xf0,
+    0x0, 0x7e, 0x0, 0xf, 0xe0, 0x3, 0xfc, 0x0,
+    0x7f, 0xc0, 0xf, 0xf8, 0x0, 0xff, 0x80, 0x1f,
+    0xf0, 0x0, 0xfe, 0x0, 0xf, 0xe0, 0xe, 0x7c,
+    0x1, 0xf8, 0x0, 0x9f, 0xc0, 0xf, 0xfc, 0x0,
+    0x7f, 0xc0, 0x7, 0xf8, 0x0, 0x1f, 0x0, 0x0,
+
     /* U+F21E "" */
     0x1e, 0x7, 0x83, 0xf9, 0xfe, 0x7f, 0xff, 0xef,
     0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xfc,
@@ -681,17 +689,18 @@     {.bitmap_index = 1599, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
     {.bitmap_index = 1647, .adv_w = 120, .box_w = 8, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
     {.bitmap_index = 1666, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
     {.bitmap_index = 1716, .adv_w = 240, .box_w = 15, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
-    {.bitmap_index = 1752, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
-    {.bitmap_index = 1795, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
-    {.bitmap_index = 1833, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
-    {.bitmap_index = 1871, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
-    {.bitmap_index = 1909, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
-    {.bitmap_index = 1947, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
-    {.bitmap_index = 1985, .adv_w = 280, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
-    {.bitmap_index = 2023, .adv_w = 200, .box_w = 11, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
-    {.bitmap_index = 2052, .adv_w = 360, .box_w = 23, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
-    {.bitmap_index = 2101, .adv_w = 400, .box_w = 25, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
-    {.bitmap_index = 2161, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3}
+    {.bitmap_index = 1752, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+    {.bitmap_index = 1800, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
+    {.bitmap_index = 1843, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
+    {.bitmap_index = 1881, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
+    {.bitmap_index = 1919, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
+    {.bitmap_index = 1957, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
+    {.bitmap_index = 1995, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
+    {.bitmap_index = 2033, .adv_w = 280, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+    {.bitmap_index = 2071, .adv_w = 200, .box_w = 11, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+    {.bitmap_index = 2100, .adv_w = 360, .box_w = 23, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
+    {.bitmap_index = 2149, .adv_w = 400, .box_w = 25, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+    {.bitmap_index = 2209, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3}
 };
 
 /*---------------------
@@ -699,9 +708,9 @@  *  CHARACTER MAPPING
  *--------------------*/
 
 static const uint16_t unicode_list_1[] = {
-    0x0, 0x16, 0x39, 0x68, 0x128, 0x184, 0x1e5, 0x21d,
-    0x23f, 0x240, 0x241, 0x242, 0x243, 0x292, 0x293, 0x3fc,
-    0x54a, 0x55f
+    0x0, 0x16, 0x39, 0x68, 0x128, 0x184, 0x1e5, 0x1fb,
+    0x21d, 0x23f, 0x240, 0x241, 0x242, 0x243, 0x292, 0x293,
+    0x3fc, 0x54a, 0x55f
 };
 
 /*Collect the unicode lists and glyph_id offsets*/
@@ -713,7 +722,7 @@         .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
     },
     {
         .range_start = 61441, .range_length = 1376, .glyph_id_start = 96,
-        .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 18, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
+        .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 19, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
     }
 };
 




diff --git a/src/DisplayApp/Screens/ApplicationList.cpp b/src/DisplayApp/Screens/ApplicationList.cpp
index 575426f0c749a59fc315b1e0fe0c54edc3e82f84..eb85be4fab9351f6cbaba635acd8b247ef3b624d 100644
--- a/src/DisplayApp/Screens/ApplicationList.cpp
+++ b/src/DisplayApp/Screens/ApplicationList.cpp
@@ -57,7 +57,7 @@ std::unique_ptr ApplicationList::CreateScreen2() {
   std::array<Screens::Tile::Applications, 6> applications {
           {{Symbols::tachometer, Apps::Gauge},
            {Symbols::asterisk, Apps::Meter},
-           {Symbols::none, Apps::None},
+           {Symbols::paintbrush, Apps::Paint},
            {Symbols::none, Apps::None},
            {Symbols::none, Apps::None},
            {Symbols::none, Apps::None}




diff --git a/src/DisplayApp/Screens/InfiniPaint.cpp b/src/DisplayApp/Screens/InfiniPaint.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b340f5d86e8ee6b5cbcd8e74d72e0d34001b66b1
--- /dev/null
+++ b/src/DisplayApp/Screens/InfiniPaint.cpp
@@ -0,0 +1,44 @@
+#include <libs/lvgl/lvgl.h>
+#include <libraries/log/nrf_log.h>
+#include "InfiniPaint.h"
+#include "../DisplayApp.h"
+
+using namespace Pinetime::Applications::Screens;
+extern lv_font_t jetbrains_mono_extrabold_compressed;
+extern lv_font_t jetbrains_mono_bold_20;
+
+InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp *app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl{lvgl} {
+  app->SetTouchMode(DisplayApp::TouchModes::Polling);
+  std::fill(b, b+bufferSize, LV_COLOR_WHITE);
+}
+
+InfiniPaint::~InfiniPaint() {
+  // Reset the touchmode
+  app->SetTouchMode(DisplayApp::TouchModes::Gestures);
+  lv_obj_clean(lv_scr_act());
+}
+
+bool InfiniPaint::Refresh() {
+  return running;
+}
+
+bool InfiniPaint::OnButtonPushed() {
+  running = false;
+  return true;
+}
+
+bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+  return true;
+}
+
+bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) {
+  lv_area_t area;
+  area.x1 = x-(width/2);
+  area.y1 = y-(height/2);
+  area.x2 = x+(width/2)-1;
+  area.y2 = y+(height/2)-1;
+  lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None);
+  lvgl.FlushDisplay(&area, b);
+  return true;
+}
+




diff --git a/src/DisplayApp/Screens/InfiniPaint.h b/src/DisplayApp/Screens/InfiniPaint.h
new file mode 100644
index 0000000000000000000000000000000000000000..a1592f97b4af0899e64343cff4f76c66ead9c9e5
--- /dev/null
+++ b/src/DisplayApp/Screens/InfiniPaint.h
@@ -0,0 +1,35 @@
+#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 <drivers/St7789.h>
+#include <DisplayApp/LittleVgl.h>
+
+namespace Pinetime {
+  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;
+          static constexpr uint16_t height = 10;
+          static constexpr uint16_t bufferSize = width*height;
+          lv_color_t b[bufferSize];
+          bool running = true;
+      };
+    }
+  }
+}




diff --git a/src/DisplayApp/Screens/Screen.h b/src/DisplayApp/Screens/Screen.h
index d890231753a05f260d8da31c80e737ef2358c715..dbf81a440b5ad761d17215b843adde2b4cedde8b 100644
--- a/src/DisplayApp/Screens/Screen.h
+++ b/src/DisplayApp/Screens/Screen.h
@@ -1,4 +1,6 @@
 #pragma once
+
+#include <cstdint>
 #include "../TouchEvents.h"
 
 namespace Pinetime {
@@ -18,6 +20,7 @@           virtual bool OnButtonPushed() { return false; }
 
           // Return false if the event hasn't been handled by the app, true if it has been handled
           virtual bool OnTouchEvent(TouchEvents event) { return false; }
+          virtual bool OnTouchEvent(uint16_t x, uint16_t y) { return false; }
 
         protected:
           DisplayApp* app;




diff --git a/src/DisplayApp/Screens/Symbols.h b/src/DisplayApp/Screens/Symbols.h
index 69078c8a93afa2533fb629d6b292ac11e497e8be..aeea3243031f38dd617aab77eb586e51b482098e 100644
--- a/src/DisplayApp/Screens/Symbols.h
+++ b/src/DisplayApp/Screens/Symbols.h
@@ -23,6 +23,7 @@         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";
+        static constexpr const char* paintbrush = "\xEF\x87\xBC";
       }
     }
   }