linux-st7735/spilcd_font.c

38 lines
730 B
C
Raw Normal View History

2020-08-02 13:51:47 +00:00
#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_printChar(lcd_t* lcd, uint8 x, uint8 y, char c)
{
lcd_setWindow(lcd, x, y, x+8 - 1, y+8 - 1);
lcd_pushChar(lcd, c);
}
void lcd_printText(lcd_t* lcd, uint8 x, uint8 y, char* text)
{
for (int i = 0; i < strlen(text); i++) {
lcd_printChar(lcd, x + i * 8, y, text[i]);
}
}