linux-st7735/spilcd_font.c

39 lines
853 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"
2020-08-02 19:38:10 +00:00
static void lcd_pushChar(lcd_t* lcd, char c, uint8 r, uint8 g, uint8 b)
2020-08-02 13:51:47 +00:00
{
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) {
2020-08-02 19:38:10 +00:00
lcd_pushPixel(lcd, r, g, b);
2020-08-02 13:51:47 +00:00
} else {
2020-08-02 19:38:10 +00:00
//lcd_pushPixel(lcd, 0, 0, 0);
lcd_pushPixelSkip(lcd);
2020-08-02 13:51:47 +00:00
}
}
}
}
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);
2020-08-02 19:38:10 +00:00
lcd_pushChar(lcd, c, r, g, b);
2020-08-02 13:51:47 +00:00
}
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
}
}