static void clear_pixel_range(uint8_t buf[], int row, int start, int end) { int i; for (i = start; i <= end; i++) clear_pixel(buf, row, i); }
/** * Draw character on screen * * @param character character to draw * @param x character x coordinate * @param y character y coordinate */ void draw_character(char character, int x, int y) { // Get the font binary address by run objdump -t build/font.o unsigned char *font_addr = (unsigned char *)&_binary_font_font_bin_start; int row; unsigned int bits, bit; if (character > 127) { return; } // Each character cost 16 bytes in font.bin font_addr += CHARACTER_SIZE * character; for (row = 0; row < CHARACTER_HEIGHT; row += 1) { bits = (unsigned int)peek_b((MEM_ADDR)(font_addr + row)); bit = CHARACTER_WIDTH; do { bits = bits << 1; bit -= 1; if ((bits & 0x100) != 0) { set_pixel(x + bit, y); } else { clear_pixel(x + bit, y); } } while (bit != 0); y += 1; } }
void Display::draw_char(uint16_t x, uint16_t y, const char c) { uint8_t line; // draw char to pixel for (uint8_t i = 0; i < 6; i++) { if (i == 5) { line = 0; } else { line = _font[(c * 5) + i]; } for (uint8_t j = 0; j < 8; j++) { if (line & 1) { set_pixel(x + i, y + j); } else { clear_pixel(x + i, y + j); } line >>= 1; } } // update display _need_update = true; }