mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
fix shift back in screenshot and mayhem hub (#1910)
* fix_shift_back * clean up * gitignore * remove the workaround in notpad cuz it's been fixed in this PR * format * add credit for mark * 2024
This commit is contained in:
parent
27dc37713b
commit
948e039574
4
.gitignore
vendored
4
.gitignore
vendored
@ -68,9 +68,11 @@ CMakeFiles/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
/firmware/CMakeCache.txt
|
/firmware/CMakeCache.txt
|
||||||
|
|
||||||
# Python env/ venv
|
# Python env/ venv and cache
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
|
**/__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
*.bak
|
*.bak
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include "log_file.hpp"
|
#include "log_file.hpp"
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
|
|
||||||
#include "portapack_persistent_memory.hpp"
|
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
@ -556,8 +554,6 @@ void TextEditorView::open_file(const fs::path& path) {
|
|||||||
viewer.set_file(*file_);
|
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();
|
refresh_ui();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||||
* Copyleft (ɔ) 2024 zxkmm under GPL license
|
* Copyleft (ɔ) 2024 zxkmm under GPL license
|
||||||
* Copyright (C) 2024 u-foka
|
* Copyright (C) 2024 u-foka
|
||||||
|
* Copyright (C) 2024 Mark Thompson
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@ -147,7 +148,7 @@ class IO {
|
|||||||
|
|
||||||
void lcd_write_pixel(ui::Color pixel) {
|
void lcd_write_pixel(ui::Color pixel) {
|
||||||
if (get_dark_cover()) {
|
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);
|
lcd_write_data(pixel.v);
|
||||||
}
|
}
|
||||||
@ -158,7 +159,7 @@ class IO {
|
|||||||
|
|
||||||
void lcd_write_pixels(ui::Color pixel, size_t n) {
|
void lcd_write_pixels(ui::Color pixel, size_t n) {
|
||||||
if (get_dark_cover()) {
|
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--) {
|
while (n--) {
|
||||||
lcd_write_data(pixel.v);
|
lcd_write_data(pixel.v);
|
||||||
@ -167,7 +168,7 @@ class IO {
|
|||||||
|
|
||||||
void lcd_write_pixels_unrolled8(ui::Color pixel, size_t n) {
|
void lcd_write_pixels_unrolled8(ui::Color pixel, size_t n) {
|
||||||
if (get_dark_cover()) {
|
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;
|
auto v = pixel.v;
|
||||||
n >>= 3;
|
n >>= 3;
|
||||||
@ -331,7 +332,7 @@ class IO {
|
|||||||
addr(1); /* Set up for data phase (most likely after a command) */
|
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?
|
// TODO: 1. do we need edge control?
|
||||||
// currently didn't see and issue without edge control
|
// currently didn't see and issue without edge control
|
||||||
// but maybe hurts screen hardware without one?
|
// but maybe hurts screen hardware without one?
|
||||||
@ -343,9 +344,15 @@ class IO {
|
|||||||
uint16_t g = (pixel.v >> 5) & 0x3F; // Extract green
|
uint16_t g = (pixel.v >> 5) & 0x3F; // Extract green
|
||||||
uint16_t b = pixel.v & 0x1F; // Extract blue
|
uint16_t b = pixel.v & 0x1F; // Extract blue
|
||||||
|
|
||||||
r = r >> darken_level_shift; // Darken red
|
if (shift_left) { // Shfting
|
||||||
g = g >> darken_level_shift; // Darken green
|
r = r << shift_level;
|
||||||
b = b >> darken_level_shift; // Darken blue
|
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
|
pixel.v = (r << 11) | (g << 5) | b; // Combine back to color, check UI::color for the color layout
|
||||||
}
|
}
|
||||||
@ -417,7 +424,16 @@ class IO {
|
|||||||
halPolledDelay(18); // 90ns
|
halPolledDelay(18); // 90ns
|
||||||
|
|
||||||
const auto value_low = data_read();
|
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) {
|
void io_write(const bool address, const uint_fast16_t value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user