Support for configurable Menu Color & scrolling fix (#1905)

* Support for Configurable Menu Color Scheme
* Limit min value to 8 so doesn't get reset to default
* Increased max encoder rate multiplier value to 15
* Fixed menu scrolling issue
This commit is contained in:
Mark Thompson
2024-02-16 00:19:43 -06:00
committed by GitHub
parent d04c781ada
commit 13fd1b1f3b
8 changed files with 161 additions and 6 deletions

View File

@@ -31,6 +31,7 @@
#include "memory_map.hpp"
#include "portapack.hpp"
#include "string_format.hpp"
#include "ui.hpp"
#include "ui_styles.hpp"
#include "ui_painter.hpp"
#include "ui_flash_utility.hpp"
@@ -46,6 +47,7 @@
#include <hal.h>
using namespace std;
using namespace ui;
namespace portapack {
namespace persistent_memory {
@@ -248,6 +250,11 @@ struct data_t {
// Daylight savings time
dst_config_t dst_config;
// Menu Color Scheme
Color menu_color;
uint16_t UNUSED_16;
constexpr data_t()
: structure_version(data_structure_version_enum::VERSION_CURRENT),
target_frequency(target_frequency_reset_value),
@@ -304,7 +311,9 @@ struct data_t {
misc_config(),
ui_config2(),
config_mode_storage(CONFIG_MODE_NORMAL_VALUE),
dst_config() {
dst_config(),
menu_color(Color::grey()),
UNUSED_16() {
}
};
@@ -412,6 +421,7 @@ void defaults() {
set_config_disable_external_tcxo(false);
set_encoder_dial_sensitivity(DIAL_SENSITIVITY_NORMAL);
set_config_speaker_disable(true); // Disable AK4951 speaker by default (in case of OpenSourceSDRLab H2)
set_menu_color(Color::grey());
// Default values for recon app.
set_recon_autosave_freqs(false);
@@ -461,6 +471,7 @@ void init() {
// Firmware upgrade handling - adjust newly defined fields where 0 is an invalid default
if (fake_brightness_level() == 0) set_fake_brightness_level(BRIGHTNESS_50);
if (menu_color().v == 0) set_menu_color(Color::grey());
}
void persist() {
@@ -1052,6 +1063,14 @@ void toggle_fake_brightness_level() {
}
}
// Menu Color Scheme
Color menu_color() {
return data->menu_color;
}
void set_menu_color(Color v) {
data->menu_color = v;
}
// PMem to sdcard settings
bool should_use_sdcard_for_pmem() {
@@ -1158,6 +1177,7 @@ bool debug_dump() {
pmem_dump_file.write_line("config_mode_storage: 0x" + to_string_hex(data->config_mode_storage, 8));
pmem_dump_file.write_line("dst_config: 0x" + to_string_hex((uint32_t)data->dst_config.v, 8));
pmem_dump_file.write_line("fake_brightness_level: " + to_string_dec_uint(data->fake_brightness_level));
pmem_dump_file.write_line("menu_color: 0x" + to_string_hex(data->menu_color.v, 4));
// ui_config bits
const auto backlight_timer = portapack::persistent_memory::config_backlight_timer();

View File

@@ -34,6 +34,7 @@
#include "serializer.hpp"
#include "volume.hpp"
#include "config_mode.hpp"
#include "ui.hpp"
// persistent memory from/to sdcard flag file
#define PMEM_FILEFLAG u"/SETTINGS/PMEM_FILEFLAG"
@@ -46,6 +47,7 @@
using namespace modems;
using namespace serializer;
using namespace ui;
namespace portapack {
@@ -282,6 +284,9 @@ uint8_t fake_brightness_level();
void set_fake_brightness_level(uint8_t v);
void toggle_fake_brightness_level();
Color menu_color();
void set_menu_color(Color v);
/* Recon app */
bool recon_autosave_freqs();
bool recon_autostart_recon();

View File

@@ -78,6 +78,18 @@ struct Color {
((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3))} {
}
uint8_t r() {
return (uint8_t)((v >> 8) & 0xf8);
}
uint8_t g() {
return (uint8_t)((v >> 3) & 0xfc);
}
uint8_t b() {
return (uint8_t)((v << 3) & 0xf8);
}
uint8_t to_greyscale() {
uint32_t r = (v >> 8) & 0xf8;
uint32_t g = (v >> 3) & 0xfc;

View File

@@ -1290,6 +1290,11 @@ void NewButton::set_color(Color color) {
set_dirty();
}
void NewButton::set_bg_color(Color color) {
bg_color_ = color;
set_dirty();
}
void NewButton::set_vertical_center(bool value) {
vertical_center_ = value;
set_dirty();
@@ -1343,7 +1348,7 @@ Style NewButton::paint_style() {
s.background = style().foreground;
s.foreground = Color::black();
} else {
s.background = Color::grey();
s.background = bg_color_;
s.foreground = style().foreground;
}

View File

@@ -504,6 +504,7 @@ class NewButton : public Widget {
void set_bitmap(const Bitmap* bitmap);
void set_text(const std::string value);
void set_color(Color value);
void set_bg_color(Color value);
void set_vertical_center(bool value);
std::string text() const;
const Bitmap* bitmap();
@@ -522,6 +523,7 @@ class NewButton : public Widget {
protected:
virtual Style paint_style();
Color color_;
Color bg_color_{Color::light_grey()};
private:
std::string text_;