Trying to create a font for the arduino project. And the display library contains code that I understand what I am doing, but I don’t understand how. Because of this section, it is impossible to add Russian font.
void Paint::DrawCharAt(int x, int y, char ascii_char, sFONT* font, int colored) { int i, j; //Height=16, Width=11 unsigned int char_offset = (ascii_char - ' ') * font->Height * (font->Width / 8 + (font->Width % 8 ? 1 : 0)); const unsigned char* ptr = &font->table[char_offset]; for (j = 0; j < font->Height; j++) { for (i = 0; i < font->Width; i++) { if (pgm_read_byte(ptr) & (0x80 >> (i % 8))) { DrawPixel(x + i, y + j, colored);//рисуем пиксель } if (i % 8 == 7) { ptr++; } } if (font->Width % 8 != 0) { ptr++; } } } const uint8_t Font16_Table[] PROGMEM = { // @0 ' ' (11 pixels wide) 0x00, 0x00, // 0x00, 0x00, // 0x00, 0x00, // xxx }; sFONT Font16 = { Font16_Table, 11, /* Width */ 16, /* Height */ }; The code above takes and goes over the table Font16_Table , where the comma-separated HEX codes are indicated. This seems to be understandable, but adding your own font to this table is not displayed. In this case, the 32-HEX codes form 1 letter. Those. The procedure receives the character code of the letter and somehow understands the position of its HEX code.
Explain how to pass the character code if you set 0, 0, etc. Does not help? And in general, what does that procedure do?
Here is the procedure that calls it:
void Paint::DrawStringAt(int x, int y, const char* text, sFONT* font, int colored) { const char* p_text = text; unsigned int counter = 0; int refcolumn = x; /* Send the string character by character on EPD */ while (*p_text != 0) { /* Display one character on EPD */ DrawCharAt(refcolumn, y, *p_text, font, colored); /* Decrement the column position by 16 */ refcolumn += font->Width; /* Point on the next character */ p_text++; counter++; } } Do I understand correctly that she takes the text, receives the character char code of the letter, then this code is a number, say the Russian letter A will have the code 192. I still can’t understand how the code points to the HEX table where to find the beginning of the Russian letter A. If you just add the letters A to the end of the HEX - I get hieroglyphs or something else but not my painted letter. With the correct formation of the letter, I figured out - 100% sure that I draw the letter correctly. I tried replacing the English letter, for example H and drew our Russian U instead. When I type the text, H displays Y - everything is ok. But the Cyrillic alphabet is not seen as a bud. Help to understand, from the answer it became partially clear, but not quite :-(