Skip to content

Commit

Permalink
chore: reduce foot-print of numfont20x24
Browse files Browse the repository at this point in the history
  • Loading branch information
edy555 committed Oct 21, 2019
1 parent dcbcfe1 commit 7adba06
Show file tree
Hide file tree
Showing 6 changed files with 650 additions and 694 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ CSRC = $(STARTUPSRC) \
$(STREAMSSRC) \
$(SHELLSRC) \
usbcfg.c \
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont20x24.c Font5x7.c flash.c adc.c
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c flash.c adc.c

# $(TESTSRC) \
Expand Down
35 changes: 18 additions & 17 deletions ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,27 +426,28 @@ ili9341_line(int x0, int y0, int x1, int y1, uint16_t fg)
}


const font_t NF20x24 = { 20, 24, 1, 24, (const uint32_t *)numfont20x24 };
//const font_t NF32x24 = { 32, 24, 1, 24, (const uint32_t *)numfont32x24 };
//const font_t NF32x48 = { 32, 48, 2, 24, (const uint32_t *)numfont32x24 };
const font_t NF20x22 = { 20, 22, 1, 3*22, (const uint8_t *)numfont20x22 };

void
ili9341_drawfont(uint8_t ch, const font_t *font, int x, int y, uint16_t fg, uint16_t bg)
{
uint16_t *buf = spi_buffer;
uint32_t bits;
const uint32_t *bitmap = &font->bitmap[font->slide * ch];
int c, r, j;

for (c = 0; c < font->slide; c++) {
for (j = 0; j < font->scaley; j++) {
bits = bitmap[c];
for (r = 0; r < font->width; r++) {
*buf++ = (0x80000000UL & bits) ? fg : bg;
bits <<= 1;
}
}
}
const uint8_t *bitmap = &font->bitmap[font->slide * ch];
int c, r;

for (c = 0; c < font->height; c++) {
uint8_t bits = *bitmap++;
uint8_t m = 0x80;
for (r = 0; r < font->width; r++) {
*buf++ = (bits & m) ? fg : bg;
m >>= 1;

if (m == 0) {
bits = *bitmap++;
m = 0x80;
}
}
}
ili9341_bulk(x, y, font->width, font->height);
}

Expand Down Expand Up @@ -485,7 +486,7 @@ ili9341_test(int mode)
#if 1
case 3:
for (i = 0; i < 10; i++)
ili9341_drawfont(i, &NF20x24, i*20, 120, colormap[i%6], 0x0000);
ili9341_drawfont(i, &NF20x22, i*20, 120, colormap[i%6], 0x0000);
break;
#endif
#if 0
Expand Down
6 changes: 3 additions & 3 deletions nanovna.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ extern int area_height;
// font

extern const uint8_t x5x7_bits [];
extern const uint32_t numfont20x24[][24];
extern const uint8_t numfont20x22[][22 * 3];

#define S_PI "\034"
#define S_MICRO "\035"
Expand Down Expand Up @@ -269,10 +269,10 @@ typedef struct {
uint16_t height;
uint16_t scaley;
uint16_t slide;
const uint32_t *bitmap;
const uint8_t *bitmap;
} font_t;

extern const font_t NF20x24;
extern const font_t NF20x22;

extern uint16_t spi_buffer[1024];

Expand Down
Loading

0 comments on commit 7adba06

Please sign in to comment.