mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-04-22 14:21:49 +00:00
Added fonts viewer (debug) app (#1251)
* Added fonts viewer (debug) app * Added fonts viewer (debug) app * Clang * Use degree symbol vs asterisk for latitude/longitude degrees * Save a few bytes by not overriding on_key * Save a few bytes by not overriding on_key * Clang
This commit is contained in:
parent
a09c0e4c2d
commit
60de625c37
@ -30,6 +30,9 @@
|
|||||||
#include "audio.hpp"
|
#include "audio.hpp"
|
||||||
|
|
||||||
#include "ui_sd_card_debug.hpp"
|
#include "ui_sd_card_debug.hpp"
|
||||||
|
#include "ui_font_fixed_8x16.hpp"
|
||||||
|
#include "ui_styles.hpp"
|
||||||
|
#include "ui_painter.hpp"
|
||||||
|
|
||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
#include "portapack_persistent_memory.hpp"
|
#include "portapack_persistent_memory.hpp"
|
||||||
@ -401,6 +404,7 @@ DebugMenuView::DebugMenuView(NavigationView& nav) {
|
|||||||
{"Temperature", ui::Color::dark_cyan(), &bitmap_icon_temperature, [&nav]() { nav.push<TemperatureView>(); }},
|
{"Temperature", ui::Color::dark_cyan(), &bitmap_icon_temperature, [&nav]() { nav.push<TemperatureView>(); }},
|
||||||
{"Buttons Test", ui::Color::dark_cyan(), &bitmap_icon_controls, [&nav]() { nav.push<DebugControlsView>(); }},
|
{"Buttons Test", ui::Color::dark_cyan(), &bitmap_icon_controls, [&nav]() { nav.push<DebugControlsView>(); }},
|
||||||
{"P.Memory", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { nav.push<DebugPmemView>(); }},
|
{"P.Memory", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { nav.push<DebugPmemView>(); }},
|
||||||
|
{"Fonts Viewer", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push<DebugFontsView>(); }},
|
||||||
{"Debug Dump", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { portapack::persistent_memory::debug_dump(); }},
|
{"Debug Dump", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { portapack::persistent_memory::debug_dump(); }},
|
||||||
});
|
});
|
||||||
set_max_rows(2); // allow wider buttons
|
set_max_rows(2); // allow wider buttons
|
||||||
@ -462,6 +466,43 @@ uint32_t DebugPmemView::registers_widget_feed(const size_t register_number) {
|
|||||||
return data.regfile[(page_size * page + register_number) / 4] >> (register_number % 4 * 8);
|
return data.regfile[(page_size * page + register_number) / 4] >> (register_number % 4 * 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DebugFontsView *******************************************************/
|
||||||
|
|
||||||
|
uint16_t DebugFontsView::display_font(Painter& painter, uint16_t y_offset, const Style* font_style, std::string_view font_name) {
|
||||||
|
auto char_width{font_style->font.char_width()};
|
||||||
|
auto char_height{font_style->font.line_height()};
|
||||||
|
auto cpl{((screen_width / char_width) - 6) & 0xF8}; // Display a multiple of 8 characters per line
|
||||||
|
uint16_t line_pos{y_offset};
|
||||||
|
|
||||||
|
painter.draw_string({0, y_offset}, *font_style, font_name);
|
||||||
|
|
||||||
|
// Displaying ASCII+extended characters from 0x20 to 0xFF
|
||||||
|
for (uint8_t c = 0; c <= 0xDF; c++) {
|
||||||
|
line_pos = y_offset + ((c / cpl) + 2) * char_height;
|
||||||
|
|
||||||
|
if ((c % cpl) == 0)
|
||||||
|
painter.draw_string({0, line_pos}, *font_style, "Ox" + to_string_hex(c + 0x20, 2));
|
||||||
|
|
||||||
|
painter.draw_char({((c % cpl) + 5) * char_width, line_pos}, *font_style, (char)(c + 0x20));
|
||||||
|
}
|
||||||
|
|
||||||
|
return line_pos + char_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugFontsView::paint(Painter& painter) {
|
||||||
|
int16_t line_pos;
|
||||||
|
|
||||||
|
line_pos = display_font(painter, 32, &Styles::white, "Fixed 8x16");
|
||||||
|
display_font(painter, line_pos + 16, &Styles::white_small, "Fixed 5x8");
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugFontsView::DebugFontsView(NavigationView& nav)
|
||||||
|
: nav_{nav} {
|
||||||
|
set_focusable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DebugLCRView *******************************************************/
|
||||||
|
|
||||||
/*DebugLCRView::DebugLCRView(NavigationView& nav, std::string lcr_string) {
|
/*DebugLCRView::DebugLCRView(NavigationView& nav, std::string lcr_string) {
|
||||||
|
|
||||||
std::string debug_text;
|
std::string debug_text;
|
||||||
|
@ -310,6 +310,17 @@ class DebugPmemView : public View {
|
|||||||
uint32_t registers_widget_feed(const size_t register_number);
|
uint32_t registers_widget_feed(const size_t register_number);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DebugFontsView : public View {
|
||||||
|
public:
|
||||||
|
DebugFontsView(NavigationView& nav);
|
||||||
|
void paint(Painter& painter) override;
|
||||||
|
std::string title() const override { return "Fonts"; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16_t display_font(Painter& painter, uint16_t y_offset, const Style* font_style, std::string_view font_name);
|
||||||
|
NavigationView& nav_;
|
||||||
|
};
|
||||||
|
|
||||||
/*class DebugLCRView : public View {
|
/*class DebugLCRView : public View {
|
||||||
public:
|
public:
|
||||||
DebugLCRView(NavigationView& nav, std::string lcrstring);
|
DebugLCRView(NavigationView& nav, std::string lcrstring);
|
||||||
|
@ -84,8 +84,8 @@ class GeoPos : public View {
|
|||||||
|
|
||||||
Labels labels_position{
|
Labels labels_position{
|
||||||
{{1 * 8, 0 * 16}, "Alt:", Color::light_grey()},
|
{{1 * 8, 0 * 16}, "Alt:", Color::light_grey()},
|
||||||
{{1 * 8, 1 * 16}, "Lat: * ' \"", Color::light_grey()}, // No ° symbol in 8x16 font
|
{{1 * 8, 1 * 16}, "Lat: \x90 ' \"", Color::light_grey()}, // 0x90 is degree ° symbol in our 8x16 font
|
||||||
{{1 * 8, 2 * 16}, "Lon: * ' \"", Color::light_grey()},
|
{{1 * 8, 2 * 16}, "Lon: \x90 ' \"", Color::light_grey()},
|
||||||
};
|
};
|
||||||
|
|
||||||
NumberField field_altitude{
|
NumberField field_altitude{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user