mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-03-21 14:16:28 -04:00
Cycle through brightness levels when icon selected (#1873)
This commit is contained in:
parent
998be5ba09
commit
b2ad1fa979
@ -329,9 +329,9 @@ SystemStatusView::SystemStatusView(
|
||||
refresh();
|
||||
};
|
||||
|
||||
toggle_fake_brightness.on_change = [this, &nav](bool v) {
|
||||
button_fake_brightness.on_select = [this](ImageButton&) {
|
||||
set_dirty();
|
||||
pmem::set_apply_fake_brightness(v);
|
||||
pmem::toggle_fake_brightness_level();
|
||||
refresh();
|
||||
if (nullptr != parent()) {
|
||||
parent()->set_dirty(); // The parent of NavigationView shal be the SystemView
|
||||
@ -359,7 +359,6 @@ SystemStatusView::SystemStatusView(
|
||||
toggle_speaker.set_value(pmem::config_speaker_disable());
|
||||
toggle_mute.set_value(pmem::config_audio_mute());
|
||||
toggle_stealth.set_value(pmem::stealth_mode());
|
||||
toggle_fake_brightness.set_value(pmem::apply_fake_brightness());
|
||||
|
||||
audio::output::stop();
|
||||
audio::output::update_audio_mute();
|
||||
@ -381,7 +380,7 @@ void SystemStatusView::refresh() {
|
||||
// Display "Disable speaker" icon only if AK4951 Codec which has separate speaker/headphone control
|
||||
if (audio::speaker_disable_supported() && !pmem::ui_hide_speaker()) status_icons.add(&toggle_speaker);
|
||||
|
||||
if (!pmem::ui_hide_fake_brightness()) status_icons.add(&toggle_fake_brightness);
|
||||
if (!pmem::ui_hide_fake_brightness()) status_icons.add(&button_fake_brightness);
|
||||
|
||||
if (!pmem::ui_hide_sd_card()) status_icons.add(&sd_card_status_view);
|
||||
status_icons.update_layout();
|
||||
@ -404,8 +403,8 @@ void SystemStatusView::refresh() {
|
||||
button_converter.set_bitmap(pmem::config_updown_converter() ? &bitmap_icon_downconvert : &bitmap_icon_upconvert);
|
||||
button_converter.set_foreground(pmem::config_converter() ? Color::red() : Color::light_grey());
|
||||
|
||||
// Brightness
|
||||
toggle_fake_brightness.set_value(pmem::apply_fake_brightness());
|
||||
// Fake Brightness
|
||||
button_fake_brightness.set_foreground(pmem::apply_fake_brightness() ? Color::green() : Color::light_grey());
|
||||
|
||||
set_dirty();
|
||||
}
|
||||
|
@ -266,9 +266,11 @@ class SystemStatusView : public View {
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageToggle toggle_fake_brightness{
|
||||
ImageButton button_fake_brightness{
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_brightness};
|
||||
&bitmap_icon_brightness,
|
||||
Color::green(),
|
||||
Color::dark_grey()};
|
||||
|
||||
SDCardStatusView sd_card_status_view{
|
||||
{0, 0 * 16, 2 * 8, 1 * 16}};
|
||||
|
@ -291,7 +291,7 @@ struct data_t {
|
||||
frequency_tx_correction(0),
|
||||
|
||||
encoder_dial_sensitivity(DIAL_SENSITIVITY_NORMAL),
|
||||
fake_brightness_level(0),
|
||||
fake_brightness_level(BRIGHTNESS_50),
|
||||
UNUSED_8(0),
|
||||
headphone_volume_cb(-600),
|
||||
misc_config(),
|
||||
@ -448,6 +448,10 @@ void init() {
|
||||
defaults();
|
||||
}
|
||||
set_config_mode_storage_direct(config_mode_backup);
|
||||
|
||||
// Firmware upgrade handling - adjust newly defined fields where 0 is an unwanted default
|
||||
if (fake_brightness_level() == 0)
|
||||
set_fake_brightness_level(BRIGHTNESS_50);
|
||||
}
|
||||
|
||||
void persist() {
|
||||
@ -728,10 +732,6 @@ void set_config_backlight_timer(const backlight_config_t& new_value) {
|
||||
|
||||
void set_apply_fake_brightness(const bool v) {
|
||||
data->ui_config.apply_fake_brightness = v;
|
||||
|
||||
// The fake_brightness_level field in PMEM will be 0 if it was never enabled before; pick a valid value
|
||||
if (data->fake_brightness_level == 0)
|
||||
data->fake_brightness_level = BRIGHTNESS_50;
|
||||
}
|
||||
|
||||
uint32_t pocsag_last_address() {
|
||||
@ -1015,8 +1015,8 @@ void set_config_dst(dst_config_t v) {
|
||||
data->dst_config = v;
|
||||
rtc_time::dst_init();
|
||||
}
|
||||
// fake brightness level (switch is in another place)
|
||||
|
||||
// Fake brightness level (switch is in another place)
|
||||
uint8_t fake_brightness_level() {
|
||||
return data->fake_brightness_level;
|
||||
}
|
||||
@ -1024,6 +1024,18 @@ void set_fake_brightness_level(uint8_t v) {
|
||||
data->fake_brightness_level = 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 ((!fbe) || (data->fake_brightness_level >= BRIGHTNESS_12p5)) {
|
||||
set_apply_fake_brightness(!fbe);
|
||||
data->fake_brightness_level = BRIGHTNESS_50;
|
||||
} else {
|
||||
data->fake_brightness_level++;
|
||||
}
|
||||
}
|
||||
|
||||
// PMem to sdcard settings
|
||||
|
||||
bool should_use_sdcard_for_pmem() {
|
||||
|
@ -276,6 +276,7 @@ void set_apply_fake_brightness(const bool v);
|
||||
// level (color change level):
|
||||
uint8_t fake_brightness_level();
|
||||
void set_fake_brightness_level(uint8_t v);
|
||||
void toggle_fake_brightness_level();
|
||||
|
||||
/* Recon app */
|
||||
bool recon_autosave_freqs();
|
||||
|
Loading…
x
Reference in New Issue
Block a user