From e76809cc3d5ad8d6c2d17e76b812b2782db65a2d Mon Sep 17 00:00:00 2001 From: zxkmm Date: Sat, 17 Feb 2024 13:04:15 +0800 Subject: [PATCH 1/7] fix_shift_back --- firmware/common/portapack_io.hpp | 31 +++++++++++++----- .../external_app_info.cpython-311.pyc | Bin 0 -> 319 bytes 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 firmware/tools/__pycache__/external_app_info.cpython-311.pyc diff --git a/firmware/common/portapack_io.hpp b/firmware/common/portapack_io.hpp index 8fa45d8b6..0c07a7dce 100644 --- a/firmware/common/portapack_io.hpp +++ b/firmware/common/portapack_io.hpp @@ -147,7 +147,7 @@ class IO { void lcd_write_pixel(ui::Color pixel) { if (get_dark_cover()) { - darken_color(pixel, get_brightness()); // Darken the pixel color + shift_color(pixel, get_brightness(), false); // Darken the pixel color } lcd_write_data(pixel.v); } @@ -158,7 +158,7 @@ class IO { void lcd_write_pixels(ui::Color pixel, size_t n) { if (get_dark_cover()) { - darken_color(pixel, get_brightness()); // Darken the pixel color + shift_color(pixel, get_brightness(), false); // Darken the pixel color } while (n--) { lcd_write_data(pixel.v); @@ -167,7 +167,7 @@ class IO { void lcd_write_pixels_unrolled8(ui::Color pixel, size_t n) { if (get_dark_cover()) { - darken_color(pixel, get_brightness()); // Darken the pixel color + shift_color(pixel, get_brightness(), false); // Darken the pixel color } auto v = pixel.v; n >>= 3; @@ -331,7 +331,7 @@ class IO { addr(1); /* Set up for data phase (most likely after a command) */ } - void darken_color(ui::Color& pixel, uint8_t darken_level_shift) { + void shift_color(ui::Color& pixel, uint8_t shift_level, bool shift_left) { // TODO: 1. do we need edge control? // currently didn't see and issue without edge control // but maybe hurts screen hardware without one? @@ -343,9 +343,15 @@ class IO { uint16_t g = (pixel.v >> 5) & 0x3F; // Extract green uint16_t b = pixel.v & 0x1F; // Extract blue - r = r >> darken_level_shift; // Darken red - g = g >> darken_level_shift; // Darken green - b = b >> darken_level_shift; // Darken blue + if (shift_left) { // Shfting + r = r << shift_level; + g = g << shift_level; + b = b << shift_level; + } else if (!shift_left) { + r = r >> shift_level; + g = g >> shift_level; + b = b >> shift_level; + } pixel.v = (r << 11) | (g << 5) | b; // Combine back to color, check UI::color for the color layout } @@ -417,7 +423,16 @@ class IO { halPolledDelay(18); // 90ns const auto value_low = data_read(); - return (value_high << 8) | value_low; + uint32_t original_value = (value_high << 8) | value_low; + + if (get_dark_cover()) { + ui::Color pixel; + pixel.v = original_value; + shift_color(pixel, get_brightness(), true); + original_value = pixel.v; + } + + return original_value; } void io_write(const bool address, const uint_fast16_t value) { diff --git a/firmware/tools/__pycache__/external_app_info.cpython-311.pyc b/firmware/tools/__pycache__/external_app_info.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2a0d434f167412044ac4032defc4e320793006f5 GIT binary patch literal 319 zcmZ3^%ge<81Sg-KN`1l1!0;HvfdNJ+S zD>b>KSU)$hG9xutH!ZU$w>+^ZRUghM$ Date: Sat, 17 Feb 2024 13:08:33 +0800 Subject: [PATCH 2/7] clean up --- .../__pycache__/external_app_info.cpython-311.pyc | Bin 319 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 firmware/tools/__pycache__/external_app_info.cpython-311.pyc diff --git a/firmware/tools/__pycache__/external_app_info.cpython-311.pyc b/firmware/tools/__pycache__/external_app_info.cpython-311.pyc deleted file mode 100644 index 2a0d434f167412044ac4032defc4e320793006f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 319 zcmZ3^%ge<81Sg-KN`1l1!0;HvfdNJ+S zD>b>KSU)$hG9xutH!ZU$w>+^ZRUghM$ Date: Sat, 17 Feb 2024 13:09:14 +0800 Subject: [PATCH 3/7] gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cc292cb38..a40570cad 100644 --- a/.gitignore +++ b/.gitignore @@ -68,9 +68,11 @@ CMakeFiles/ .DS_Store /firmware/CMakeCache.txt -# Python env/ venv +# Python env/ venv and cache env/ venv/ +**/__pycache__/ +*.pyc # Other *.bak From 0a1dc4d99a1d70f522ae9b4050a355916fdb65a9 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Sat, 17 Feb 2024 13:36:43 +0800 Subject: [PATCH 4/7] remove the workaround in notpad cuz it's been fixed in this PR --- firmware/application/apps/ui_text_editor.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/firmware/application/apps/ui_text_editor.cpp b/firmware/application/apps/ui_text_editor.cpp index a1584853e..037e73a71 100644 --- a/firmware/application/apps/ui_text_editor.cpp +++ b/firmware/application/apps/ui_text_editor.cpp @@ -555,9 +555,7 @@ void TextEditorView::open_file(const fs::path& path) { path_ = path; viewer.set_file(*file_); } - - portapack::persistent_memory::set_apply_fake_brightness(false); // work around to resolve the display issue in notepad app. not elegant i know, so TODO. - + refresh_ui(); } From bdec777fc5289e86ed38faf8f3ae1a3625986dfa Mon Sep 17 00:00:00 2001 From: zxkmm Date: Sat, 17 Feb 2024 13:44:46 +0800 Subject: [PATCH 5/7] format --- firmware/application/apps/ui_text_editor.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/firmware/application/apps/ui_text_editor.cpp b/firmware/application/apps/ui_text_editor.cpp index 037e73a71..fdf4a0de4 100644 --- a/firmware/application/apps/ui_text_editor.cpp +++ b/firmware/application/apps/ui_text_editor.cpp @@ -27,8 +27,6 @@ #include "log_file.hpp" #include "string_format.hpp" -#include "portapack_persistent_memory.hpp" - using namespace portapack; namespace fs = std::filesystem; @@ -555,7 +553,7 @@ void TextEditorView::open_file(const fs::path& path) { path_ = path; viewer.set_file(*file_); } - + refresh_ui(); } From 0eb79efd8490c216d3b2c1cb43dde2675924b150 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Sat, 17 Feb 2024 16:36:36 +0800 Subject: [PATCH 6/7] add credit for mark --- firmware/common/portapack_io.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/firmware/common/portapack_io.hpp b/firmware/common/portapack_io.hpp index 0c07a7dce..8ace55bdc 100644 --- a/firmware/common/portapack_io.hpp +++ b/firmware/common/portapack_io.hpp @@ -2,6 +2,7 @@ * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyleft (ɔ) 2024 zxkmm under GPL license * Copyright (C) 2024 u-foka + * Copyright (C) 2023 Mark Thompson * * This file is part of PortaPack. * From 1369af8a2012dda28cb7d623cdf6316c633df8b8 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Sun, 18 Feb 2024 00:13:10 +0800 Subject: [PATCH 7/7] 2024 --- firmware/common/portapack_io.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/common/portapack_io.hpp b/firmware/common/portapack_io.hpp index 8ace55bdc..a23627a21 100644 --- a/firmware/common/portapack_io.hpp +++ b/firmware/common/portapack_io.hpp @@ -2,7 +2,7 @@ * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyleft (ɔ) 2024 zxkmm under GPL license * Copyright (C) 2024 u-foka - * Copyright (C) 2023 Mark Thompson + * Copyright (C) 2024 Mark Thompson * * This file is part of PortaPack. *