Compressed 5x7 font to 8 bit and removed unneeded characters to get some space in flash.

This commit is contained in:
Dennis Real 2019-09-22 18:09:53 +02:00
parent e89c9bd6a7
commit c848019f54
5 changed files with 1731 additions and 2133 deletions

3760
Font5x7.c

File diff suppressed because it is too large Load diff

View file

@ -101,3 +101,4 @@ Hardware design material is disclosed to prevent bad quality clone. Please let m
* [@hugen79](https://github.com/hugen79)
* [@cho45](https://github.com/cho45)
* DL9CAT

View file

@ -334,22 +334,31 @@ ili9341_read_memory_continue(int len, uint16_t* out)
ili9341_read_memory_raw(0x3E, len, out);
}
void
ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg)
{
uint16_t *buf = spi_buffer;
uint16_t bits;
uint8_t bits;
int c, r;
for(c = 0; c < 7; c++) {
ch = x5x7_map_char_table(ch);
for(c = 0; c < 7; c++)
{
bits = x5x7_bits[(ch * 7) + c];
for (r = 0; r < 5; r++) {
*buf++ = (0x8000 & bits) ? fg : bg;
for (r = 0; r < 5; r++)
{
*buf++ = (0x80 & bits) ? fg : bg;
bits <<= 1;
}
}
ili9341_bulk(x, y, 5, 7);
}
void
ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg)
{
@ -360,17 +369,25 @@ ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t 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;
uint8_t bits;
int c, r;
for(c = 0; c < 7*size; c++) {
ch = x5x7_map_char_table(ch);
for(c = 0; c < 7*size; c++)
{
bits = x5x7_bits[(ch * 7) + (c / size)];
for (r = 0; r < 5*size; r++) {
*buf++ = (0x8000 & bits) ? fg : bg;
if (r % size == (size-1)) {
for (r = 0; r < 5*size; r++)
{
*buf++ = (0x80 & bits) ? fg : bg;
if (r % size == (size-1))
{
bits <<= 1;
}
}
@ -378,6 +395,8 @@ ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_
ili9341_bulk(x, y, 5*size, 7*size);
}
void
ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size)
{

View file

@ -147,15 +147,19 @@ extern int area_height;
// font
extern const uint16_t x5x7_bits [];
extern const uint8_t x5x7_bits [];
extern const uint32_t numfont20x24[][24];
#define S_PI "\034"
#define S_MICRO "\035"
#define S_OHM "\036"
#define S_DEGREE "\037"
#define S_LARROW "\032"
#define S_RARROW "\033"
#define S_PI "\003"
#define S_MICRO "\004"
#define S_OHM "\005"
#define S_DEGREE "\006"
#define S_LARROW "\001"
#define S_RARROW "\002"
extern uint8_t x5x7_map_char_table(uint8_t ch);
// trace

48
plot.c
View file

@ -1003,19 +1003,27 @@ cell_draw_refpos(int m, int n, int w, int h)
}
}
void
draw_marker(int w, int h, int x, int y, int c, int ch)
{
int i, j;
for (j = 10; j >= 0; j--) {
ch = x5x7_map_char_table(ch);
for (j = 10; j >= 0; j--)
{
int j0 = j / 2;
for (i = -j0; i <= j0; i++) {
for (i = -j0; i <= j0; i++)
{
int x0 = x + i;
int y0 = y - j;
int cc = c;
if (j <= 9 && j > 2 && i >= -1 && i <= 3) {
uint16_t bits = x5x7_bits[(ch * 7) + (9-j)];
if (bits & (0x8000>>(i+1)))
if ( j <= 9 && j > 2 && i >= -1 && i <= 3 )
{
uint8_t bits = x5x7_bits[(ch * 7) + (9-j)];
if ( bits & (0x80>>(i+1)) )
cc = 0;
}
if (y0 >= 0 && y0 < h && x0 >= 0 && x0 < w)
@ -1024,6 +1032,8 @@ draw_marker(int w, int h, int x, int y, int c, int ch)
}
}
void
marker_position(int m, int t, int *x, int *y)
{
@ -1300,27 +1310,40 @@ request_to_draw_cells_behind_numeric_input(void)
}
void
cell_drawchar_5x7(int w, int h, uint8_t ch, int x, int y, uint16_t fg, int invert)
{
uint16_t bits;
uint8_t bits;
int c, r;
if (y <= -7 || y >= h || x <= -5 || x >= w)
return;
for(c = 0; c < 7; c++) {
ch = x5x7_map_char_table(ch);
for(c = 0; c < 7; c++)
{
if ((y + c) < 0 || (y + c) >= h)
continue;
bits = x5x7_bits[(ch * 7) + c];
if (invert)
bits = ~bits;
for (r = 0; r < 5; r++) {
if ((x+r) >= 0 && (x+r) < w && (0x8000 & bits))
for (r = 0; r < 5; r++)
{
if ( (x+r) >= 0 && (x+r) < w && (0x80 & bits) )
spi_buffer[(y+c)*w + (x+r)] = fg;
bits <<= 1;
}
}
}
void
cell_drawstring_5x7(int w, int h, char *str, int x, int y, uint16_t fg)
{
@ -1331,16 +1354,21 @@ cell_drawstring_5x7(int w, int h, char *str, int x, int y, uint16_t fg)
}
}
void
cell_drawstring_invert_5x7(int w, int h, char *str, int x, int y, uint16_t fg, int invert)
{
while (*str) {
while (*str)
{
cell_drawchar_5x7(w, h, *str, x, y, fg, invert);
x += 5;
str++;
}
}
static void
cell_draw_marker_info(int m, int n, int w, int h)
{