From ec5fbab9d41be5cea6a160851591f7c1aca07bd1 Mon Sep 17 00:00:00 2001
From: Manna Harbour <51143715+manna-harbour@users.noreply.github.com>
Date: Sat, 15 Oct 2022 23:18:58 +1100
Subject: [PATCH] Add selectable logo images

---
 app/boards/arm/corneish_zen/CMakeLists.txt    |  5 +-
 app/boards/arm/corneish_zen/Kconfig.defconfig | 17 +++++
 .../corneish_zen_v2_left_defconfig            |  1 +
 .../corneish_zen_v2_right_defconfig           |  1 +
 .../arm/corneish_zen/custom_status_screen.c   | 13 +++-
 .../arm/corneish_zen/widgets/icons/lpkblogo.c | 67 +++++++++++++++++++
 .../corneish_zen/widgets/icons/miryokulogo.c  | 59 ++++++++++++++++
 .../arm/corneish_zen/widgets/icons/zmklogo.c  | 65 ++++++++++++++++++
 8 files changed, 226 insertions(+), 2 deletions(-)
 create mode 100644 app/boards/arm/corneish_zen/widgets/icons/lpkblogo.c
 create mode 100644 app/boards/arm/corneish_zen/widgets/icons/miryokulogo.c
 create mode 100644 app/boards/arm/corneish_zen/widgets/icons/zmklogo.c

diff --git a/app/boards/arm/corneish_zen/CMakeLists.txt b/app/boards/arm/corneish_zen/CMakeLists.txt
index afaaf6bf19be..be921d1686ea 100644
--- a/app/boards/arm/corneish_zen/CMakeLists.txt
+++ b/app/boards/arm/corneish_zen/CMakeLists.txt
@@ -48,7 +48,10 @@ if(CONFIG_ZMK_DISPLAY)
     zephyr_library_sources(widgets/icons/layers2.c)
   endif()
   if(NOT CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
-    zephyr_library_sources(widgets/icons/zenlogo.c)
+    target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN app PRIVATE widgets/icons/zenlogo.c)
+    target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_LPKB app PRIVATE widgets/icons/lpkblogo.c)
+    target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZMK app PRIVATE widgets/icons/zmklogo.c)
+    target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_MIRYOKU app PRIVATE widgets/icons/miryokulogo.c)
   endif()
 endif()
 
diff --git a/app/boards/arm/corneish_zen/Kconfig.defconfig b/app/boards/arm/corneish_zen/Kconfig.defconfig
index f7dfc20d08e5..29a95cb733b0 100644
--- a/app/boards/arm/corneish_zen/Kconfig.defconfig
+++ b/app/boards/arm/corneish_zen/Kconfig.defconfig
@@ -81,6 +81,23 @@ menuconfig CUSTOM_WIDGET_PERIPHERAL_STATUS
 config CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING
 	bool "Hide heading strip for layer widget and center widgets on 1/3rds"
 
+choice CUSTOM_WIDGET_LOGO_IMAGE
+	prompt "custom logo widget image"
+
+	config CUSTOM_WIDGET_LOGO_IMAGE_ZEN
+		bool "Corne-ish Zen"
+
+	config CUSTOM_WIDGET_LOGO_IMAGE_LPKB
+		bool "LPKB"
+
+	config CUSTOM_WIDGET_LOGO_IMAGE_ZMK
+		bool "ZMK"
+
+	config CUSTOM_WIDGET_LOGO_IMAGE_MIRYOKU
+		bool "Miryoku"
+
+endchoice
+
 endif # BOARD_CORNEISH_ZEN_LEFT || BOARD_CORNEISH_ZEN_RIGHT
 
 if BOARD_CORNEISH_ZEN_V1_LEFT || BOARD_CORNEISH_ZEN_V1_RIGHT
diff --git a/app/boards/arm/corneish_zen/corneish_zen_v2_left_defconfig b/app/boards/arm/corneish_zen/corneish_zen_v2_left_defconfig
index b6670fd8df57..37e4319cb3fd 100644
--- a/app/boards/arm/corneish_zen/corneish_zen_v2_left_defconfig
+++ b/app/boards/arm/corneish_zen/corneish_zen_v2_left_defconfig
@@ -60,6 +60,7 @@ CONFIG_CUSTOM_WIDGET_OUTPUT_STATUS=y
 CONFIG_ZMK_WIDGET_OUTPUT_STATUS=n
 CONFIG_CUSTOM_WIDGET_LAYER_STATUS=y
 CONFIG_ZMK_WIDGET_LAYER_STATUS=n
+CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN=y
 
 # Turn on logging, and set ZMK logging to debug output
 #CONFIG_LOG=y
diff --git a/app/boards/arm/corneish_zen/corneish_zen_v2_right_defconfig b/app/boards/arm/corneish_zen/corneish_zen_v2_right_defconfig
index 90cfe7698d13..cf0ae49c74fc 100644
--- a/app/boards/arm/corneish_zen/corneish_zen_v2_right_defconfig
+++ b/app/boards/arm/corneish_zen/corneish_zen_v2_right_defconfig
@@ -58,6 +58,7 @@ CONFIG_CUSTOM_WIDGET_BATTERY_STATUS=y
 CONFIG_ZMK_WIDGET_BATTERY_STATUS=n
 CONFIG_CUSTOM_WIDGET_PERIPHERAL_STATUS=y
 CONFIG_ZMK_WIDGET_PERIPHERAL_STATUS=n
+CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN=y
 
 # Turn on logging, and set ZMK logging to debug output
 #CONFIG_LOG=y
diff --git a/app/boards/arm/corneish_zen/custom_status_screen.c b/app/boards/arm/corneish_zen/custom_status_screen.c
index 159803b66057..766288b8cc39 100644
--- a/app/boards/arm/corneish_zen/custom_status_screen.c
+++ b/app/boards/arm/corneish_zen/custom_status_screen.c
@@ -14,7 +14,6 @@
 #include <zephyr/logging/log.h>
 LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
 
-LV_IMG_DECLARE(zenlogo);
 LV_IMG_DECLARE(layers2);
 
 #if IS_ENABLED(CONFIG_CUSTOM_WIDGET_BATTERY_STATUS)
@@ -88,7 +87,19 @@ lv_obj_t *zmk_display_status_screen() {
 #if !IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
     lv_obj_t *zenlogo_icon;
     zenlogo_icon = lv_img_create(screen);
+  #if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN)
+    LV_IMG_DECLARE(zenlogo);
     lv_img_set_src(zenlogo_icon, &zenlogo);
+  #elif IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_LPKB)
+    LV_IMG_DECLARE(lpkblogo);
+    lv_img_set_src(zenlogo_icon, &lpkblogo);
+  #elif IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZMK)
+    LV_IMG_DECLARE(zmklogo);
+    lv_img_set_src(zenlogo_icon, &zmklogo);
+  #elif IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_MIRYOKU)
+    LV_IMG_DECLARE(miryokulogo);
+    lv_img_set_src(zenlogo_icon, &miryokulogo);
+  #endif
 #if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING)
     lv_obj_align(zenlogo_icon, LV_ALIGN_CENTER, 0, 43);
 #else
diff --git a/app/boards/arm/corneish_zen/widgets/icons/lpkblogo.c b/app/boards/arm/corneish_zen/widgets/icons/lpkblogo.c
new file mode 100644
index 000000000000..6998127b9fb5
--- /dev/null
+++ b/app/boards/arm/corneish_zen/widgets/icons/lpkblogo.c
@@ -0,0 +1,67 @@
+/*
+ *
+ * Copyright (c) 2021 Darryl deHaan
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#include <lvgl.h>
+
+#ifndef LV_ATTRIBUTE_MEM_ALIGN
+#define LV_ATTRIBUTE_MEM_ALIGN
+#endif
+
+#ifndef LV_ATTRIBUTE_IMG_LPKBLOGO
+#define LV_ATTRIBUTE_IMG_LPKBLOGO
+#endif
+
+const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LPKBLOGO uint8_t lpkblogo_map[] = {
+  0xff, 0xff, 0xff, 0xff, 	/*Color of index 0*/
+  0x00, 0x00, 0x00, 0xff, 	/*Color of index 1*/
+
+  0x7f, 0xff, 0xff, 0xff, 0xc0, 
+  0xff, 0xff, 0xff, 0xff, 0xe0, 
+  0xe0, 0x00, 0x00, 0x00, 0xe0, 
+  0xc0, 0x00, 0x00, 0x00, 0x60, 
+  0xc7, 0x83, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc3, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc0, 0x00, 0xfc, 0x60, 
+  0xcf, 0xc0, 0x00, 0xfc, 0x60, 
+  0xcf, 0xc0, 0x00, 0xfc, 0x60, 
+  0xcf, 0xc0, 0x00, 0xfc, 0x60, 
+  0xcf, 0xc3, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc3, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc0, 0x00, 0x00, 0x60, 
+  0xcf, 0xc0, 0x00, 0x00, 0x60, 
+  0xcf, 0xc0, 0x00, 0x00, 0x60, 
+  0xcf, 0xc0, 0x00, 0x00, 0x60, 
+  0xcf, 0xc0, 0x00, 0x00, 0x60, 
+  0xcf, 0xc3, 0xff, 0xf8, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xcf, 0xc7, 0xff, 0xfc, 0x60, 
+  0xc7, 0x83, 0xff, 0xf8, 0x60, 
+  0xc0, 0x00, 0x00, 0x00, 0x60, 
+  0xe0, 0x00, 0x00, 0x00, 0xe0, 
+  0xff, 0xff, 0xff, 0xff, 0xe0, 
+  0x7f, 0xff, 0xff, 0xff, 0xc0, 
+};
+
+const lv_img_dsc_t lpkblogo = {
+  .header.cf = LV_IMG_CF_INDEXED_1BIT,
+  .header.always_zero = 0,
+  .header.reserved = 0,
+  .header.w = 35,
+  .header.h = 35,
+  .data_size = 183,
+  .data = lpkblogo_map,
+};
diff --git a/app/boards/arm/corneish_zen/widgets/icons/miryokulogo.c b/app/boards/arm/corneish_zen/widgets/icons/miryokulogo.c
new file mode 100644
index 000000000000..154f2d1e5fe7
--- /dev/null
+++ b/app/boards/arm/corneish_zen/widgets/icons/miryokulogo.c
@@ -0,0 +1,59 @@
+// Copyright 2022 Manna Harbour
+// https://github.com/manna-harbour/miryoku
+
+#include "lvgl.h"
+
+#ifndef LV_ATTRIBUTE_MEM_ALIGN
+#define LV_ATTRIBUTE_MEM_ALIGN
+#endif
+
+#ifndef LV_ATTRIBUTE_IMG_MIRYOKULOGO
+#define LV_ATTRIBUTE_IMG_MIRYOKULOGO
+#endif
+
+const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_MIRYOKULOGO uint8_t miryokulogo_map[] = {
+  0x04, 0x02, 0x04, 0xff, 	/*Color of index 0*/
+  0xfc, 0xfe, 0xfc, 0xff, 	/*Color of index 1*/
+
+  0xff, 0xff, 0xff, 0xff, 
+  0x80, 0x00, 0x00, 0x01, 
+  0x80, 0x00, 0x00, 0x01, 
+  0x9f, 0xff, 0xff, 0xf9, 
+  0x9f, 0xff, 0xff, 0xf9, 
+  0x98, 0x01, 0x99, 0x99, 
+  0x98, 0x01, 0x99, 0x99, 
+  0x99, 0x99, 0x80, 0x19, 
+  0x99, 0x99, 0x80, 0x19, 
+  0x98, 0x01, 0xf9, 0xf9, 
+  0x98, 0x01, 0xf9, 0xf9, 
+  0x99, 0x99, 0x99, 0x99, 
+  0x99, 0x99, 0x99, 0x99, 
+  0x98, 0x01, 0x80, 0x19, 
+  0x98, 0x01, 0x80, 0x19, 
+  0x9f, 0x9f, 0xf9, 0xf9, 
+  0x9f, 0x9f, 0xf9, 0xf9, 
+  0x98, 0x01, 0x80, 0x19, 
+  0x98, 0x01, 0x80, 0x19, 
+  0x99, 0x99, 0x99, 0x99, 
+  0x99, 0x99, 0x99, 0x99, 
+  0x99, 0x81, 0x99, 0x99, 
+  0x99, 0x81, 0x99, 0x99, 
+  0x99, 0x9f, 0x99, 0x99, 
+  0x99, 0x9f, 0x99, 0x99, 
+  0x99, 0x80, 0x19, 0x99, 
+  0x99, 0x80, 0x19, 0x99, 
+  0x9f, 0xff, 0xff, 0xf9, 
+  0x9f, 0xff, 0xff, 0xf9, 
+  0x80, 0x00, 0x00, 0x01, 
+  0x80, 0x00, 0x00, 0x01, 
+  0xff, 0xff, 0xff, 0xff, 
+};
+
+const lv_img_dsc_t miryokulogo = {
+  .header.always_zero = 0,
+  .header.w = 32,
+  .header.h = 32,
+  .data_size = 136,
+  .header.cf = LV_IMG_CF_INDEXED_1BIT,
+  .data = miryokulogo_map,
+};
diff --git a/app/boards/arm/corneish_zen/widgets/icons/zmklogo.c b/app/boards/arm/corneish_zen/widgets/icons/zmklogo.c
new file mode 100644
index 000000000000..98c7a8adc5c1
--- /dev/null
+++ b/app/boards/arm/corneish_zen/widgets/icons/zmklogo.c
@@ -0,0 +1,65 @@
+#include "lvgl.h"
+
+#ifndef LV_ATTRIBUTE_MEM_ALIGN
+#define LV_ATTRIBUTE_MEM_ALIGN
+#endif
+
+#ifndef LV_ATTRIBUTE_IMG_ZMKLOGO
+#define LV_ATTRIBUTE_IMG_ZMKLOGO
+#endif
+
+const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_ZMKLOGO uint8_t zmklogo_map[] = {
+  0xff, 0xff, 0xff, 0xff, 	/*Color of index 0*/
+  0x00, 0x00, 0x00, 0xfe, 	/*Color of index 1*/
+
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xf0, 0x0e, 0x7e, 0x73, 0xc7, 
+  0xe0, 0x04, 0x3c, 0x31, 0x87, 
+  0xf0, 0x0c, 0x18, 0x31, 0x0f, 
+  0xff, 0x0c, 0x18, 0x30, 0x1f, 
+  0xff, 0x1c, 0x00, 0x30, 0x3f, 
+  0xfe, 0x3c, 0x00, 0x30, 0x7f, 
+  0xfe, 0x3c, 0x42, 0x30, 0xff, 
+  0xfc, 0x7c, 0x66, 0x30, 0xff, 
+  0xf8, 0x7c, 0x7e, 0x30, 0x7f, 
+  0xf8, 0xfc, 0x7e, 0x30, 0x3f, 
+  0xf0, 0xfc, 0x7e, 0x30, 0x1f, 
+  0xf0, 0x0c, 0x7e, 0x31, 0x0f, 
+  0xe0, 0x04, 0x7e, 0x31, 0x87, 
+  0xf0, 0x0e, 0xff, 0x73, 0xc7, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+  0xff, 0xff, 0xff, 0xff, 0xff, 
+};
+
+const lv_img_dsc_t zmklogo = {
+  .header.cf = LV_IMG_CF_INDEXED_1BIT,
+  .header.always_zero = 0,
+  .header.reserved = 0,
+  .header.w = 40,
+  .header.h = 40,
+  .data_size = 208,
+  .data = zmklogo_map,
+};