Skip to content

Commit f844748

Browse files
committed
7x13字体显示
1 parent 2cb0f25 commit f844748

File tree

11 files changed

+738
-101
lines changed

11 files changed

+738
-101
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ CSRC = $(STARTUPSRC) \
150150
$(STREAMSSRC) \
151151
$(SHELLSRC) \
152152
usbcfg.c \
153-
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c flash.c adc.c
153+
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont20x22.c Font7x13b.c Font5x7.c flash.c adc.c
154154

155155
# $(TESTSRC) \
156156

NANOVNA_STM32_F072/run_openocd

100755100644
File mode changed.

NANOVNA_STM32_F303/run_openocd

100755100644
File mode changed.

dfu.bat

100755100644
File mode changed.

ili9341.c

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,19 +463,20 @@ ili9341_read_memory_continue(int len, uint16_t* out)
463463
ili9341_read_memory_raw(0x3E, len, out);
464464
}
465465

466+
#if !defined(ST7796S)
466467
void
467468
ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg)
468469
{
469470
#if defined(ILI9488)
470471
ili9341_drawchar_size(ch, x, y, fg, bg, 1);
471472
#else
472473
uint16_t *buf = spi_buffer;
473-
uint8_t bits;
474+
uint16_t bits;
474475
int c, r;
475476
for(c = 0; c < 7; c++) {
476477
bits = x5x7_bits[(ch * 7) + c];
477478
for (r = 0; r < 5; r++) {
478-
*buf++ = (0x80 & bits) ? fg : bg;
479+
*buf++ = (0x8000 & bits) ? fg : bg;
479480
bits <<= 1;
480481
}
481482
}
@@ -506,12 +507,12 @@ void
506507
ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size)
507508
{
508509
uint16_t *buf = spi_buffer;
509-
uint8_t bits;
510+
uint16_t bits;
510511
int c, r;
511512
for(c = 0; c < 7*size; c++) {
512513
bits = x5x7_bits[(ch * 7) + (c / size)];
513514
for (r = 0; r < 5*size; r++) {
514-
*buf++ = (0x80 & bits) ? fg : bg;
515+
*buf++ = (0x8000 & bits) ? fg : bg;
515516
if (r % size == (size-1)) {
516517
bits <<= 1;
517518
}
@@ -530,6 +531,73 @@ ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg,
530531
}
531532
}
532533

534+
#else
535+
void
536+
ili9341_drawchar_7x13(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg)
537+
{
538+
uint16_t *buf = spi_buffer;
539+
uint16_t bits;
540+
int c, r;
541+
for(c = 0; c < 13; c++) {
542+
bits = x7x13b_bits[(ch * 13) + c];
543+
for (r = 0; r < 7; r++) {
544+
*buf++ = (0x8000 & bits) ? fg : bg;
545+
bits <<= 1;
546+
}
547+
}
548+
ili9341_bulk(x, y, 7, 13);
549+
}
550+
551+
void
552+
ili9341_drawstring_7x13(const char *str, int x, int y, uint16_t fg, uint16_t bg)
553+
{
554+
while (*str) {
555+
ili9341_drawchar_7x13(*str, x, y, fg, bg);
556+
x += 7;
557+
str++;
558+
}
559+
}
560+
561+
void
562+
ili9341_drawstring_7x13_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool invert)
563+
{
564+
if (invert)
565+
ili9341_drawstring_7x13(str, x, y, bg, fg);
566+
else
567+
ili9341_drawstring_7x13(str, x, y, fg, bg);
568+
}
569+
570+
571+
void
572+
ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size)
573+
{
574+
uint16_t *buf = spi_buffer;
575+
uint16_t bits;
576+
int c, r;
577+
for(c = 0; c < 13*size; c++) {
578+
bits = x7x13b_bits[(ch * 13) + (c / size)];
579+
for (r = 0; r < 7*size; r++) {
580+
*buf++ = (0x8000 & bits) ? fg : bg;
581+
if (r % size == (size-1)) {
582+
bits <<= 1;
583+
}
584+
}
585+
}
586+
ili9341_bulk(x, y, 7*size, 13*size);
587+
}
588+
589+
void
590+
ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size)
591+
{
592+
while (*str) {
593+
ili9341_drawchar_size(*str, x, y, fg, bg, size);
594+
x += 7 * size;
595+
str++;
596+
}
597+
}
598+
#endif
599+
600+
533601
#define SWAP(x,y) do { int z=x; x = y; y = z; } while(0)
534602

535603
void

nanovna.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ extern int area_width;
191191
extern int area_height;
192192

193193
// font
194-
194+
#if !defined(ST7796S)
195195
extern const uint8_t x5x7_bits [];
196+
#else
197+
extern const uint16_t x7x13b_bits [];
198+
#endif
196199
extern const uint8_t numfont20x22[][22 * 3];
197200

198201
#define S_PI "\034"
@@ -328,9 +331,15 @@ void ili9341_init(void);
328331
void ili9341_test(int mode);
329332
void ili9341_bulk(int x, int y, int w, int h);
330333
void ili9341_fill(int x, int y, int w, int h, int color);
334+
#if !defined(ST7796S)
331335
void ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg);
332336
void ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg);
333337
void ili9341_drawstring_5x7_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool inv);
338+
#else
339+
void ili9341_drawchar_7x13(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg);
340+
void ili9341_drawstring_7x13(const char *str, int x, int y, uint16_t fg, uint16_t bg);
341+
void ili9341_drawstring_7x13_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool inv);
342+
#endif
334343
void ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size);
335344
void ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size);
336345
void ili9341_drawfont(uint8_t ch, const font_t *font, int x, int y, uint16_t fg, uint16_t bg);

0 commit comments

Comments
 (0)