Skip to content

Commit

Permalink
7x13字体显示
Browse files Browse the repository at this point in the history
  • Loading branch information
hugen79 committed Nov 20, 2019
1 parent 2cb0f25 commit f844748
Show file tree
Hide file tree
Showing 11 changed files with 738 additions and 101 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ CSRC = $(STARTUPSRC) \
$(STREAMSSRC) \
$(SHELLSRC) \
usbcfg.c \
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c flash.c adc.c
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont20x22.c Font7x13b.c Font5x7.c flash.c adc.c

# $(TESTSRC) \
Expand Down
Empty file modified NANOVNA_STM32_F072/run_openocd
100755 → 100644
Empty file.
Empty file modified NANOVNA_STM32_F303/run_openocd
100755 → 100644
Empty file.
Empty file modified dfu.bat
100755 → 100644
Empty file.
76 changes: 72 additions & 4 deletions ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,19 +463,20 @@ ili9341_read_memory_continue(int len, uint16_t* out)
ili9341_read_memory_raw(0x3E, len, out);
}

#if !defined(ST7796S)
void
ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg)
{
#if defined(ILI9488)
ili9341_drawchar_size(ch, x, y, fg, bg, 1);
#else
uint16_t *buf = spi_buffer;
uint8_t bits;
uint16_t bits;
int c, r;
for(c = 0; c < 7; c++) {
bits = x5x7_bits[(ch * 7) + c];
for (r = 0; r < 5; r++) {
*buf++ = (0x80 & bits) ? fg : bg;
*buf++ = (0x8000 & bits) ? fg : bg;
bits <<= 1;
}
}
Expand Down Expand Up @@ -506,12 +507,12 @@ void
ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size)
{
uint16_t *buf = spi_buffer;
uint8_t bits;
uint16_t bits;
int c, r;
for(c = 0; c < 7*size; c++) {
bits = x5x7_bits[(ch * 7) + (c / size)];
for (r = 0; r < 5*size; r++) {
*buf++ = (0x80 & bits) ? fg : bg;
*buf++ = (0x8000 & bits) ? fg : bg;
if (r % size == (size-1)) {
bits <<= 1;
}
Expand All @@ -530,6 +531,73 @@ ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg,
}
}

#else
void
ili9341_drawchar_7x13(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg)
{
uint16_t *buf = spi_buffer;
uint16_t bits;
int c, r;
for(c = 0; c < 13; c++) {
bits = x7x13b_bits[(ch * 13) + c];
for (r = 0; r < 7; r++) {
*buf++ = (0x8000 & bits) ? fg : bg;
bits <<= 1;
}
}
ili9341_bulk(x, y, 7, 13);
}

void
ili9341_drawstring_7x13(const char *str, int x, int y, uint16_t fg, uint16_t bg)
{
while (*str) {
ili9341_drawchar_7x13(*str, x, y, fg, bg);
x += 7;
str++;
}
}

void
ili9341_drawstring_7x13_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool invert)
{
if (invert)
ili9341_drawstring_7x13(str, x, y, bg, fg);
else
ili9341_drawstring_7x13(str, x, y, fg, bg);
}


void
ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size)
{
uint16_t *buf = spi_buffer;
uint16_t bits;
int c, r;
for(c = 0; c < 13*size; c++) {
bits = x7x13b_bits[(ch * 13) + (c / size)];
for (r = 0; r < 7*size; r++) {
*buf++ = (0x8000 & bits) ? fg : bg;
if (r % size == (size-1)) {
bits <<= 1;
}
}
}
ili9341_bulk(x, y, 7*size, 13*size);
}

void
ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size)
{
while (*str) {
ili9341_drawchar_size(*str, x, y, fg, bg, size);
x += 7 * size;
str++;
}
}
#endif


#define SWAP(x,y) do { int z=x; x = y; y = z; } while(0)

void
Expand Down
11 changes: 10 additions & 1 deletion nanovna.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ extern int area_width;
extern int area_height;

// font

#if !defined(ST7796S)
extern const uint8_t x5x7_bits [];
#else
extern const uint16_t x7x13b_bits [];
#endif
extern const uint8_t numfont20x22[][22 * 3];

#define S_PI "\034"
Expand Down Expand Up @@ -328,9 +331,15 @@ void ili9341_init(void);
void ili9341_test(int mode);
void ili9341_bulk(int x, int y, int w, int h);
void ili9341_fill(int x, int y, int w, int h, int color);
#if !defined(ST7796S)
void ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg);
void ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg);
void ili9341_drawstring_5x7_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool inv);
#else
void ili9341_drawchar_7x13(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg);
void ili9341_drawstring_7x13(const char *str, int x, int y, uint16_t fg, uint16_t bg);
void ili9341_drawstring_7x13_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool inv);
#endif
void ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size);
void ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size);
void ili9341_drawfont(uint8_t ch, const font_t *font, int x, int y, uint16_t fg, uint16_t bg);
Expand Down
Loading

0 comments on commit f844748

Please sign in to comment.