linux-st7735/spilcd_font.c

38 lines
790 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);
}
}
}
}
2020-08-02 15:57:45 +00:00
void lcd_drawChar(lcd_t* lcd, uint8 x, uint8 y, char c, uint8 r, uint8 g, uint8 b)
2020-08-02 13:51:47 +00:00
{
lcd_setWindow(lcd, x, y, x+8 - 1, y+8 - 1);
lcd_pushChar(lcd, c);
}
2020-08-02 15:57:45 +00:00
void lcd_drawText(lcd_t* lcd, uint8 x, uint8 y, char* text, uint8 r, uint8 g, uint8 b)
2020-08-02 13:51:47 +00:00
{
for (int i = 0; i < strlen(text); i++) {
2020-08-02 15:57:45 +00:00
lcd_drawChar(lcd, x + i * 8, y, text[i], r, g, b);
2020-08-02 13:51:47 +00:00
}
}