diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index e874eb60..e2ab322d 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -28,9 +28,9 @@ //BUG: RDS doesn't stop baseband when stopping tx ? //TEST: Imperial in whipcalc -//TEST: Numbers -//TODO: Use TransmitterView in ADSB, Morse, TEDI/LCR, Numbers, whistle, jammer... +//TODO: Use Labels widget wherever possible +//TODO: Use TransmitterView in Morse, TEDI/LCR, Numbers, whistle, jammer... //TODO: FreqMan: Add and rename categories //TODO: FreqMan: Sort by category in edit screen //TODO: FreqMan: Cap entry count per category (only done for total entries right now) diff --git a/firmware/application/ui_afsksetup.cpp b/firmware/application/ui_afsksetup.cpp index 3fa174aa..ca968624 100644 --- a/firmware/application/ui_afsksetup.cpp +++ b/firmware/application/ui_afsksetup.cpp @@ -69,19 +69,13 @@ AFSKSetupView::AFSKSetupView( size_t i; add_children({ - &text_setfreq, + &labels, &button_setfreq, - &text_bps, &options_bps, - &text_mark, &field_mark, - &text_space, &field_space, - &text_bw, &field_bw, - &text_repeat, &field_repeat, - &text_format, &options_format, &button_save }); diff --git a/firmware/application/ui_afsksetup.hpp b/firmware/application/ui_afsksetup.hpp index 77fa7960..a8fa5c44 100644 --- a/firmware/application/ui_afsksetup.hpp +++ b/firmware/application/ui_afsksetup.hpp @@ -39,19 +39,21 @@ public: private: void update_freq(rf::Frequency f); - Text text_setfreq { - { 8, 32, 104, 16 }, - "Frequency:" + Labels labels { + { { 1 * 8, 4 * 8 }, "Frequency:", Color::light_grey() }, + { { 16 * 8, 5 * 8 }, "Speed:", Color::light_grey() }, + { { 2 * 8, 13 * 8 }, "Mark: Hz", Color::light_grey() }, + { { 2 * 8, 15 * 8 }, "Space: Hz", Color::light_grey() }, + { { 140, 13 * 8 }, "BW: kHz", Color::light_grey() }, + { { 140, 15 * 8 }, "Repeat:", Color::light_grey() }, + { { 2 * 8, 19 * 8 }, "Format:", Color::light_grey() } }; + Button button_setfreq { { 8, 48, 104, 32 }, "----.----" }; - - Text text_bps { - { 128, 40, 104, 16 }, - "Speed:" - }; + OptionsField options_bps { { 128, 60 }, 7, @@ -63,11 +65,7 @@ private: { "9600bps", 9600 } } }; - - Text text_mark { - { 16, 104, 48, 16 }, - "Mark: Hz" - }; + NumberField field_mark { { 64, 104 }, 5, @@ -76,10 +74,6 @@ private: ' ' }; - Text text_space { - { 16, 120, 48, 16 }, - "Space: Hz" - }; NumberField field_space { { 64, 120 }, 5, @@ -88,10 +82,6 @@ private: ' ' }; - Text text_bw { - { 140, 104, 80, 16 }, - "BW: kHz" - }; NumberField field_bw { { 172, 104 }, 2, @@ -100,10 +90,6 @@ private: ' ' }; - Text text_repeat { - { 140, 120, 64, 16 }, - "Repeat: " - }; NumberField field_repeat { { 204, 120 }, 2, @@ -112,10 +98,6 @@ private: ' ' }; - Text text_format { - { 16, 152, 7 * 8, 16 }, - "Format:" - }; OptionsField options_format { { 80, 152 }, 10, diff --git a/firmware/application/ui_pocsag_tx.cpp b/firmware/application/ui_pocsag_tx.cpp index 2aef6443..7756c4fa 100644 --- a/firmware/application/ui_pocsag_tx.cpp +++ b/firmware/application/ui_pocsag_tx.cpp @@ -119,7 +119,7 @@ bool POCSAGTXView::start_tx() { void POCSAGTXView::paint(Painter&) { message = buffer; - text_message.set("Message:" + message); + text_message.set(message); } void POCSAGTXView::on_set_text(NavigationView& nav) { @@ -134,11 +134,9 @@ POCSAGTXView::POCSAGTXView( baseband::run_image(portapack::spi_flash::image_tag_fsktx); add_children({ - &text_bitrate, + &labels, &options_bitrate, - &text_address, &field_address, - &text_type, &options_type, &text_message, &button_message, diff --git a/firmware/application/ui_pocsag_tx.hpp b/firmware/application/ui_pocsag_tx.hpp index 1cbb7137..19cd2ada 100644 --- a/firmware/application/ui_pocsag_tx.hpp +++ b/firmware/application/ui_pocsag_tx.hpp @@ -26,7 +26,6 @@ #include "ui.hpp" #include "ui_widget.hpp" #include "ui_navigation.hpp" -#include "ui_font_fixed_8x16.hpp" #include "ui_receiver.hpp" #include "ui_transmitter.hpp" #include "ui_textentry.hpp" @@ -68,10 +67,13 @@ private: void on_tx_progress(const int progress, const bool done); bool start_tx(); - Text text_bitrate { - { 3 * 8, 4 * 8, 8 * 8, 16 }, - "Bitrate:" + Labels labels { + { { 3 * 8, 4 * 8 }, "Bitrate:", Color::light_grey() }, + { { 3 * 8, 6 * 8 }, "Address:", Color::light_grey() }, + { { 6 * 8, 8 * 8 }, "Type:", Color::light_grey() }, + { { 3 * 8, 12 * 8 }, "Message:", Color::light_grey() } }; + OptionsField options_bitrate { { 11 * 8, 4 * 8 }, 8, @@ -81,21 +83,13 @@ private: { "2400 bps", 2 } } }; - - Text text_address { - { 3 * 8, 6 * 8, 8 * 8, 16 }, - "Address:" - }; + SymField field_address { { 11 * 8, 6 * 8 }, 7, SymField::SYMFIELD_DEC }; - Text text_type { - { 6 * 8, 8 * 8, 5 * 8, 16 }, - "Type:" - }; OptionsField options_type { { 11 * 8, 8 * 8 }, 12, @@ -107,9 +101,10 @@ private: }; Text text_message { - { 3 * 8, 12 * 8, 16 * 8, 16 }, + { 11 * 8, 12 * 8, 16 * 8, 16 }, "" }; + Button button_message { { 3 * 8, 14 * 8, 8 * 8, 28 }, "Set" diff --git a/firmware/common/ui_painter.cpp b/firmware/common/ui_painter.cpp index c315e3f9..70286594 100644 --- a/firmware/common/ui_painter.cpp +++ b/firmware/common/ui_painter.cpp @@ -42,11 +42,14 @@ int Painter::draw_char(const Point p, const Style& style, const char c) { return glyph.advance().x(); } -int Painter::draw_string(Point p, const Style& style, const std::string text) { +int Painter::draw_string(Point p, const Font& font, const Color foreground, + const Color background, const std::string text) { + size_t width = 0; + for(const auto c : text) { - const auto glyph = style.font.glyph(c); - display.draw_glyph(p, glyph, style.foreground, style.background); + const auto glyph = font.glyph(c); + display.draw_glyph(p, glyph, foreground, background); const auto advance = glyph.advance(); p += advance; width += advance.x(); @@ -54,6 +57,10 @@ int Painter::draw_string(Point p, const Style& style, const std::string text) { return width; } +int Painter::draw_string(Point p, const Style& style, const std::string text) { + return draw_string(p, style.font, style.foreground, style.background, text); +} + void Painter::draw_bitmap(const Point p, const Bitmap& bitmap, const Color foreground, const Color background) { display.draw_bitmap(p, bitmap.size, bitmap.data, foreground, background); } diff --git a/firmware/common/ui_painter.hpp b/firmware/common/ui_painter.hpp index 84afa2b9..b2ea2662 100644 --- a/firmware/common/ui_painter.hpp +++ b/firmware/common/ui_painter.hpp @@ -48,6 +48,8 @@ public: int draw_char(const Point p, const Style& style, const char c); + int draw_string(Point p, const Font& font, const Color foreground, + const Color background, const std::string text); int draw_string(Point p, const Style& style, const std::string text); void draw_bitmap(const Point p, const Bitmap& bitmap, const Color background, const Color foreground); diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index f775aacd..af2f87f7 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -352,27 +352,26 @@ void Text::paint(Painter& painter) { /* Labels ****************************************************************/ Labels::Labels( - std::vector