From 960ecf616c578eac55d68d141baddb50274a65e5 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Sun, 25 Jun 2023 12:48:51 -0500 Subject: [PATCH] Update menu icons colors per app state & add contrast to bright icons for improved visibility when Selected (#1189) * Orange icons vs yellow * Update app icon colors per current development states * Darken bright icons on white backgrounds * Darken bright icons on white backgrounds --- firmware/application/ui_navigation.cpp | 16 ++++++++-------- firmware/common/ui.hpp | 13 +++++++++---- firmware/common/ui_painter.cpp | 4 ++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index d8350d4d..740b19ad 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -541,10 +541,10 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) { add_items({{"..", Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}}); } add_items({ - {"ADS-B [S]", ui::Color::yellow(), &bitmap_icon_adsb, [&nav]() { nav.push(); }}, + {"ADS-B [S]", ui::Color::green(), &bitmap_icon_adsb, [&nav]() { nav.push(); }}, {"APRS", ui::Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push(); }}, {"BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav]() { nav.push(); }}, - {"GPS Sim", ui::Color::yellow(), &bitmap_icon_gps_sim, [&nav]() { nav.push(); }}, + {"GPS Sim", ui::Color::green(), &bitmap_icon_gps_sim, [&nav]() { nav.push(); }}, {"Jammer", ui::Color::green(), &bitmap_icon_jammer, [&nav]() { nav.push(); }}, //{ "Key fob", ui::Color::orange(), &bitmap_icon_keyfob, [&nav](){ nav.push(); } }, {"LGE tool", ui::Color::yellow(), &bitmap_icon_lge, [&nav]() { nav.push(); }}, @@ -557,7 +557,7 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) { {"Soundbrd", ui::Color::green(), &bitmap_icon_soundboard, [&nav]() { nav.push(); }}, {"SSTV", ui::Color::green(), &bitmap_icon_sstv, [&nav]() { nav.push(); }}, {"TEDI/LCR", ui::Color::yellow(), &bitmap_icon_lcr, [&nav]() { nav.push(); }}, - {"TouchTune", ui::Color::yellow(), &bitmap_icon_touchtunes, [&nav]() { nav.push(); }}, + {"TouchTune", ui::Color::green(), &bitmap_icon_touchtunes, [&nav]() { nav.push(); }}, {"Playlist", ui::Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push(); }}, {"S.Painter", ui::Color::orange(), &bitmap_icon_paint, [&nav]() { nav.push(); }}, //{ "Remote", ui::Color::dark_grey(), &bitmap_icon_remote, [&nav](){ nav.push(); } }, @@ -573,7 +573,7 @@ UtilitiesMenuView::UtilitiesMenuView(NavigationView& nav) { add_items({ //{ "Test app", Color::dark_grey(), nullptr, [&nav](){ nav.push(); } }, {"Freq. manager", Color::green(), &bitmap_icon_freqman, [&nav]() { nav.push(); }}, - {"File manager", Color::yellow(), &bitmap_icon_dir, [&nav]() { nav.push(); }}, + {"File manager", Color::green(), &bitmap_icon_dir, [&nav]() { nav.push(); }}, {"Notepad", Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push(); }}, {"Signal gen", Color::green(), &bitmap_icon_cwgen, [&nav]() { nav.push(); }}, //{ "Tone search", Color::dark_grey(), nullptr, [&nav](){ nav.push(); } }, @@ -582,7 +582,7 @@ UtilitiesMenuView::UtilitiesMenuView(NavigationView& nav) { {"Wipe SD card", Color::red(), &bitmap_icon_tools_wipesd, [&nav]() { nav.push(); }}, {"Flash Utility", Color::red(), &bitmap_icon_temperature, [&nav]() { nav.push(); }}, - {"SD over USB", Color::yellow(), &bitmap_icon_hackrf, [&nav]() { nav.push(); }}, + {"SD over USB", Color::green(), &bitmap_icon_hackrf, [&nav]() { nav.push(); }}, }); set_max_rows(2); // allow wider buttons } @@ -606,9 +606,9 @@ SystemMenuView::SystemMenuView(NavigationView& nav) { {"Capture", Color::red(), &bitmap_icon_capture, [&nav]() { nav.push(); }}, {"Replay", Color::green(), &bitmap_icon_replay, [&nav]() { nav.push(); }}, {"Search", Color::yellow(), &bitmap_icon_search, [&nav]() { nav.push(); }}, - {"Scanner", Color::yellow(), &bitmap_icon_scanner, [&nav]() { nav.push(); }}, - {"Microphone", Color::yellow(), &bitmap_icon_microphone, [&nav]() { nav.push(); }}, - {"Looking Glass", Color::yellow(), &bitmap_icon_looking, [&nav]() { nav.push(); }}, + {"Scanner", Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push(); }}, + {"Microphone", Color::green(), &bitmap_icon_microphone, [&nav]() { nav.push(); }}, + {"Looking Glass", Color::green(), &bitmap_icon_looking, [&nav]() { nav.push(); }}, {"Utilities", Color::cyan(), &bitmap_icon_utilities, [&nav]() { nav.push(); }}, {"Settings", Color::cyan(), &bitmap_icon_setup, [&nav]() { nav.push(); }}, {"Debug", Color::light_grey(), &bitmap_icon_debug, [&nav]() { nav.push(); }}, diff --git a/firmware/common/ui.hpp b/firmware/common/ui.hpp index 8616bcf4..16769e2d 100644 --- a/firmware/common/ui.hpp +++ b/firmware/common/ui.hpp @@ -56,15 +56,20 @@ struct Color { } uint8_t to_greyscale() { - uint32_t r = ((v >> 11) & 31U) << 3; - uint32_t g = ((v >> 5) & 63U) << 2; - uint32_t b = (v & 31U) << 3; + uint32_t r = (v >> 8) & 0xf8; + uint32_t g = (v >> 3) & 0xfc; + uint32_t b = (v << 3) & 0xf8; - uint32_t grey = (r * 299 + g * 587 + b * 114) / 1000; + uint32_t grey = ((r * 306) + (g * 601) + (b * 117)) >> 10; return (uint8_t)grey; } + uint16_t dark() { + // stripping bits 4 & 5 from each of the colors R/G/B + return (v & ((0xc8 << 8) | (0xcc << 3) | (0xc8 >> 3))); + } + Color operator-() const { return (v ^ 0xffff); } diff --git a/firmware/common/ui_painter.cpp b/firmware/common/ui_painter.cpp index b6edd8e8..49d31da6 100644 --- a/firmware/common/ui_painter.cpp +++ b/firmware/common/ui_painter.cpp @@ -79,6 +79,10 @@ int Painter::draw_string( } void Painter::draw_bitmap(Point p, const Bitmap& bitmap, Color foreground, Color background) { + // If bright foreground colors on white background, darken the foreground color to improve visibility + if ((background.v == ui::Color::white().v) && (foreground.to_greyscale() > 175)) + foreground = foreground.dark(); + display.draw_bitmap(p, bitmap.size, bitmap.data, foreground, background); }