linux-st7735/spilcd_font.c
2020-08-02 15:57:45 +00:00

38 lines
790 B
C

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "spilcd_font.h"
#include "font8x8_basic.h"
static void lcd_pushChar(lcd_t* lcd, char c)
{
char* bitmap = font8x8_basic[(unsigned int) c];
int x,y;
int set;
for (x=0; x < 8; x++) {
for (y=0; y < 8; y++) {
set = bitmap[x] & 1 << y;
if (set) {
lcd_pushPixel(lcd, 200, 0, 0);
} else {
lcd_pushPixel(lcd, 0, 0, 0);
}
}
}
}
void lcd_drawChar(lcd_t* lcd, uint8 x, uint8 y, char c, uint8 r, uint8 g, uint8 b)
{
lcd_setWindow(lcd, x, y, x+8 - 1, y+8 - 1);
lcd_pushChar(lcd, c);
}
void lcd_drawText(lcd_t* lcd, uint8 x, uint8 y, char* text, uint8 r, uint8 g, uint8 b)
{
for (int i = 0; i < strlen(text); i++) {
lcd_drawChar(lcd, x + i * 8, y, text[i], r, g, b);
}
}