Skip to content

Commit

Permalink
only inv or fakebrightness (#2240)
Browse files Browse the repository at this point in the history
  • Loading branch information
htotoo committed Sep 8, 2024
1 parent 31c844b commit 1f78646
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
7 changes: 7 additions & 0 deletions firmware/application/apps/ui_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,13 @@ SetDisplayView::SetDisplayView(NavigationView& nav) {
send_system_refresh();
nav.pop();
};
// only enable invert OR fake brightness
checkbox_invert_switch.on_select = [this](Checkbox&, bool v) {
if (v) checkbox_brightness_switch.set_value(false);
};
checkbox_brightness_switch.on_select = [this](Checkbox&, bool v) {
if (v) checkbox_invert_switch.set_value(false);
};

button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void SystemStatusView::refresh() {
button_converter.set_foreground(pmem::config_converter() ? Theme::getInstance()->fg_red->foreground : Theme::getInstance()->fg_light->foreground);

// Fake Brightness
button_fake_brightness.set_foreground(pmem::apply_fake_brightness() ? *Theme::getInstance()->status_active : Theme::getInstance()->fg_light->foreground);
button_fake_brightness.set_foreground((pmem::apply_fake_brightness() & (!pmem::config_lcd_inverted_mode())) ? *Theme::getInstance()->status_active : Theme::getInstance()->fg_light->foreground);

set_dirty();
}
Expand Down
2 changes: 1 addition & 1 deletion firmware/common/portapack_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void IO::reference_oscillator(const bool enable) {
}

bool IO::get_dark_cover() {
return portapack::persistent_memory::apply_fake_brightness();
return portapack::persistent_memory::apply_fake_brightness() & (!portapack::persistent_memory::config_lcd_inverted_mode());
}

bool IO::get_is_inverted() {
Expand Down
20 changes: 4 additions & 16 deletions firmware/common/portapack_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ class IO {

void lcd_write_pixel(ui::Color pixel) {
if (get_dark_cover()) {
if (!get_is_inverted())
pixel.v = DARKENED_PIXEL(pixel.v, get_brightness());
else
pixel.v = UNDARKENED_PIXEL(pixel.v, get_brightness());
pixel.v = DARKENED_PIXEL(pixel.v, get_brightness());
}
lcd_write_data(pixel.v);
}
Expand All @@ -177,10 +174,7 @@ class IO {

void lcd_write_pixels(ui::Color pixel, size_t n) {
if (get_dark_cover()) {
if (!get_is_inverted())
pixel.v = DARKENED_PIXEL(pixel.v, get_brightness());
else
pixel.v = UNDARKENED_PIXEL(pixel.v, get_brightness());
pixel.v = DARKENED_PIXEL(pixel.v, get_brightness());
}
while (n--) {
lcd_write_data(pixel.v);
Expand All @@ -189,10 +183,7 @@ class IO {

void lcd_write_pixels_unrolled8(ui::Color pixel, size_t n) {
if (get_dark_cover()) {
if (!get_is_inverted())
pixel.v = DARKENED_PIXEL(pixel.v, get_brightness());
else
pixel.v = UNDARKENED_PIXEL(pixel.v, get_brightness());
pixel.v = DARKENED_PIXEL(pixel.v, get_brightness());
}
auto v = pixel.v;
n >>= 3;
Expand Down Expand Up @@ -426,10 +417,7 @@ class IO {
uint32_t original_value = (value_high << 8) | value_low;

if (get_dark_cover()) {
if (!get_is_inverted())
original_value = DARKENED_PIXEL(original_value, get_brightness());
else
original_value = UNDARKENED_PIXEL(original_value, get_brightness());
original_value = DARKENED_PIXEL(original_value, get_brightness());
}
return original_value;
}
Expand Down
2 changes: 1 addition & 1 deletion firmware/common/portapack_persistent_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ void set_fake_brightness_level(uint8_t v) {
// Cycle through 4 brightness options: disabled -> enabled/50% -> enabled/25% -> enabled/12.5% -> disabled
void toggle_fake_brightness_level() {
bool fbe = apply_fake_brightness();

if (config_lcd_inverted_mode()) return; // for now only inverted mode OR fake brightness
if ((!fbe) || (data->fake_brightness_level >= BRIGHTNESS_12p5)) {
set_apply_fake_brightness(!fbe);
data->fake_brightness_level = BRIGHTNESS_50;
Expand Down

0 comments on commit 1f78646

Please sign in to comment.