add ccache option and transparent color instead of bool (#2269)

* add ccache option and use language helper for proto view app

* add transparent color

* typo

* fix my typo

* fix my typo 2
This commit is contained in:
zxkmm 2024-09-28 20:50:37 +08:00 committed by GitHub
parent b3a0ad018c
commit 419bc75d2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 46 additions and 19 deletions

View File

@ -23,6 +23,8 @@ cmake_policy(SET CMP0005 NEW)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/firmware/toolchain-arm-cortex-m.cmake) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/firmware/toolchain-arm-cortex-m.cmake)
option(USE_CCACHE "Enable ccache, please keep an eye on this because sometimes it's not quite stable and generated unusable binary" OFF)
project(portapack-h1) project(portapack-h1)
set(EXPECTED_GCC_VERSION "9.2.1") set(EXPECTED_GCC_VERSION "9.2.1")
@ -72,13 +74,24 @@ set(HACKRF_CPLD_XSVF_PATH ${HACKRF_PATH}/firmware/cpld/sgpio_if/${HACKRF_CPLD_XS
set(HACKRF_FIRMWARE_DFU_IMAGE ${hackrf_usb_BINARY_DIR}/${HACKRF_FIRMWARE_DFU_FILENAME}) set(HACKRF_FIRMWARE_DFU_IMAGE ${hackrf_usb_BINARY_DIR}/${HACKRF_FIRMWARE_DFU_FILENAME})
set(HACKRF_FIRMWARE_BIN_IMAGE ${hackrf_usb_BINARY_DIR}/${HACKRF_FIRMWARE_BIN_FILENAME}) set(HACKRF_FIRMWARE_BIN_IMAGE ${hackrf_usb_BINARY_DIR}/${HACKRF_FIRMWARE_BIN_FILENAME})
# this seems causing some issues (ref. in discord discussions), so temporarily disabled, until figure out the pros and cons and bugs of this tool. # this seems causing some issues (ref. in discord discussions), but it sometimes do helps, so you have your choice to use. it's default disabled, unless you use such command:
#find_program(CCACHE "ccache") # cmake -DUSE_CCACHE=ON ..
#if(CCACHE) # `make` or `make -j` or `make -j10` etc
# set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE}) # the default behavior `cmake ..` isn't changed (aka don't use ccache)
# set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE}) message(STATUS "-------v ccache info--------")
# set(ENV{CCACHE_SLOPPINESS} pch_defines,time_macros) if(USE_CCACHE)
#endif(CCACHE) find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_FOUND})
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_FOUND})
message(STATUS "Using ccache, please keep an eye on this because sometimes it's not quite stable and generated unusable binary.\n-- use `cmake -DUSE_CCACHE=OFF ..` to turn off ccache")
else()
message(WARNING "ccache is enabled but not found on the system.")
endif()
else()
message(STATUS "Not using ccache, use `cmake -DUSE_CCACHE=ON ..` to turn on ccache")
endif()
message(STATUS "-------^ ccache info--------")
enable_testing() enable_testing()
add_subdirectory(firmware) add_subdirectory(firmware)

View File

@ -140,9 +140,9 @@ void ProtoView::draw() {
drawcnt = 0; drawcnt = 0;
for (uint16_t i = 0; i < MAXDRAWCNT; i++) waveform_buffer[i] = 0; // reset for (uint16_t i = 0; i < MAXDRAWCNT; i++) waveform_buffer[i] = 0; // reset
// add empty data for padding (so you can shift left/nagetive) // add empty data for padding (so you can shift left/negative)
if (waveform_shift < 0) { if (waveform_shift < 0) {
for (int32_t i = 0; (i < -1 * waveform_shift) && drawcnt < MAXDRAWCNT; // this is for shift nagetive (move to right) for (int32_t i = 0; (i < -1 * waveform_shift) && drawcnt < MAXDRAWCNT; // this is for shift negative (move to right)
++i) { ++i) {
waveform_buffer[drawcnt++] = 0; waveform_buffer[drawcnt++] = 0;
} }
@ -224,11 +224,11 @@ void ProtoView::set_pause(bool pause) {
if (pause) { if (pause) {
label_shift.hidden(false); label_shift.hidden(false);
number_shift.hidden(false); number_shift.hidden(false);
button_pause.set_text("Resume"); button_pause.set_text(LanguageHelper::currentMessages[LANG_RESUME]);
} else { } else {
label_shift.hidden(true); label_shift.hidden(true);
number_shift.hidden(true); number_shift.hidden(true);
button_pause.set_text("Pause"); button_pause.set_text(LanguageHelper::currentMessages[LANG_PAUSE]);
} }
set_dirty(); set_dirty();
} }

View File

@ -1007,7 +1007,7 @@ BMPView::BMPView(NavigationView& nav)
void BMPView::paint(Painter&) { void BMPView::paint(Painter&) {
if (!portapack::display.drawBMP2({0, 0}, splash_dot_bmp)) if (!portapack::display.drawBMP2({0, 0}, splash_dot_bmp))
portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, true); portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, (const uint8_t[]){0x29, 0x18, 0x16});
} }
bool BMPView::on_touch(const TouchEvent event) { bool BMPView::on_touch(const TouchEvent event) {
@ -1103,7 +1103,7 @@ ModalMessageView::ModalMessageView(
} }
void ModalMessageView::paint(Painter& painter) { void ModalMessageView::paint(Painter& painter) {
if (!compact) portapack::display.drawBMP({100, 48}, modal_warning_bmp, true); if (!compact) portapack::display.drawBMP({100, 48}, modal_warning_bmp, (const uint8_t[]){0, 0, 0});
// Break lines. // Break lines.
auto lines = split_string(message_, '\n'); auto lines = split_string(message_, '\n');

View File

@ -344,7 +344,20 @@ void ILI9341::render_box(const ui::Point p, const ui::Size s, const ui::Color* l
} }
// RLE_4 BMP loader (delta not implemented) // RLE_4 BMP loader (delta not implemented)
void ILI9341::drawBMP(const ui::Point p, const uint8_t* bitmap, const bool transparency) { /* draw transparent, pass transparent color as arg, usage inline anonymous obj
* portapack::display.drawBMP({100, 100}, foo_bmp, (const uint8_t[]){41, 24, 22}); // dec, out of {255, 255, 255}
* portapack::display.drawBMP({100, 100}, foo_bmp, (const uint8_t[]){0x29, 0x18, 0x16}); //hex out of {0xFF, 0xFF, 0xFF}
*
* draw transparent, pass transparent color as arg, usage pass uint8_t[] obj
* const uint8_t c[] = {41, 24, 22}; or const uint8_t c[3] = {0x29, 0x18, 0x16};
* portapack::display.drawBMP({100, 100}, foo_bmp, c);
*
* don't draw transparent, pass nullptr as arg, usage
* portapack::display.drawBMP({100, 100}, foo_bmp, nullptr);
*
* if your image use RLE compress as transparency methods, pass any valid color as arg, it doesn't matter (like the modal bmp. TODO: write RLE transparency generator)
* */
void ILI9341::drawBMP(const ui::Point p, const uint8_t* bitmap, const uint8_t* transparency_color) {
const bmp_header_t* bmp_header = (const bmp_header_t*)bitmap; const bmp_header_t* bmp_header = (const bmp_header_t*)bitmap;
uint32_t data_idx; uint32_t data_idx;
uint8_t by, c, count, transp_idx = 0; uint8_t by, c, count, transp_idx = 0;
@ -362,12 +375,13 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t* bitmap, const bool trans
// Convert palette and find pure magenta index (alpha color key) rgb dec(41,24,22) // Convert palette and find pure magenta index (alpha color key) rgb dec(41,24,22)
for (c = 0; c < 16; c++) { for (c = 0; c < 16; c++) {
palette[c] = ui::Color(bmp_palette->color[c].R, bmp_palette->color[c].G, bmp_palette->color[c].B); palette[c] = ui::Color(bmp_palette->color[c].R, bmp_palette->color[c].G, bmp_palette->color[c].B);
if ((bmp_palette->color[c].R == 0x29) && if (transparency_color &&
(bmp_palette->color[c].G == 0x18) && (bmp_palette->color[c].R == transparency_color[0]) &&
(bmp_palette->color[c].B == 0x16)) transp_idx = c; (bmp_palette->color[c].G == transparency_color[1]) &&
(bmp_palette->color[c].B == transparency_color[2])) transp_idx = c;
} }
if (!transparency) { if (!transparency_color) {
py = bmp_header->height + 16; py = bmp_header->height + 16;
do { do {
by = bitmap[data_idx++]; by = bitmap[data_idx++];

View File

@ -62,7 +62,7 @@ class ILI9341 {
const ui::Color background); const ui::Color background);
void draw_pixel(const ui::Point p, const ui::Color color); void draw_pixel(const ui::Point p, const ui::Color color);
void drawBMP(const ui::Point p, const uint8_t* bitmap, const bool transparency); void drawBMP(const ui::Point p, const uint8_t* bitmap, const uint8_t* transparency_color);
bool drawBMP2(const ui::Point p, const std::filesystem::path& file); bool drawBMP2(const ui::Point p, const std::filesystem::path& file);
void render_line(const ui::Point p, const uint8_t count, const ui::Color* line_buffer); void render_line(const ui::Point p, const uint8_t count, const ui::Color* line_buffer);
void render_box(const ui::Point p, const ui::Size s, const ui::Color* line_buffer); void render_box(const ui::Point p, const ui::Size s, const ui::Color* line_buffer);