mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 14:55:29 +00:00
Support IPS screen & brightness set for IPS screen (#2629)
* _ * format * format * format
This commit is contained in:

committed by
GitHub

parent
806219f46e
commit
6b6a00d511
@@ -33,6 +33,8 @@ using namespace portapack;
|
||||
|
||||
#include "file.hpp"
|
||||
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
#include <complex>
|
||||
|
||||
#include <cstring>
|
||||
@@ -143,7 +145,13 @@ void lcd_init() {
|
||||
// REV = 1 (normally white)
|
||||
// NL = 0b100111 (default)
|
||||
// PCDIV = 0b000000 (default?)
|
||||
io.lcd_data_write_command_and_data(0xB6, {0x0A, 0xA2, 0x27, 0x00});
|
||||
|
||||
/*as per the datasheet chapter 8.3.7, addr B6h,
|
||||
data "REV" bit, liquid crystal type:*/
|
||||
if (portapack::persistent_memory::config_lcd_normally_black())
|
||||
io.lcd_data_write_command_and_data(0xB6, {0x0A, 0x22, 0x27, 0x00}); // IPS : normally black : 0
|
||||
else
|
||||
io.lcd_data_write_command_and_data(0xB6, {0x0A, 0xA2, 0x27, 0x00}); // TFT : normally white : 1
|
||||
|
||||
// Power Control 1
|
||||
// VRH[5:0]
|
||||
@@ -309,14 +317,6 @@ void ILI9341::wake() {
|
||||
lcd_wake();
|
||||
}
|
||||
|
||||
void ILI9341::set_inverted(bool invert) {
|
||||
if (invert) {
|
||||
io.lcd_data_write_command_and_data(0x21, {});
|
||||
} else {
|
||||
io.lcd_data_write_command_and_data(0x20, {});
|
||||
}
|
||||
}
|
||||
|
||||
void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) {
|
||||
const auto r_clipped = r.intersect(screen_rect());
|
||||
if (!r_clipped.is_empty()) {
|
||||
|
@@ -50,8 +50,6 @@ class ILI9341 {
|
||||
void sleep();
|
||||
void wake();
|
||||
|
||||
void set_inverted(bool invert);
|
||||
|
||||
void fill_rectangle(ui::Rect r, const ui::Color c);
|
||||
void fill_rectangle_unrolled8(ui::Rect r, const ui::Color c);
|
||||
void draw_line(const ui::Point start, const ui::Point end, const ui::Color color);
|
||||
|
@@ -78,11 +78,11 @@ void IO::reference_oscillator(const bool enable) {
|
||||
}
|
||||
|
||||
bool IO::get_dark_cover() {
|
||||
return portapack::persistent_memory::apply_fake_brightness() & (!portapack::persistent_memory::config_lcd_inverted_mode());
|
||||
return portapack::persistent_memory::apply_fake_brightness();
|
||||
}
|
||||
|
||||
bool IO::get_is_inverted() {
|
||||
return portapack::persistent_memory::config_lcd_inverted_mode();
|
||||
bool IO::get_is_normally_black() {
|
||||
return portapack::persistent_memory::config_lcd_normally_black();
|
||||
}
|
||||
|
||||
uint8_t IO::get_brightness() {
|
||||
@@ -90,7 +90,7 @@ uint8_t IO::get_brightness() {
|
||||
}
|
||||
|
||||
void IO::update_cached_values() {
|
||||
inverted_enabled = get_is_inverted();
|
||||
lcd_normally_black = get_is_normally_black();
|
||||
dark_cover_enabled = get_dark_cover();
|
||||
brightness = get_brightness();
|
||||
}
|
||||
|
@@ -231,10 +231,10 @@ class IO {
|
||||
|
||||
return switches_raw;
|
||||
}
|
||||
bool inverted_enabled = false;
|
||||
bool lcd_normally_black = false;
|
||||
bool dark_cover_enabled = false;
|
||||
uint8_t brightness = 0;
|
||||
bool get_is_inverted();
|
||||
bool get_is_normally_black();
|
||||
bool get_dark_cover();
|
||||
uint8_t get_brightness();
|
||||
void update_cached_values();
|
||||
@@ -419,7 +419,7 @@ class IO {
|
||||
const auto value_low = data_read();
|
||||
uint32_t original_value = (value_high << 8) | value_low;
|
||||
|
||||
if (inverted_enabled) return original_value;
|
||||
if (lcd_normally_black) return original_value;
|
||||
|
||||
if (dark_cover_enabled) {
|
||||
// this is read data, so if the fake brightness is enabled AKA get_dark_cover() == true,
|
||||
|
@@ -211,7 +211,7 @@ struct data_t {
|
||||
bool updown_converter;
|
||||
bool updown_frequency_rx_correction;
|
||||
bool updown_frequency_tx_correction;
|
||||
bool lcd_inverted_mode : 1;
|
||||
bool lcd_normally_black : 1;
|
||||
bool encoder_dial_direction : 1; // false = normal, true = reverse
|
||||
bool UNUSED_6 : 1;
|
||||
bool UNUSED_7 : 1;
|
||||
@@ -289,7 +289,7 @@ struct data_t {
|
||||
updown_converter(false),
|
||||
updown_frequency_rx_correction(false),
|
||||
updown_frequency_tx_correction(false),
|
||||
lcd_inverted_mode(false),
|
||||
lcd_normally_black(false),
|
||||
encoder_dial_direction(false),
|
||||
UNUSED_6(false),
|
||||
UNUSED_7(false),
|
||||
@@ -1090,12 +1090,12 @@ void set_config_freq_rx_correction(uint32_t v) {
|
||||
data->frequency_rx_correction = v;
|
||||
}
|
||||
|
||||
// LCD invert
|
||||
bool config_lcd_inverted_mode() {
|
||||
return data->lcd_inverted_mode;
|
||||
// IPS vs TFT
|
||||
bool config_lcd_normally_black() {
|
||||
return data->lcd_normally_black;
|
||||
}
|
||||
void set_lcd_inverted_mode(bool v) {
|
||||
data->lcd_inverted_mode = v;
|
||||
void set_lcd_normally_black(bool v) {
|
||||
data->lcd_normally_black = v;
|
||||
}
|
||||
|
||||
// Rotary encoder dial settings
|
||||
@@ -1164,7 +1164,6 @@ 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;
|
||||
|
@@ -249,8 +249,8 @@ void set_config_audio_mute(bool v);
|
||||
void set_config_speaker_disable(bool v);
|
||||
void set_config_backlight_timer(const backlight_config_t& new_value);
|
||||
void set_disable_touchscreen(bool v);
|
||||
bool config_lcd_inverted_mode();
|
||||
void set_lcd_inverted_mode(bool v);
|
||||
bool config_lcd_normally_black();
|
||||
void set_lcd_normally_black(bool v);
|
||||
|
||||
uint8_t encoder_dial_sensitivity();
|
||||
void set_encoder_dial_sensitivity(uint8_t v);
|
||||
|
Reference in New Issue
Block a user