mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
use RLE compressed fonts on Horus
This commit is contained in:
parent
caaba0ab3f
commit
96afa57d84
10 changed files with 106 additions and 14 deletions
|
@ -8,7 +8,7 @@ if(PCB STREQUAL X12S)
|
||||||
add_bitmaps_target(x12s_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits)
|
add_bitmaps_target(x12s_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits)
|
||||||
add_bitmaps_target(x12s_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits)
|
add_bitmaps_target(x12s_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits)
|
||||||
add_bitmaps_target(x12s_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5)
|
add_bitmaps_target(x12s_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5)
|
||||||
add_bitmaps_target(x12s_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits)
|
add_bitmaps_target(x12s_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits rle)
|
||||||
add_bitmaps_target(x12s_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
|
add_bitmaps_target(x12s_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
|
||||||
add_bitmaps_target(x12s_bootloader_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/bmp_*.png 480 5/6/5)
|
add_bitmaps_target(x12s_bootloader_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/bmp_*.png 480 5/6/5)
|
||||||
add_bitmaps_target(x12s_bootloader_icons ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/icon_*.png 480 8bits)
|
add_bitmaps_target(x12s_bootloader_icons ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/icon_*.png 480 8bits)
|
||||||
|
@ -23,7 +23,7 @@ else()
|
||||||
add_bitmaps_target(x10_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits)
|
add_bitmaps_target(x10_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits)
|
||||||
add_bitmaps_target(x10_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits)
|
add_bitmaps_target(x10_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits)
|
||||||
add_bitmaps_target(x10_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5-R)
|
add_bitmaps_target(x10_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5-R)
|
||||||
add_bitmaps_target(x10_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits)
|
add_bitmaps_target(x10_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits rle)
|
||||||
add_bitmaps_target(x10_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
|
add_bitmaps_target(x10_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
|
||||||
add_bitmaps_target(x10_bootloader_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/bmp_*.png 480 5/6/5-R)
|
add_bitmaps_target(x10_bootloader_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/bmp_*.png 480 5/6/5-R)
|
||||||
add_bitmaps_target(x10_bootloader_icons ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/icon_*.png 480 8bits)
|
add_bitmaps_target(x10_bootloader_icons ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/icon_*.png 480 8bits)
|
||||||
|
|
|
@ -24,17 +24,17 @@
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
|
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
extern const uint16_t * const fontspecsTable[16];
|
#define FONT_TABLE_SIZE 16
|
||||||
extern const uint8_t * const fontsTable[16];
|
|
||||||
#else
|
#else
|
||||||
extern const uint16_t * const fontspecsTable[1];
|
#define FONT_TABLE_SIZE 1
|
||||||
extern const uint8_t * const fontsTable[1];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBHORUS)
|
extern const uint16_t * const fontspecsTable[FONT_TABLE_SIZE];
|
||||||
extern BitmapBuffer * fontCache[2];
|
extern const uint8_t * fontsTable[FONT_TABLE_SIZE];
|
||||||
|
extern BitmapBuffer * fontCache[2];
|
||||||
|
|
||||||
void loadFontCache();
|
void loadFontCache();
|
||||||
#endif
|
void loadFonts();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
#include "rle.h"
|
||||||
|
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
const uint16_t font_tinsize_specs[] = {
|
const uint16_t font_tinsize_specs[] = {
|
||||||
|
@ -82,17 +83,18 @@ const pm_uchar font_stdsizebold[] = {
|
||||||
|
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
const uint16_t * const fontspecsTable[16] = {
|
const uint16_t * const fontspecsTable[16] = {
|
||||||
font_stdsize_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs,
|
font_stdsize_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs,
|
||||||
font_stdsizebold_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs
|
font_stdsizebold_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t * const fontsTable[16] = {
|
const uint8_t * fontsTable[16] = {
|
||||||
font_stdsize, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize,
|
font_stdsize, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize,
|
||||||
font_stdsizebold, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize
|
font_stdsizebold, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
const uint16_t * const fontspecsTable[1] = { font_stdsize_specs };
|
const uint16_t * const fontspecsTable[1] = { font_stdsize_specs };
|
||||||
const uint8_t * const fontsTable[1] = { font_stdsize };
|
const uint8_t * fontsTable[1] = { font_stdsize };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BitmapBuffer * fontCache[2] = { NULL, NULL };
|
BitmapBuffer * fontCache[2] = { NULL, NULL };
|
||||||
|
@ -117,3 +119,38 @@ void loadFontCache()
|
||||||
fontCache[0] = createFontCache(fontsTable[0], TEXT_COLOR, TEXT_BGCOLOR);
|
fontCache[0] = createFontCache(fontsTable[0], TEXT_COLOR, TEXT_BGCOLOR);
|
||||||
fontCache[1] = createFontCache(fontsTable[0], TEXT_INVERTED_COLOR, TEXT_INVERTED_BGCOLOR);
|
fontCache[1] = createFontCache(fontsTable[0], TEXT_INVERTED_COLOR, TEXT_INVERTED_BGCOLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t* decompressFont(const uint8_t* font)
|
||||||
|
{
|
||||||
|
uint16_t width = *((uint16_t *)font);
|
||||||
|
uint16_t height = *(((uint16_t *)font)+1);
|
||||||
|
|
||||||
|
size_t font_size = width * height;
|
||||||
|
uint8_t* dec_buf = (uint8_t*)malloc(font_size + 4);
|
||||||
|
|
||||||
|
// copy width / height
|
||||||
|
memcpy(dec_buf,font,4);
|
||||||
|
|
||||||
|
rle_decode_8bit(dec_buf+4, font_size, font+4);
|
||||||
|
return dec_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadFonts()
|
||||||
|
{
|
||||||
|
static bool fonts_loaded = false;
|
||||||
|
if (fonts_loaded) return;
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
|
int i=0;
|
||||||
|
for (; i<9; i++)
|
||||||
|
fontsTable[i] = decompressFont(fontsTable[i]);
|
||||||
|
|
||||||
|
for (; i<16; i++)
|
||||||
|
fontsTable[i] = fontsTable[i-9];
|
||||||
|
#else
|
||||||
|
fontsTable[0] = decompressFont(fontsTable[0]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fonts_loaded = true;
|
||||||
|
}
|
||||||
|
|
38
radio/src/gui/480x272/rle.cpp
Normal file
38
radio/src/gui/480x272/rle.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#include "rle.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int rle_decode_8bit(unsigned char* dest, unsigned int dest_size, const unsigned char* src)
|
||||||
|
{
|
||||||
|
//unsigned char count = 0;
|
||||||
|
unsigned char prev_byte = 0;
|
||||||
|
bool prev_byte_valid = false;
|
||||||
|
|
||||||
|
const unsigned char* dest_end = dest + dest_size;
|
||||||
|
unsigned char* d = dest;
|
||||||
|
|
||||||
|
while(d < dest_end) {
|
||||||
|
|
||||||
|
*d++ = *src;
|
||||||
|
if (prev_byte_valid && (*src == prev_byte)) {
|
||||||
|
|
||||||
|
src++;
|
||||||
|
|
||||||
|
if (d + *src > dest + dest_size) {
|
||||||
|
TRACE("rle_decode_8bit: destination overflow!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(d, prev_byte, *src);
|
||||||
|
d += *src++;
|
||||||
|
prev_byte_valid = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prev_byte = *src++;
|
||||||
|
prev_byte_valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return d - dest;
|
||||||
|
}
|
7
radio/src/gui/480x272/rle.h
Normal file
7
radio/src/gui/480x272/rle.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef _rle_h_
|
||||||
|
#define _rle_h_
|
||||||
|
|
||||||
|
int rle_decode_8bit(unsigned char* dest, unsigned int dest_size, const unsigned char* src);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -2201,6 +2201,11 @@ int main()
|
||||||
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE); //BT is turn on for a brief period to differentiate X7 and X7S
|
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE); //BT is turn on for a brief period to differentiate X7 and X7S
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBHORUS)
|
||||||
|
loadFonts();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(GUI) && !defined(PCBTARANIS) && !defined(PCBHORUS)
|
#if defined(GUI) && !defined(PCBTARANIS) && !defined(PCBHORUS)
|
||||||
// TODO remove this
|
// TODO remove this
|
||||||
lcdInit();
|
lcdInit();
|
||||||
|
|
|
@ -93,6 +93,7 @@ else()
|
||||||
../../../../../targets/common/arm/stm32/sdio_sd.c
|
../../../../../targets/common/arm/stm32/sdio_sd.c
|
||||||
../../../../../targets/${TARGET_DIR}/haptic_driver.cpp
|
../../../../../targets/${TARGET_DIR}/haptic_driver.cpp
|
||||||
../../../../../gui/${GUI_DIR}/bitmapbuffer.cpp
|
../../../../../gui/${GUI_DIR}/bitmapbuffer.cpp
|
||||||
|
../../../../../gui/${GUI_DIR}/rle.cpp
|
||||||
../../../../../syscalls.c
|
../../../../../syscalls.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ set(GUI_SRC
|
||||||
${THEMES_SRC}
|
${THEMES_SRC}
|
||||||
${LAYOUTS_SRC}
|
${LAYOUTS_SRC}
|
||||||
${WIDGETS_SRC}
|
${WIDGETS_SRC}
|
||||||
|
rle.cpp
|
||||||
)
|
)
|
||||||
if(DISK_CACHE)
|
if(DISK_CACHE)
|
||||||
set(SRC ${SRC} disk_cache.cpp)
|
set(SRC ${SRC} disk_cache.cpp)
|
||||||
|
|
|
@ -40,6 +40,9 @@ void bootloaderInitScreen()
|
||||||
lcdColorTable[BARGRAPH2_COLOR_INDEX] = RGB(73, 219, 62); // green
|
lcdColorTable[BARGRAPH2_COLOR_INDEX] = RGB(73, 219, 62); // green
|
||||||
|
|
||||||
backlightEnable(BACKLIGHT_LEVEL_MAX);
|
backlightEnable(BACKLIGHT_LEVEL_MAX);
|
||||||
|
|
||||||
|
//TODO: load/decompress bitmaps
|
||||||
|
loadFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bootloaderDrawTitle(unsigned int x, const char* text)
|
static void bootloaderDrawTitle(unsigned int x, const char* text)
|
||||||
|
|
|
@ -91,7 +91,7 @@ with open(output_filename, "w") as f:
|
||||||
extension = os.path.splitext(output_filename)[1]
|
extension = os.path.splitext(output_filename)[1]
|
||||||
out = F_writeValue(f)
|
out = F_writeValue(f)
|
||||||
|
|
||||||
if extension == ".rle":
|
if extension == ".rle" or ((len(sys.argv) > 5) and (sys.argv[5] == "rle")):
|
||||||
encoder = RLE_encoder(out)
|
encoder = RLE_encoder(out)
|
||||||
else:
|
else:
|
||||||
encoder = dummy_encoder(out)
|
encoder = dummy_encoder(out)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue